Fix Android libretro builds

This commit is contained in:
刘皓 2025-01-14 18:51:56 -05:00
parent 688544096f
commit b1131c1a7b
No known key found for this signature in database
GPG key ID: 7901753DB465B711
2 changed files with 19 additions and 7 deletions

View file

@ -531,7 +531,7 @@ jobs:
endian: little endian: little
- arch_mkxpz: riscv64 - arch_mkxpz: riscv64
arch_alpine: riscv64 arch_alpine: riscv64
arch_llvm: riscv64gc-alpine-linux-musl arch_llvm: riscv64-alpine-linux-musl
cpu_family: riscv64 cpu_family: riscv64
cpu: rv64gc cpu: rv64gc
endian: little endian: little
@ -604,7 +604,7 @@ jobs:
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: libretro-mkxp-z.linux-musl.${{ matrix.arch_mkxpz }} 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 path: ${{ runner.temp }}/retro-phase2
build-retro-phase2-android: build-retro-phase2-android:
@ -617,21 +617,25 @@ jobs:
include: include:
- arch_mkxpz: armv7 - arch_mkxpz: armv7
arch_llvm: armv7a-linux-androideabi21 arch_llvm: armv7a-linux-androideabi21
arch_cmake: armv7-a
cpu_family: arm cpu_family: arm
cpu: generic-armv7-a cpu: generic-armv7-a
endian: little endian: little
- arch_mkxpz: arm64 - arch_mkxpz: arm64
arch_llvm: aarch64-linux-android21 arch_llvm: aarch64-linux-android21
arch_cmake: aarch64
cpu_family: aarch64 cpu_family: aarch64
cpu: generic-armv8-a cpu: generic-armv8-a
endian: little endian: little
- arch_mkxpz: x86 - arch_mkxpz: x86
arch_llvm: i686-linux-android21 arch_llvm: i686-linux-android21
arch_cmake: i686
cpu_family: x86 cpu_family: x86
cpu: i686 cpu: i686
endian: little endian: little
- arch_mkxpz: x86_64 - arch_mkxpz: x86_64
arch_llvm: x86_64-linux-android21 arch_llvm: x86_64-linux-android21
arch_cmake: x86_64
cpu_family: x86_64 cpu_family: x86_64
cpu: x86_64 cpu: x86_64
endian: little endian: little
@ -672,10 +676,12 @@ jobs:
echo "cpu_family = '${{ matrix.cpu_family }}'" | tee -a ${{ runner.temp }}/cross.ini echo "cpu_family = '${{ matrix.cpu_family }}'" | tee -a ${{ runner.temp }}/cross.ini
echo "cpu = '${{ matrix.cpu }}'" | tee -a ${{ runner.temp }}/cross.ini echo "cpu = '${{ matrix.cpu }}'" | tee -a ${{ runner.temp }}/cross.ini
echo "endian = '${{ matrix.endian }}'" | tee -a ${{ runner.temp }}/cross.ini echo "endian = '${{ matrix.endian }}'" | tee -a ${{ runner.temp }}/cross.ini
echo "[cmake]" | tee -a ${{ runner.temp }}/cross.ini
echo "CMAKE_SYSTEM_PROCESSOR = '${{ matrix.arch_cmake }}'" | tee -a ${{ runner.temp }}/cross.ini
mkdir ${{ runner.temp }}/retro-phase2 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/libretro-mkxp-z.info
meson setup build --cross-file ${{ runner.temp }}/cross.ini --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1 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 cd build
ninja -v ninja -v
llvm-strip libretro-mkxp-z.so llvm-strip libretro-mkxp-z.so
@ -683,7 +689,7 @@ jobs:
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: libretro-mkxp-z.android.${{ matrix.arch_mkxpz }} 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 path: ${{ runner.temp }}/retro-phase2
build-retro-phase2-darwin: build-retro-phase2-darwin:

View file

@ -1,4 +1,4 @@
project('mkxp-z', 'c', 'cpp', version: '2.4.2', meson_version: '>=0.63.0', default_options: ['cpp_std=c++14', 'buildtype=release']) project('mkxp-z', 'c', 'cpp', version: '2.4.2', meson_version: '>=1.3.0', default_options: ['cpp_std=c++14', 'buildtype=release'])
host_system = host_machine.system() host_system = host_machine.system()
host_endian = host_machine.endian() host_endian = host_machine.endian()
@ -106,11 +106,17 @@ if get_option('retro') == true
retro_link_args = [] retro_link_args = []
# 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 # 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' if (host_system == 'windows' or host_system == 'cygwin') and compilers['cpp'].has_link_argument('-static')
retro_link_args += '-static' retro_link_args += '-static'
endif endif
# Android doesn't have a built-in C++ standard library, so we need to statically link against the C++ standard library
if host_system == 'android'
compilers['cpp'].has_link_argument('-static-libstdc++', required: true)
retro_link_args += '-static-libstdc++'
endif
# If possible, stop the linker from reexporting the symbols from the static libraries we use (e.g. zlib) # 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 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') retro_link_args += '-Wl,--version-script,' + join_paths(meson.current_source_dir(), 'retro/link.T')