Skip to content

Commit 36ab8f6

Browse files
committed
ci: Run tests against Android NDK
1 parent 3728fc0 commit 36ab8f6

File tree

7 files changed

+179
-0
lines changed

7 files changed

+179
-0
lines changed

.github/workflows/images.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
fail-fast: false
3838
matrix:
3939
cfg:
40+
- { name: Android NDK, id: android }
4041
- { name: Arch Linux, id: arch }
4142
- { name: CUDA (on Arch), id: cuda }
4243
- { name: CUDA Cross (on Ubuntu Jammy), id: cuda-cross }

.github/workflows/nonnative.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,16 @@ jobs:
4949
- uses: actions/checkout@v4
5050
- name: Run tests
5151
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./run_tests.py $CI_ARGS --cross cuda-cross.json --cross-only'
52+
53+
cross-android:
54+
runs-on: ubuntu-latest
55+
strategy:
56+
matrix:
57+
cfg:
58+
- { arch: aarch64 }
59+
- { arch: x86_64 }
60+
container: mesonbuild/android:lastest
61+
steps:
62+
- uses: actions/checkout@v4
63+
- name: Run tests
64+
run: bash -c 'source /ci/env_vars.sh; cd $GITHUB_WORKSPACE; ./run_tests.py $CI_ARGS --cross android-${{ matrix.cfg.arch }} --cross-only'

ci/ciimage/android/image.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"base_image": "debian:sid",
3+
"args": ["--cross", "/opt/android/toolchain.cross"],
4+
"env": {
5+
"ANDROID_HOME": "/opt/android",
6+
"ANDROID_SDKVER": "36.1.0",
7+
"CI": "1",
8+
"MESON_CI_JOBNAME": "android-cross"
9+
}
10+
}

ci/ciimage/android/install.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source /ci/common.sh
6+
source /ci/env_vars.sh
7+
8+
export DEBIAN_FRONTEND=noninteractive
9+
export LANG='C.UTF-8'
10+
11+
apt-get -y update
12+
apt-get -y upgrade
13+
14+
pkgs=(
15+
git ninja-build python3-pip sdkmanager
16+
)
17+
18+
apt-get -y install "${pkgs[@]}"
19+
20+
install_minimal_python_packages
21+
22+
# cleanup
23+
apt-get -y clean
24+
apt-get -y autoclean
25+
26+
# sdk install
27+
28+
set -x
29+
30+
if [ -z $ANDROID_HOME -o -z $ANDROID_SDKVER ]; then
31+
echo "ANDROID_HOME and ANDROID_SDKVER env var must be set!"
32+
exit 1
33+
fi
34+
35+
test -d ${HOME}/.android || mkdir ${HOME}/.android
36+
# there are currently zero user repos
37+
echo 'count=0' > ${HOME}/.android/repositories.cfg
38+
cat <<EOF >> ${HOME}/.android/sites-settings.cfg
39+
@version@=1
40+
@disabled@https\://dl.google.com/android/repository/extras/intel/addon.xml=disabled
41+
@disabled@https\://dl.google.com/android/repository/glass/addon.xml=disabled
42+
@disabled@https\://dl.google.com/android/repository/sys-img/android/sys-img.xml=disabled
43+
@disabled@https\://dl.google.com/android/repository/sys-img/android-tv/sys-img.xml=disabled
44+
@disabled@https\://dl.google.com/android/repository/sys-img/android-wear/sys-img.xml=disabled
45+
@disabled@https\://dl.google.com/android/repository/sys-img/google_apis/sys-img.xml=disabled
46+
EOF
47+
48+
ANDROID_SDKMAJOR=`echo ${ANDROID_SDKVER} | awk -F '.' '{print $1}'`
49+
ANDROID_NDKVER="29.0.14206865"
50+
51+
# accepted licenses
52+
53+
mkdir -p $ANDROID_HOME/licenses/
54+
55+
cat << EOF > $ANDROID_HOME/licenses/android-sdk-license
56+
57+
8933bad161af4178b1185d1a37fbf41ea5269c55
58+
59+
d56f5187479451eabf01fb78af6dfcb131a6481e
60+
61+
24333f8a63b6825ea9c5514f83c2829b004d1fee
62+
EOF
63+
64+
cat <<EOF > $ANDROID_HOME/licenses/android-sdk-preview-license
65+
66+
84831b9409646a918e30573bab4c9c91346d8abd
67+
EOF
68+
69+
cat <<EOF > $ANDROID_HOME/licenses/android-sdk-preview-license-old
70+
71+
79120722343a6f314e0719f863036c702b0e6b2a
72+
73+
84831b9409646a918e30573bab4c9c91346d8abd
74+
EOF
75+
76+
cat <<EOF > $ANDROID_HOME/licenses/intel-android-extra-license
77+
78+
d975f751698a77b662f1254ddbeed3901e976f5a
79+
EOF
80+
81+
SDKMANAGER="sdkmanager --sdk_root=${ANDROID_HOME}" #ANDROID_HOME may not contain a space :(
82+
${SDKMANAGER} \
83+
"ndk;${ANDROID_NDKVER}"
84+
85+
tee "${ANDROID_HOME}/toolchain.cross" <<EOF
86+
[constants]
87+
toolchain='${ANDROID_HOME}/ndk/${ANDROID_NDKVER}/toolchains/llvm/prebuilt/`uname -s | tr "[:upper:]" "[:lower:]"`-`uname -m`/'
88+
EOF

