diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 9969159f..217e1f6c 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -310,7 +310,7 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: | sudo apt update - sudo apt install -y git curl build-essential automake libtool binaryen wabt universal-ctags + sudo apt install -y git curl build-essential automake libtool binaryen wabt zip universal-ctags - name: Download WASI SDK if: steps.cache.outputs.cache-hit != 'true' @@ -331,7 +331,7 @@ jobs: name: retro-phase1.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} path: retro/build/retro-phase1 - build-retro-phase2-windows: + build-retro-windows: needs: build-retro-phase1 name: LR Windows runs-on: windows-latest @@ -354,24 +354,24 @@ jobs: msystem: mingw64 install: base-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-meson mingw-w64-x86_64-cmake - - name: Build phase 2 + - name: Build core shell: msys2 {0} run: | runner_temp="$(cygpath '${{ runner.temp }}')" mkdir "$runner_temp"/retro-phase2 - cp retro/core.info "$runner_temp"/retro-phase2/libretro-mkxp-z.info + cp retro/core.info "$runner_temp"/retro-phase2/mkxp-z_libretro.info meson setup build --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 cd build ninja -v strip libretro-mkxp-z.dll - mv libretro-mkxp-z.dll "$runner_temp"/retro-phase2 + mv libretro-mkxp-z.dll "$runner_temp"/retro-phase2/mkxp-z_libretro.dll - uses: actions/upload-artifact@v4 with: name: libretro-mkxp-z.windows.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} path: ${{ runner.temp }}/retro-phase2 - build-retro-phase2-linux-gnu: + build-retro-linux-gnu: needs: build-retro-phase1 name: LR GNU/Linux ${{ matrix.arch_mkxpz }} runs-on: ubuntu-latest @@ -440,10 +440,10 @@ jobs: sudo apt install -y gcc-${{ matrix.arch_gcc }} g++-${{ matrix.arch_gcc }} fi - - name: Build phase 2 + - name: Build core run: | mkdir ${{ runner.temp }}/retro-phase2 - cp retro/core.info ${{ runner.temp }}/retro-phase2/libretro-mkxp-z.info + cp retro/core.info ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.info if [ '${{ matrix.arch_mkxpz }}' != 'x86_64' ] then cross_arg='--cross-file linux/meson-${{ matrix.arch_mkxpz }}.txt' @@ -459,14 +459,14 @@ jobs: else strip libretro-mkxp-z.so fi - mv libretro-mkxp-z.so ${{ runner.temp }}/retro-phase2 + mv libretro-mkxp-z.so ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.so - uses: actions/upload-artifact@v4 with: name: libretro-mkxp-z.linux-gnu.${{ matrix.arch_mkxpz }}.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} path: ${{ runner.temp }}/retro-phase2 - build-retro-phase2-linux-musl: + build-retro-linux-musl: needs: build-retro-phase1 name: LR Alpine Linux ${{ matrix.arch_mkxpz }} runs-on: ubuntu-latest @@ -561,7 +561,7 @@ jobs: branch: latest-stable packages: build-base - - name: Build phase 2 + - name: Build core run: | echo '#!/bin/sh'$'\n''exec clang --target=${{ matrix.arch_llvm }} -fuse-ld=lld --sysroot=${{ steps.sysroot.outputs.root-path }} "$@"' > ${{ runner.temp }}/cc echo '#!/bin/sh'$'\n''exec clang++ --target=${{ matrix.arch_llvm }} -fuse-ld=lld --sysroot=${{ steps.sysroot.outputs.root-path }} "$@"' > ${{ runner.temp }}/c++ @@ -583,19 +583,19 @@ jobs: echo '--------------------------------------------------------------------------------' mkdir ${{ runner.temp }}/retro-phase2 - cp retro/core.info ${{ runner.temp }}/retro-phase2/libretro-mkxp-z.info + cp retro/core.info ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.info meson setup build --cross-file ${{ runner.temp }}/cross.ini --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 cd build ninja -v llvm-strip libretro-mkxp-z.so - mv libretro-mkxp-z.so ${{ runner.temp }}/retro-phase2 + mv libretro-mkxp-z.so ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.so - uses: actions/upload-artifact@v4 with: name: libretro-mkxp-z.linux-musl.${{ matrix.arch_mkxpz }}.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} path: ${{ runner.temp }}/retro-phase2 - build-retro-phase2-android: + build-retro-android: needs: build-retro-phase1 name: LR Android ${{ matrix.arch_mkxpz }} runs-on: ubuntu-latest @@ -652,7 +652,7 @@ jobs: ndk-version: r27c add-to-path: false - - name: Build phase 2 + - name: Build core run: | echo "[binaries]" | tee -a ${{ runner.temp }}/cross.ini echo "c = '${{ steps.ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.arch_llvm }}-clang'" | tee -a ${{ runner.temp }}/cross.ini @@ -669,19 +669,19 @@ jobs: echo '--------------------------------------------------------------------------------' mkdir ${{ runner.temp }}/retro-phase2 - cp retro/core.info ${{ runner.temp }}/retro-phase2/libretro-mkxp-z.info + cp retro/core.info ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.info ANDROID_NDK=${{ steps.ndk.outputs.ndk-path }} meson setup build --cross-file ${{ runner.temp }}/cross.ini --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 cd build ninja -v llvm-strip libretro-mkxp-z.so - mv libretro-mkxp-z.so ${{ runner.temp }}/retro-phase2 + mv libretro-mkxp-z.so ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.so - uses: actions/upload-artifact@v4 with: name: libretro-mkxp-z.android.${{ matrix.arch_mkxpz }}.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} path: ${{ runner.temp }}/retro-phase2 - build-retro-phase2-darwin: + build-retro-darwin: needs: build-retro-phase1 name: LR Darwin ${{ matrix.arch_mkxpz }} runs-on: macos-latest @@ -717,7 +717,7 @@ jobs: run: | brew install -q git gpatch meson cmake - - name: Build phase 2 + - name: Build core run: | echo '#!/bin/sh'$'\n''exec clang --target=${{ matrix.arch_llvm }} "$@"' > ${{ runner.temp }}/cc echo '#!/bin/sh'$'\n''exec clang++ --target=${{ matrix.arch_llvm }} "$@"' > ${{ runner.temp }}/c++ @@ -737,19 +737,144 @@ jobs: echo '--------------------------------------------------------------------------------' mkdir ${{ runner.temp }}/retro-phase2 - cp retro/core.info ${{ runner.temp }}/retro-phase2/libretro-mkxp-z.info + cp retro/core.info ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.info PATH="$HOMEBREW_PREFIX/opt/gpatch/libexec/gnubin:$PATH" meson setup build --cross-file ${{ runner.temp }}/cross.ini --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 cd build ninja -v strip -x libretro-mkxp-z.dylib - mv libretro-mkxp-z.dylib ${{ runner.temp }}/retro-phase2 + mv libretro-mkxp-z.dylib ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.dylib - uses: actions/upload-artifact@v4 with: name: libretro-mkxp-z.darwin.${{ matrix.arch_mkxpz }}.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} path: ${{ runner.temp }}/retro-phase2 - build-retro-phase2-wiiu: + build-retro-emscripten: + needs: build-retro-phase1 + name: LR Emscripten + runs-on: ubuntu-latest + steps: + - id: short-sha + uses: benjlevesque/short-sha@v2.2 + with: + length: 7 + + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: retro-phase1.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: retro/build/retro-phase1 + + - name: Install apt dependencies + run: | + sudo apt update + sudo apt install -y git build-essential meson cmake + + - uses: mymindstorm/setup-emsdk@v14 + with: + version: 3.1.46 + + - name: Build core + run: | + echo "[binaries]" | tee -a ${{ runner.temp }}/cross.ini + echo "c = 'emcc'" | tee -a ${{ runner.temp }}/cross.ini + echo "cpp = 'em++'" | tee -a ${{ runner.temp }}/cross.ini + echo "ar = 'emar'" | tee -a ${{ runner.temp }}/cross.ini + echo "[host_machine]" | tee -a ${{ runner.temp }}/cross.ini + echo "system = 'emscripten'" | tee -a ${{ runner.temp }}/cross.ini + echo "cpu_family = 'wasm32'" | tee -a ${{ runner.temp }}/cross.ini + echo "cpu = 'wasm32'" | tee -a ${{ runner.temp }}/cross.ini + echo "endian = 'little'" | tee -a ${{ runner.temp }}/cross.ini + echo '--------------------------------------------------------------------------------' + + mkdir ${{ runner.temp }}/retro-phase2 + cp retro/core.info ${{ runner.temp }}/retro-phase2/mkxp-z_libretro.info + meson setup build --cross-file ${{ runner.temp }}/cross.ini --default-library static --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 + cd build + ninja -v + + - name: Link core + run: | + cd build + mkdir mkxp-link + cd mkxp-link + set -o xtrace + find ../ -type f -name '*.a' -print0 | while IFS= read -r -d '' path; do + filename="$(basename "$path")" + mkdir "$filename.p" + cd "$filename.p" + emar x "../$path" + cd .. + done + find ./ -type f -name '*.o' -print0 | xargs -0 emcc -r -o ${{ runner.temp }}/libretro-mkxp-z.bc + + - name: Build RetroArch + run: | + cd ${{ runner.temp }} + git clone https://github.com/libretro/RetroArch retroarch --depth 1 -b $(curl -s https://api.github.com/repos/libretro/RetroArch/releases/latest | jq -r '.tag_name') + mv libretro-mkxp-z.bc retroarch/libretro_emscripten.bc + cd retroarch + emmake make -f Makefile.emscripten LIBRETRO=mkxp-z + mv mkxp-z_libretro.wasm ${{ runner.temp }}/retro-phase2 + mv mkxp-z_libretro.js ${{ runner.temp }}/retro-phase2 + + - uses: actions/upload-artifact@v4 + with: + name: libretro-mkxp-z.emscripten.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: ${{ runner.temp }}/retro-phase2 + + build-retro-vita: + needs: build-retro-phase1 + name: LR PlayStation Vita + runs-on: ubuntu-latest + container: vitasdk/vitasdk:latest + steps: + - id: short-sha + uses: benjlevesque/short-sha@v2.2 + with: + length: 7 + + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: retro-phase1.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: retro/build/retro-phase1 + + - name: Install dependencies + run: | + apk update + apk add git build-base meson cmake + + - name: Build core + run: | + echo "[binaries]" | tee -a ~/cross.ini + echo "c = 'arm-vita-eabi-gcc'" | tee -a ~/cross.ini + echo "cpp = 'arm-vita-eabi-g++'" | tee -a ~/cross.ini + echo "ar = 'arm-vita-eabi-ar'" | tee -a ~/cross.ini + echo "[host_machine]" | tee -a ~/cross.ini + echo "system = 'bare'" | tee -a ~/cross.ini + echo "cpu_family = 'arm'" | tee -a ~/cross.ini + echo "cpu = 'generic-armv7-a'" | tee -a ~/cross.ini + echo "endian = 'little'" | tee -a ~/cross.ini + echo '--------------------------------------------------------------------------------' + + mkdir ~/retro-phase2 + cp retro/core.info ~/retro-phase2/mkxp-z_libretro.info + meson setup build --cross-file ~/cross.ini --default-library static -Db_staticpic=false --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 + cd build + ninja -v + mv libretro-mkxp-z.a ~/retro-phase2/mkxp-z_libretro.a + + - uses: actions/upload-artifact@v4 + with: + name: libretro-mkxp-z.vita.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} + path: ~/retro-phase2 + + build-retro-wiiu: needs: build-retro-phase1 name: LR Wii U runs-on: ubuntu-latest @@ -774,13 +899,12 @@ jobs: apt install -y git build-essential pip ninja-build cmake pip install meson - - name: Build phase 2 + - name: Build core run: | echo "[binaries]" | tee -a ~/cross.ini echo "c = '/opt/devkitpro/devkitPPC/bin/powerpc-eabi-gcc'" | tee -a ~/cross.ini echo "cpp = '/opt/devkitpro/devkitPPC/bin/powerpc-eabi-g++'" | tee -a ~/cross.ini echo "ar = '/opt/devkitpro/devkitPPC/bin/powerpc-eabi-ar'" | tee -a ~/cross.ini - echo "strip = '/opt/devkitpro/devkitPPC/bin/powerpc-eabi-strip'" | tee -a ~/cross.ini echo "[host_machine]" | tee -a ~/cross.ini echo "system = 'bare'" | tee -a ~/cross.ini echo "cpu_family = 'ppc'" | tee -a ~/cross.ini @@ -789,19 +913,18 @@ jobs: echo '--------------------------------------------------------------------------------' mkdir ~/retro-phase2 - cp retro/core.info ~/retro-phase2/libretro-mkxp-z.info + cp retro/core.info ~/retro-phase2/mkxp-z_libretro.info meson setup build --cross-file ~/cross.ini --default-library static --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 cd build ninja -v - /opt/devkitpro/devkitPPC/bin/powerpc-eabi-strip libretro-mkxp-z.a - mv libretro-mkxp-z.a ~/retro-phase2 + mv libretro-mkxp-z.a ~/retro-phase2/mkxp-z_libretro.a - uses: actions/upload-artifact@v4 with: name: libretro-mkxp-z.wiiu.${{ github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name }}-${{ steps.short-sha.outputs.sha }} path: ~/retro-phase2 - build-retro-phase2-switch: + build-retro-switch: needs: build-retro-phase1 name: LR Nintendo Switch runs-on: ubuntu-latest @@ -826,13 +949,12 @@ jobs: apt install -y git build-essential pip ninja-build cmake pip install meson - - name: Build phase 2 + - name: Build core run: | echo "[binaries]" | tee -a ~/cross.ini echo "c = '/opt/devkitpro/devkitA64/bin/aarch64-none-elf-gcc'" | tee -a ~/cross.ini echo "cpp = '/opt/devkitpro/devkitA64/bin/aarch64-none-elf-g++'" | tee -a ~/cross.ini echo "ar = '/opt/devkitpro/devkitA64/bin/aarch64-none-elf-ar'" | tee -a ~/cross.ini - echo "strip = '/opt/devkitpro/devkitA64/bin/aarch64-none-elf-strip'" | tee -a ~/cross.ini echo "[host_machine]" | tee -a ~/cross.ini echo "system = 'bare'" | tee -a ~/cross.ini echo "cpu_family = 'aarch64'" | tee -a ~/cross.ini @@ -841,13 +963,12 @@ jobs: echo '--------------------------------------------------------------------------------' mkdir ~/retro-phase2 - cp retro/core.info ~/retro-phase2/libretro-mkxp-z.info + cp retro/core.info ~/retro-phase2/mkxp-z_libretro.info # Enabling LTO with devkitA64 causes "plugin needed to handle lto object" linker error meson setup build --cross-file ~/cross.ini --default-library static --buildtype release -Db_lto=false -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 cd build ninja -v - /opt/devkitpro/devkitA64/bin/aarch64-none-elf-strip libretro-mkxp-z.a - mv libretro-mkxp-z.a ~/retro-phase2 + mv libretro-mkxp-z.a ~/retro-phase2/mkxp-z_libretro.a - uses: actions/upload-artifact@v4 with: diff --git a/meson.build b/meson.build index 3439d253..afd87e96 100644 --- a/meson.build +++ b/meson.build @@ -48,35 +48,6 @@ if get_option('retro') == true 'ZLIB_BUILD_EXAMPLES': false, }) - bzip2_options = cmake.subproject_options() - bzip2_options.add_cmake_defines({ - 'CMAKE_POSITION_INDEPENDENT_CODE': get_option('b_staticpic'), - 'CMAKE_BUILD_TYPE': 'None', - 'ENABLE_STATIC_LIB': true, - 'ENABLE_SHARED_LIB': false, - 'ENABLE_LIB_ONLY': true, - }) - - liblzma_options = cmake.subproject_options() - liblzma_options.add_cmake_defines({ - 'CMAKE_POSITION_INDEPENDENT_CODE': get_option('b_staticpic'), - 'BUILD_SHARED_LIBS': false, - 'ENABLE_NLS': false, - 'ENABLE_THREADS': 'OFF', - }) - - zstd_options = cmake.subproject_options() - zstd_options.add_cmake_defines({ - 'CMAKE_POSITION_INDEPENDENT_CODE': get_option('b_staticpic'), - 'ZSTD_BUILD_STATIC': true, - 'ZSTD_BUILD_SHARED': false, - 'ZSTD_BUILD_PROGRAMS': false, - 'ZSTD_BUILD_TESTS': false, - 'ZSTD_BUILD_CONTRIB': false, - 'ZSTD_MULTITHREAD_SUPPORT': false, - 'ZSTD_LEGACY_SUPPORT': false, - }) - libzip_options = cmake.subproject_options() libzip_options.add_cmake_defines({ 'CMAKE_POSITION_INDEPENDENT_CODE': get_option('b_staticpic'), @@ -93,9 +64,9 @@ if get_option('retro') == true 'ENABLE_OPENSSL': false, 'ENABLE_WINDOWS_CRYPTO': false, 'ENABLE_FDOPEN': false, - 'ENABLE_BZIP2': true, - 'ENABLE_LZMA': true, - 'ENABLE_ZSTD': true, + 'ENABLE_BZIP2': false, + 'ENABLE_LZMA': false, + 'ENABLE_ZSTD': false, }) physfs_options = cmake.subproject_options() @@ -186,6 +157,7 @@ if get_option('retro') == true endif retro_link_args = [] + retro_cppflags = [] # We need to statically link the C++ standard library (libstdc++/libc++), the compiler runtime library (libgcc/compiler-rt) and libpthread in MSYS2 builds for Windows because those are not part of the operating system if (host_system == 'windows' or host_system == 'cygwin') and compilers['cpp'].has_link_argument('-static') @@ -198,6 +170,14 @@ if get_option('retro') == true retro_link_args += '-static-libstdc++' endif + # Enable C++ exceptions when targeting Emscripten because they're disabled by default + if host_system == 'emscripten' + compilers['cpp'].has_argument('-fexceptions', required: true) + compilers['cpp'].has_link_argument('-fexceptions', required: true) + retro_cppflags += '-fexceptions' + retro_link_args += '-fexceptions' + endif + # If possible, stop the linker from reexporting the symbols from the static libraries we use (e.g. zlib) if compilers['cpp'].has_link_argument('-Wl,--version-script,' + join_paths(meson.current_source_dir(), 'retro/link.T')) # Only works with GNU linker and LLVM linker retro_link_args += '-Wl,--version-script,' + join_paths(meson.current_source_dir(), 'retro/link.T') @@ -217,9 +197,6 @@ if get_option('retro') == true cmake.subproject('boost_type_traits', options: boost_options).dependency('boost_type_traits'), cmake.subproject('boost_optional', options: boost_options).dependency('boost_optional'), cmake.subproject(host_system == 'darwin' ? 'zlib-darwin' : 'zlib', options: zlib_options).dependency('zlibstatic'), - cmake.subproject('bzip2', options: bzip2_options).dependency('bz2_static'), - cmake.subproject('liblzma', options: liblzma_options).dependency('liblzma'), - cmake.subproject('zstd', options: zstd_options).dependency('libzstd_static'), cmake.subproject('libzip', options: libzip_options).dependency('zip'), cmake.subproject('physfs', options: physfs_options).dependency('physfs-static'), cmake.subproject('openal-soft', options: openal_options).dependency('OpenAL'), @@ -247,9 +224,10 @@ if get_option('retro') == true '-Wno-ignored-optimization-argument', '-Wno-unused-command-line-argument', ] + retro_defines, - cpp_args: ['-Wno-unused-command-line-argument'] + retro_defines, + cpp_args: ['-Wno-unused-command-line-argument'] + retro_cppflags + retro_defines, link_args: retro_link_args, gnu_symbol_visibility: 'hidden', + install: true, # Prevents Meson from creating thin archives when building with `--default-library static`; see https://github.com/mesonbuild/meson/issues/9479 include_directories: [ include_directories('.'), include_directories('src'), diff --git a/retro/Makefile b/retro/Makefile index 0bd308da..d8ce7c76 100644 --- a/retro/Makefile +++ b/retro/Makefile @@ -7,7 +7,6 @@ ZLIB_VERSION ?= 1.3.1 OPENSSL_VERSION ?= 3.2.0 WASM_RT_VERSION ?= 1.0.36 SDL_VERSION ?= 2.30.11 -P7ZIP_VERSION ?= 17.06 TARGET ?= wasm32-wasip1 WASI_SDK ?= /opt/wasi-sdk WASM_OPT ?= wasm-opt @@ -16,6 +15,7 @@ CTAGS ?= ctags AUTORECONF ?= autoreconf CURL ?= curl GIT ?= git +ZIP ?= zip XXD ?= xxd SED ?= sed CC ?= cc @@ -35,7 +35,6 @@ OUTDIR := $(BUILD_PREFIX)/retro-phase1 LIBDIR := $(BUILD_PREFIX)/lib DOWNLOADS := $(BUILD_PREFIX)/downloads RUBY := $(LIBDIR)/bin/ruby -P7ZIP := $(DOWNLOADS)/p7zip/bin/7z CLONE := $(GIT) clone -q --depth 1 GITHUB := https://github.com WASI_CC := $(WASI_SDK)/bin/clang @@ -99,12 +98,18 @@ $(OUTDIR)/sdl/include/SDL.h: $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby-impl.h $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_0.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_1.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_2.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_3.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_4.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_5.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_6.c $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_7.c &: $(LIBDIR)/mkxp-retro-dist/bin/ruby mkdir -p $(OUTDIR)/mkxp-retro-ruby $(WASM2C) $(LIBDIR)/mkxp-retro-dist/bin/ruby -n ruby --num-outputs=8 -o $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby.c + # If we don't do this, the devkitARM and Vita SDK compilers will throw this warning due to some idiosyncrasy in how integer types work in those toolchains: + # warning: 'wasm_rt_type_t' is promoted to 'int' when passed through '...' + # note: (so you should pass 'int' not 'wasm_rt_type_t' to 'va_arg') + # note: if this code is reached, the program will abort + # The code will still compile, but like it says, the compiler will sprinkle trap instructions everywhere, so when you run the code it'll crash. Scary! Let's make sure that doesn't happen. + if ! for i in $(seq 0 7); do $(SED) -i 's/va_arg(\([a-z_][A-Za-z0-9_]*\), *wasm_rt_type_t)/va_arg(\1, int)/g' $(OUTDIR)/mkxp-retro-ruby/mkxp-retro-ruby_$$i.c; done; then rm -rf $(OUTDIR)/mkxp-retro-ruby; exit 1; fi $(OUTDIR)/mkxp-retro-dist.zip.c: $(LIBDIR)/mkxp-retro-dist.zip mkdir -p $(OUTDIR) cd $(LIBDIR) && $(XXD) -i mkxp-retro-dist.zip $(OUTDIR)/mkxp-retro-dist.zip.c -$(LIBDIR)/mkxp-retro-dist.zip: $(LIBDIR)/mkxp-retro-dist/bin/ruby $(P7ZIP) +$(LIBDIR)/mkxp-retro-dist.zip: $(LIBDIR)/mkxp-retro-dist/bin/ruby rm -rf $(LIBDIR)/_mkxp-retro-dist cp -r $(LIBDIR)/mkxp-retro-dist $(LIBDIR)/_mkxp-retro-dist rm $(LIBDIR)/_mkxp-retro-dist/bin/ruby @@ -114,7 +119,7 @@ $(LIBDIR)/mkxp-retro-dist.zip: $(LIBDIR)/mkxp-retro-dist/bin/ruby $(P7ZIP) rm -r $(LIBDIR)/_mkxp-retro-dist/lib/ruby/gems/$(RUBY_VERSION).0/cache/* echo '# This is a Ruby script that does nothing. We make Ruby load this file on startup just because Ruby needs to load a script on startup for some reason.' > $(LIBDIR)/_mkxp-retro-dist/bin/mkxp-z rm -f $(LIBDIR)/mkxp-retro-dist.zip - cd $(LIBDIR)/_mkxp-retro-dist && $(P7ZIP) a -bb3 -mm=zstd -mx=19 $(LIBDIR)/mkxp-retro-dist.zip * + cd $(LIBDIR)/_mkxp-retro-dist && $(ZIP) -r $(LIBDIR)/mkxp-retro-dist.zip * rm -r $(LIBDIR)/_mkxp-retro-dist $(LIBDIR)/mkxp-retro-dist/bin/ruby: $(DOWNLOADS)/crossruby/Makefile ruby-bindings.h @@ -180,15 +185,6 @@ $(DOWNLOADS)/baseruby/configure.ac: mkdir -p $(DOWNLOADS) $(CLONE) $(GITHUB)/ruby/ruby $(DOWNLOADS)/baseruby -b ruby_$(shell echo $(RUBY_VERSION) | $(SED) -e 's/\./_/g') -# p7zip - -$(P7ZIP): $(DOWNLOADS)/p7zip/makefile - cd $(DOWNLOADS)/p7zip && $(MAKE) 7z $(NATIVE_TOOLCHAIN) - -$(DOWNLOADS)/p7zip/makefile: - mkdir -p $(DOWNLOADS) - $(CLONE) $(GITHUB)/p7zip-project/p7zip $(DOWNLOADS)/p7zip -b v$(P7ZIP_VERSION) - # libyaml $(LIBDIR)/usr/local/lib/libyaml.a: $(DOWNLOADS)/libyaml/Makefile diff --git a/src/audio/fluid-fun.cpp b/src/audio/fluid-fun.cpp index a2463cef..f5e98ae1 100644 --- a/src/audio/fluid-fun.cpp +++ b/src/audio/fluid-fun.cpp @@ -8,11 +8,11 @@ #if defined(__LINUX__) || defined(__ANDROID__) # define FLUID_LIB "libfluidsynth.so.3" -#elif MKXPZ_BUILD_XCODE +#elif defined(MKXPZ_BUILD_XCODE) # define FLUID_LIB "@rpath/libfluidsynth.dylib" -#elif __APPLE__ +#elif defined(__APPLE__) # define FLUID_LIB "libfluidsynth.3.dylib" -#elif __WIN32__ +#elif defined(__WIN32__) # define FLUID_LIB "fluidsynth.dll" #elif !defined(SHARED_FLUID) # error "platform not recognized" diff --git a/subprojects/bzip2.wrap b/subprojects/bzip2.wrap deleted file mode 100644 index 7600a1a0..00000000 --- a/subprojects/bzip2.wrap +++ /dev/null @@ -1,5 +0,0 @@ -[wrap-git] -url = https://gitlab.com/bzip2/bzip2 -# 2023-06-01 -revision = 66c46b8c9436613fd81bc5d03f63a61933a4dcc3 -depth = 1 diff --git a/subprojects/fluidlite.wrap b/subprojects/fluidlite.wrap index 169ac7dd..00b4998b 100644 --- a/subprojects/fluidlite.wrap +++ b/subprojects/fluidlite.wrap @@ -1,4 +1,6 @@ [wrap-git] url = https://github.com/divideconcept/FluidLite +# 2023-04-18 revision = d59d2328818f913b7d1a6a59aed695c47a8ce388 depth = 1 +diff_files = fluidlite.patch diff --git a/subprojects/liblzma.wrap b/subprojects/liblzma.wrap deleted file mode 100644 index fc992f0e..00000000 --- a/subprojects/liblzma.wrap +++ /dev/null @@ -1,5 +0,0 @@ -[wrap-git] -url = https://github.com/ShiftMediaProject/liblzma -revision = v5.6.3 -depth = 1 -diff_files = liblzma.patch diff --git a/subprojects/libsndfile.wrap b/subprojects/libsndfile.wrap index a0f114dd..8de1a204 100644 --- a/subprojects/libsndfile.wrap +++ b/subprojects/libsndfile.wrap @@ -2,3 +2,4 @@ url = https://github.com/libsndfile/libsndfile revision = v1.0.30 depth = 1 +diff_files = libsndfile.patch diff --git a/subprojects/packagefiles/fluidlite.patch b/subprojects/packagefiles/fluidlite.patch new file mode 100644 index 00000000..262519f5 --- /dev/null +++ b/subprojects/packagefiles/fluidlite.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -19,7 +19,10 @@ if("${LOWERCASE_BUILD_TYPE}" STREQUAL "debug") + set(DEBUG TRUE) + endif() + include(TestBigEndian) +-test_big_endian(WORDS_BIGENDIAN) ++string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_LOWER) ++if(NOT SYSTEM_LOWER STREQUAL "emscripten") ++ test_big_endian(WORDS_BIGENDIAN) ++endif() + include(CheckIncludeFiles) + check_include_files("stdlib.h;stdio.h;stdarg.h;string.h;float.h;limits.h;math.h" STDC_HEADERS) + set(HAVE_STDLIB_H ${STDC_HEADERS} CACHE INTERNAL "Have include stdlib.h") diff --git a/subprojects/packagefiles/libsndfile.patch b/subprojects/packagefiles/libsndfile.patch new file mode 100644 index 00000000..acc8051a --- /dev/null +++ b/subprojects/packagefiles/libsndfile.patch @@ -0,0 +1,32 @@ +diff --git a/cmake/SndFileChecks.cmake b/cmake/SndFileChecks.cmake +--- a/cmake/SndFileChecks.cmake ++++ b/cmake/SndFileChecks.cmake +@@ -113,13 +113,9 @@ else () + set (SF_COUNT_MAX "0x7FFFFFFFFFFFFFFFLL") + set (SIZEOF_SF_COUNT_T 8) + else () +- message ("") +- message ("*** The configure process has determined that this system is capable") +- message ("*** of Large File Support but has not been able to find a type which") +- message ("*** is an unambiguous 64 bit file offset.") +- message ("*** Please contact the author to help resolve this problem.") +- message ("") +- message (FATAL_ERROR "Bad file offset type.") ++ set (TYPEOF_SF_COUNT_T "int64_t") ++ set (SF_COUNT_MAX "0x7FFFFFFFFFFFFFFFLL") ++ set (SIZEOF_SF_COUNT_T 8) + endif () + endif () + +@@ -179,7 +175,10 @@ endif () + + check_symbol_exists (S_IRGRP sys/stat.h HAVE_DECL_S_IRGRP) + +-test_big_endian (WORDS_BIGENDIAN) ++string (TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_LOWER) ++if (NOT SYSTEM_LOWER STREQUAL "emscripten") ++ test_big_endian(WORDS_BIGENDIAN) ++endif () + if (WORDS_BIGENDIAN) + set (CPU_IS_BIG_ENDIAN 1) + else () diff --git a/subprojects/packagefiles/libzip.patch b/subprojects/packagefiles/libzip.patch index 63124fe8..b54a92f2 100644 --- a/subprojects/packagefiles/libzip.patch +++ b/subprojects/packagefiles/libzip.patch @@ -3,10 +3,12 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -198,66 +198,17 @@ int main(int argc, char *argv[]) { }" HAVE_NULLABLE) - - test_big_endian(WORDS_BIGENDIAN) +@@ -196,68 +196,21 @@ check_c_source_compiles(" + int foo(char * _Nullable bar); + int main(int argc, char *argv[]) { }" HAVE_NULLABLE) +-test_big_endian(WORDS_BIGENDIAN) +- -find_package(ZLIB 1.1.2 REQUIRED) -# so developers on systems where zlib is named differently (Windows, sometimes) -# can override the name used in the pkg-config file @@ -36,6 +38,10 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt - string(REGEX REPLACE "^lib" "" ZLIB_LINK_LIBRARY_NAME ${ZLIB_FILENAME}) - endif() -endif(NOT ZLIB_LINK_LIBRARY_NAME) ++string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_LOWER) ++if(NOT SYSTEM_LOWER STREQUAL "emscripten") ++ test_big_endian(WORDS_BIGENDIAN) ++endif() if(ENABLE_BZIP2) - find_package(BZip2) @@ -99,6 +105,19 @@ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt target_include_directories(zip PUBLIC $ +diff --git a/lib/compat.h b/lib/compat.h +--- a/lib/compat.h ++++ b/lib/compat.h +@@ -154,7 +154,8 @@ typedef off_t zip_off_t; + #define ZIP_OFF_MAX ZIP_INT16_MAX + #define ZIP_OFF_MIN ZIP_INT16_MIN + #else +-#error unsupported size of off_t ++#define ZIP_OFF_MAX ZIP_INT64_MAX ++#define ZIP_OFF_MIN ZIP_INT64_MIN + #endif + + #define ZIP_FSEEK_MAX ZIP_OFF_MAX diff --git a/lib/zip_algorithm_bzip2.c b/lib/zip_algorithm_bzip2.c --- a/lib/zip_algorithm_bzip2.c +++ b/lib/zip_algorithm_bzip2.c diff --git a/subprojects/packagefiles/ogg.patch b/subprojects/packagefiles/ogg.patch index 76eb40df..95fc268f 100644 --- a/subprojects/packagefiles/ogg.patch +++ b/subprojects/packagefiles/ogg.patch @@ -1,3 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -66,7 +66,7 @@ set(USIZE32 uint32_t) + set(SIZE64 int64_t) + set(USIZE64 uint64_t) + +-include(CheckSizes) ++ + + configure_file(include/ogg/config_types.h.in include/ogg/config_types.h @ONLY) + diff --git a/include/ogg/ogg.h b/include/ogg/ogg.h --- a/include/ogg/ogg.h +++ b/include/ogg/ogg.h diff --git a/subprojects/packagefiles/openal-soft.patch b/subprojects/packagefiles/openal-soft.patch index 9917d1bf..1d3e4dd8 100644 --- a/subprojects/packagefiles/openal-soft.patch +++ b/subprojects/packagefiles/openal-soft.patch @@ -54,6 +54,15 @@ diff --git a/alc/helpers.cpp b/alc/helpers.cpp } +@@ -485,7 +469,7 @@ al::vector SearchDataFiles(const char *ext, const char *subdir) + + void SetRTPriority() + { +-#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) ++#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) && !defined(__EMSCRIPTEN__) + if(RTPrioLevel > 0) + { + struct sched_param param{}; diff --git a/common/almalloc.cpp b/common/almalloc.cpp --- a/common/almalloc.cpp +++ b/common/almalloc.cpp diff --git a/subprojects/zstd.wrap b/subprojects/zstd.wrap deleted file mode 100644 index ccf7ea60..00000000 --- a/subprojects/zstd.wrap +++ /dev/null @@ -1,5 +0,0 @@ -[wrap-git] -url = https://github.com/facebook/zstd -revision = v1.5.6 -depth = 1 -diff_files = zstd.patch