Skip to content

Commit 17f794c

Browse files
committed
Fix and test Android build
1 parent ca02a35 commit 17f794c

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

.github/workflows/CI.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,82 @@ jobs:
6060
CC: ${{ matrix.c-compiler }}
6161
CXX: ${{ matrix.cxx-compiler }}
6262

63+
tests-android:
64+
runs-on: ${{ matrix.host }}
65+
strategy:
66+
matrix:
67+
ndk-arch: [x86_64]
68+
arch: [x86_64]
69+
api-level: [21]
70+
target: [default]
71+
host: [ubuntu-24.04]
72+
python-version: [3.11.12]
73+
include:
74+
- ndk-arch: arm64-v8a
75+
arch: x86_64
76+
api-level: 30
77+
target: google_apis
78+
host: ubuntu-24.04
79+
python-version: 3.11.12
80+
- ndk-arch: x86
81+
arch: x86
82+
api-level: 21
83+
target: default
84+
host: ubuntu-24.04
85+
python-version: 3.11.12
86+
- ndk-arch: armeabi-v7a
87+
arch: x86_64
88+
api-level: 30
89+
target: google_apis
90+
host: ubuntu-24.04
91+
python-version: 3.11.12
92+
name: python-android-${{ matrix.python-version }}-${{ matrix.host }}
93+
steps:
94+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
95+
with:
96+
fetch-depth: 0
97+
path: src
98+
- name: Enable KVM
99+
run: |
100+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
101+
sudo udevadm control --reload-rules
102+
sudo udevadm trigger --name-match=kvm
103+
- name: Make build and prefix directories
104+
run: |
105+
mkdir build
106+
mkdir install-prefix
107+
- name: run action
108+
uses: reactivecircus/android-emulator-runner@v2
109+
with:
110+
api-level: ${{ matrix.api-level }}
111+
target: ${{ matrix.target }}
112+
arch: ${{ matrix.arch }}
113+
profile: Galaxy Nexus
114+
cores: 2
115+
ram-size: 2048M
116+
sdcard-path-or-size: 100M
117+
emulator-build: 7425822 # https://github.com/ReactiveCircus/android-emulator-runner/issues/160
118+
avd-name: test
119+
force-avd-creation: false
120+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
121+
disable-animations: true
122+
working-directory: build/
123+
ndk: 23.0.7421159
124+
cmake: 3.10.2.4988404
125+
channel: beta
126+
script: |
127+
adb devices
128+
ls $(pwd)/..
129+
cmake -DANDROID_NDK=/usr/local/lib/android/sdk/ndk/23.0.7421159/ -DCMAKE_INSTALL_PREFIX:PATH=../install-prefix -DCMAKE_TOOLCHAIN_FILE=/usr/local/lib/android/sdk/ndk/23.0.7421159/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.ndk-arch }} -DCMAKE_CROSSCOMPILING_EMULATOR=$(pwd)/.github/workflows/adb-emu.sh -DANDROID_ALLOW_UNDEFINED_SYMBOLS=On -DENABLE_DECIMAL=Off -DENABLE_CTYPES=Off -DENABLE_CODECS_JP=OFF -DENABLE_CODECS_KR=OFF -DENABLE_CODECS_TW=OFF -DENABLE_MULTIBYTECODEC=OFF -DENABLE_CODECS_CN=OFF -DENABLE_CODECS_HK=OFF -DENABLE_CODECS_ISO2022=OFF -DBUILD_EXTENSIONS_AS_BUILTIN=On -DANDROID_PLATFORM=android-21 -DPYTHON_VERSION=${{ matrix.python-version }} $(pwd)/..
130+
cmake --build . -- VERBOSE=1
131+
cmake --build . --target install
132+
133+
63134
pass: # This job does nothing and is only used for the branch protection
64135
if: always()
65136
needs:
66137
- tests
138+
- tests-android
67139

68140
runs-on: ubuntu-latest
69141

.github/workflows/adb-emu.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
adb push "$1" /data/local/tmp/ 1>/dev/null 2>/dev/null
3+
if [ $# -eq 1 ]; then
4+
adb shell /data/local/tmp/$(basename $1)
5+
elif [ $# -eq 3 ]; then
6+
adb push "$2" /data/local/tmp/ 1>/dev/null 2>/dev/null
7+
adb shell /data/local/tmp/$(basename $1) /data/local/tmp/$(basename $2) /data/local/tmp/$(basename $3)
8+
adb pull /data/local/tmp/$(basename $3) "$3" 1>/dev/null 2>/dev/null
9+
fi

0 commit comments

Comments
 (0)