cross/android-aarch64.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[constants]
2+
arch = 'aarch64'
3+
abi = 'arm64-v8a'
4+
platform = 'android'
5+
common_flags = []
6+
7+
[host_machine]
8+
cpu_family = 'aarch64'
9+
cpu = 'aarch64'
10+
endian = 'little'
11+
system = 'android'
12+
13+
[binaries]
14+
c = toolchain / 'bin' / arch+'-linux-'+platform+'31-clang'
15+
cpp = toolchain / 'bin' / arch+'-linux-'+platform+'31-clang++'
16+
ar = toolchain / 'bin/llvm-ar'
17+
as = toolchain / 'bin/llvm-as'
18+
ranlib = toolchain / 'bin/llvm-ranlib'
19+
ld = toolchain / 'bin/ld'
20+
strip = toolchain / 'bin/llvm-strip'
21+
22+
[built-in options]
23+
c_args = common_flags
24+
c_link_args = common_flags + ['-Wl,--build-id=sha1']
25+
cpp_args = c_args
26+
cpp_link_args = c_link_args
27+
28+
prefix = '/'
29+
bindir = 'bin' / abi
30+
libdir = 'lib' / abi
31+
32+
[properties]
33+
sys_root = toolchain / 'sysroot/'

cross/android-x86_64.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[constants]
2+
arch = 'x86_64'
3+
abi = 'x86_64'
4+
platform = 'android'
5+
common_flags = []
6+
7+
[host_machine]
8+
cpu_family = 'x86_64'
9+
cpu = 'x86_64'
10+
endian = 'little'
11+
system = 'android'
12+
13+
[binaries]
14+
c = toolchain / 'bin' / arch+'-linux-'+platform+'31-clang'
15+
cpp = toolchain / 'bin' / arch+'-linux-'+platform+'31-clang++'
16+
ar = toolchain / 'bin/llvm-ar'
17+
as = toolchain / 'bin/llvm-as'
18+
ranlib = toolchain / 'bin/llvm-ranlib'
19+
ld = toolchain / 'bin/ld'
20+
strip = toolchain / 'bin/llvm-strip'
21+
22+
[built-in options]
23+
c_args = common_flags
24+
c_link_args = common_flags + ['-Wl,--build-id=sha1']
25+
cpp_args = c_args
26+
cpp_link_args = c_link_args
27+
28+
prefix = '/'
29+
bindir = 'bin' / abi
30+
libdir = 'lib' / abi
31+
32+
[properties]
33+
sys_root = toolchain / 'sysroot/'

run_shell_checks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'ci/ciimage/fedora/install.sh',
2828
'ci/ciimage/arch/install.sh',
2929
'ci/ciimage/gentoo/install.sh',
30+
'ci/ciimage/android/install.sh',
3031
'manual tests/4 standalone binaries/myapp.sh',
3132
'manual tests/4 standalone binaries/osx_bundler.sh',
3233
'manual tests/4 standalone binaries/linux_bundler.sh',

0 commit comments

Comments
 (0)