-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android CI: Enable KVM, Caching and AArch64 (#296)
* CI: Bump Android API version and add arm64-v8a target * CI: Avoid using date +%N * CI: Enable KVM and caching of AVD * CI: Change shebang in android driver
- Loading branch information
Showing
3 changed files
with
81 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,8 +268,20 @@ jobs: | |
arch: | ||
- name: x86_64 | ||
triple: x86_64-linux-android | ||
api-level: [ 26 ] | ||
# Don't abort runners if a single one fails | ||
emu-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | ||
- name: arm64-v8a | ||
triple: aarch64-linux-android | ||
# Google broke ARM64 emulation on x86_64 hosts. A workaround is to overwrite the qemu machine type. | ||
emu-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -accel off -qemu -machine virt | ||
api-level: [ 27, 33 ] | ||
# Please note that: | ||
# - arm64-v8a emulation on a x86_64 host currently is only possible up to API level 27 Oreo | ||
# - armeabi-v7a is only supported up to API level 24 | ||
exclude: | ||
- api-level: 33 | ||
arch: | ||
name: arm64-v8a | ||
# Don't abort runners if a single one fails | ||
fail-fast: false | ||
runs-on: ${{ matrix.os }} | ||
name: Android ${{ matrix.build-type }} ${{ matrix.arch.name }} API-${{ matrix.api-level }} | ||
|
@@ -279,13 +291,31 @@ jobs: | |
run: | | ||
sudo apt-get update -y | ||
sudo apt-get install patchelf ninja-build -y | ||
- uses: nttld/setup-ndk@v1 | ||
id: setup-ndk | ||
- name: Enable KVM | ||
run: | | ||
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules | ||
sudo udevadm control --reload-rules | ||
sudo udevadm trigger --name-match=kvm | ||
- name: AVD cache | ||
uses: actions/cache@v4 | ||
id: avd-cache | ||
with: | ||
path: | | ||
~/.android/avd/* | ||
~/.android/adb* | ||
key: avd-${{ matrix.api-level }}-${{ matrix.arch.name }} | ||
- name: Create AVD and Snapshot for Caching | ||
if: steps.avd-cache.outputs.cache-hit != 'true' | ||
uses: hmelder/[email protected] | ||
with: | ||
ndk-version: r26d | ||
api-level: ${{ matrix.api-level }} | ||
arch: ${{ matrix.arch.name }} | ||
force-avd-creation: false | ||
emulator-options: ${{ matrix.arch.emu-options }} | ||
disable-animations: true | ||
script: echo "Generated AVD snapshot for caching." | ||
# We are using the default NDK from the GitHub Actions runner. | ||
- name: Configure CMake | ||
env: | ||
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | ||
run: | | ||
export TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64 | ||
export CCPREFIX=$TOOLCHAIN/bin/${{ matrix.arch.triple }}${{ matrix.api-level }} | ||
|
@@ -321,13 +351,14 @@ jobs: | |
run: | | ||
NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" ninja -v | ||
- name: Test | ||
uses: reactivecircus/android-emulator-runner@v2 | ||
env: | ||
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} | ||
uses: hmelder/[email protected] | ||
with: | ||
api-level: ${{ matrix.api-level }} | ||
target: default | ||
arch: ${{ matrix.arch.name }} | ||
force-avd-creation: false | ||
emulator-options: ${{ matrix.arch.emu-options }} | ||
disable-animations: true | ||
target: default | ||
script: | | ||
${{github.workspace}}/.github/scripts/android_test_main.sh ${{github.workspace}}/build ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/sysroot ${{ matrix.arch.triple }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
export ANDROID_NDK_HOME=~/Library/Android/sdk/ndk/24.0.8215888 | ||
export TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64 | ||
export CCPREFIX=$TOOLCHAIN/bin/aarch64-linux-android24 | ||
export CC="$CCPREFIX-clang" | ||
export CXX="$CCPREFIX-clang++" | ||
export OBJC="$CCPREFIX-clang" | ||
export OBJCXX="$CCPREFIX-clang++" | ||
export AS="$CCPREFIX-clang" | ||
export LD="$TOOLCHAIN/bin/ld.lld" | ||
export AR="$TOOLCHAIN/bin/llvm-ar" | ||
export RANLIB="$TOOLCHAIN/bin/llvm-ranlib" | ||
export STRIP="$TOOLCHAIN/bin/llvm-strip" | ||
export NM="$TOOLCHAIN/bin/llvm-nm" | ||
export OBJDUMP="$TOOLCHAIN/bin/llvm-objdump" | ||
export LDFLAGS="-fuse-ld=lld" | ||
export LIBS="-lc++_shared" | ||
|
||
cmake -B build \ | ||
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \ | ||
-DANDROID_ABI=arm64-v8a \ | ||
-DANDROID_NDK=$ANDROID_NDK_HOME \ | ||
-DANDROID_STL=c++_shared \ | ||
-DCMAKE_FIND_USE_CMAKE_PATH=false \ | ||
-DCMAKE_C_COMPILER=$CC \ | ||
-DCMAKE_CXX_COMPILER=$CXX \ | ||
-DCMAKE_ASM_COMPILER=$AS \ | ||
-DCMAKE_BUILD_TYPE=Debug \ | ||
-DTESTS=ON \ | ||
-DANDROID_PLATFORM=android-24 \ | ||
-G Ninja |