From a6c7355ac5009e61ebae5cf264667396080646d1 Mon Sep 17 00:00:00 2001 From: Victor Gaydov Date: Mon, 17 Jun 2024 15:58:15 +0400 Subject: [PATCH] gh-635 Update android scripts and add ndk26 --- .github/workflows/build.yml | 101 +++++++++++------- .../development/continuous_integration.rst | 9 +- scripts/android_emu.sh | 14 ++- scripts/android_emu/emulator.sh | 70 ++++++++++++ scripts/android_emu/{run.sh => project.sh} | 23 +--- scripts/android_emu/start.sh | 39 ------- 6 files changed, 151 insertions(+), 105 deletions(-) create mode 100755 scripts/android_emu/emulator.sh rename scripts/android_emu/{run.sh => project.sh} (85%) delete mode 100755 scripts/android_emu/start.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 813033812..ab0cd1806 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -198,28 +198,38 @@ jobs: fail-fast: false matrix: include: - - image: rocstreaming/toolchain-linux-android:ndk21 - toolchain: aarch64-linux-android29 - shortname: android29-aarch64 + # newest tested NDK and API + - toolchain: aarch64-linux-android34 + ndk: ndk26 - - image: rocstreaming/toolchain-linux-android:ndk21 - toolchain: armv7a-linux-androideabi29 - shortname: android29-armv7a + - toolchain: armv7a-linux-androideabi34 + ndk: ndk26 - - image: rocstreaming/toolchain-linux-android:ndk21 - toolchain: x86_64-linux-android29 - shortname: android29-x86_64 + - toolchain: x86_64-linux-android34 + ndk: ndk26 - - image: rocstreaming/toolchain-linux-android:ndk21 - toolchain: i686-linux-android29 - shortname: android29-i686 + - toolchain: i686-linux-android34 + ndk: ndk26 + + # oldest tested NDK and API + - toolchain: aarch64-linux-android29 + ndk: ndk21 + + - toolchain: armv7a-linux-androideabi29 + ndk: ndk21 + + - toolchain: x86_64-linux-android29 + ndk: ndk21 + + - toolchain: i686-linux-android29 + ndk: ndk21 runs-on: ubuntu-latest - name: ${{ matrix.shortname }}/linux + name: android-linux-${{ matrix.ndk }}/${{ matrix.toolchain }} steps: - name: Pull docker image - run: docker pull ${{ matrix.image }} + run: docker pull rocstreaming/toolchain-linux-android:${{ matrix.ndk }} - name: Checkout uses: actions/checkout@v4 @@ -228,7 +238,7 @@ jobs: - name: Build run: | - scripts/ci_checks/docker.sh ${{ matrix.image }} \ + scripts/ci_checks/docker.sh rocstreaming/toolchain-linux-android:${{ matrix.ndk }} \ scripts/ci_checks/android/linux.sh ${{ matrix.toolchain }} - name: Handle failure @@ -241,10 +251,21 @@ jobs: fail-fast: false matrix: include: + # newest tested versions + - toolchain: aarch64-linux-android34 + abi: aarch64 + api: 34 + ndk-major: 26 + ndk: 26.3.11579264 + build_tools: 34.0.0 + cmake: 3.22.1 + + # oldest tested versions - toolchain: aarch64-linux-android29 abi: aarch64 api: 29 - ndk: 25.2.9519653 + ndk-major: 21 + ndk: 21.4.7075529 build_tools: 28.0.3 cmake: 3.10.2.4988404 @@ -256,7 +277,7 @@ jobs: API: ${{ matrix.api }} NDK_VERSION: ${{ matrix.ndk }} - name: android${{ matrix.api }}-${{ matrix.abi }}/macos + name: android-macos-ndk${{ matrix.ndk-major }}/${{ matrix.toolchain }} steps: - name: Checkout uses: actions/checkout@v4 @@ -295,9 +316,18 @@ jobs: fail-fast: false matrix: include: + # newest tested versions + - abi: x86_64 + api: 33 + ndk-major: 26 + ndk: 26.3.11579264 + cmake: 3.22.1 + + # oldset tested versions - abi: x86_64 api: 29 - ndk: 25.2.9519653 + ndk-major: 21 + ndk: 21.4.7075529 cmake: 3.10.2.4988404 runs-on: ubuntu-latest @@ -306,7 +336,7 @@ jobs: ABI: ${{ matrix.abi }} API: ${{ matrix.api }} - name: android${{ matrix.api }}-${{ matrix.abi }}/emu + name: android-emu-ndk${{ matrix.ndk-major }}/${{ matrix.abi }}-android${{ matrix.api }} steps: - name: Checkout uses: actions/checkout@v4 @@ -315,10 +345,7 @@ jobs: - 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 + scripts/android_emu/emulator.sh enable_kvm - name: Setup AVD cache uses: actions/cache@v4 @@ -343,11 +370,11 @@ jobs: - name: Install dependencies run: | - scripts/android_emu/run.sh install + scripts/android_emu/project.sh install_deps - name: Build run: | - scripts/android_emu/run.sh build + scripts/android_emu/project.sh build - name: Run tests uses: reactivecircus/android-emulator-runner@v2 @@ -358,8 +385,8 @@ jobs: cmake: ${{ matrix.cmake }} force-avd-creation: false script: | - scripts/android_emu/run.sh prep - scripts/android_emu/run.sh test + scripts/android_emu/emulator.sh create_routes + scripts/android_emu/project.sh run_tests - name: Handle failure if: failure() @@ -371,18 +398,6 @@ jobs: fail-fast: false matrix: include: - - macos-arch: x86_64 - macos-version: 11 - script: standard-build - - - macos-arch: x86_64 - macos-version: 12 - script: standard-build - - - macos-arch: x86_64 - macos-version: 13 - script: standard-build - - macos-arch: arm64 macos-version: 14 script: standard-build @@ -395,6 +410,14 @@ jobs: macos-version: 14 script: universal-binaries + - macos-arch: x86_64 + macos-version: 13 + script: standard-build + + - macos-arch: x86_64 + macos-version: 12 + script: standard-build + runs-on: macos-${{ matrix.macos-version }} name: macos${{ matrix.macos-version }}-${{ matrix.macos-arch }}/${{ matrix.script }} diff --git a/docs/sphinx/development/continuous_integration.rst b/docs/sphinx/development/continuous_integration.rst index b03d957db..bbbf5f074 100644 --- a/docs/sphinx/development/continuous_integration.rst +++ b/docs/sphinx/development/continuous_integration.rst @@ -61,11 +61,12 @@ rocstreaming/toolchain-mips-openwrt-linux-atheros:12.09 mips32 24Kc uCl Android toolchains ------------------ -========================================== =========== =================================== ============= +========================================== =========== =================================== ========= Image APIs ABIs Compilers -========================================== =========== =================================== ============= -rocstreaming/toolchain-linux-android:ndk21 21-29 armeabi-v7a, arm64-v8a, x86, x86_64 clang-9.0.8 -========================================== =========== =================================== ============= +========================================== =========== =================================== ========= +rocstreaming/toolchain-linux-android:ndk26 21-34 armeabi-v7a, arm64-v8a, x86, x86_64 clang-17 +rocstreaming/toolchain-linux-android:ndk21 21-29 armeabi-v7a, arm64-v8a, x86, x86_64 clang-9 +========================================== =========== =================================== ========= Full Android environment ------------------------ diff --git a/scripts/android_emu.sh b/scripts/android_emu.sh index 16489f28d..7bc52dddc 100755 --- a/scripts/android_emu.sh +++ b/scripts/android_emu.sh @@ -140,12 +140,18 @@ then fi # build -run_cmd docker exec roc_toolkit_android su -Ppc "scripts/android_emu/run.sh build" user +run_cmd docker exec roc_toolkit_android \ + su -Ppc "scripts/android_emu/project.sh build" user # run tests on emulator if [[ "${action}" = test ]] then - run_cmd docker exec roc_toolkit_android "scripts/android_emu/start.sh" - run_cmd docker exec roc_toolkit_android su -Ppc "scripts/android_emu/run.sh prep" user - run_cmd docker exec roc_toolkit_android su -Ppc "scripts/android_emu/run.sh test" user + run_cmd docker exec roc_toolkit_android \ + "scripts/android_emu/emulator.sh start_avd" + + run_cmd docker exec roc_toolkit_android \ + su -Ppc "scripts/android_emu/emulator.sh create_routes" user + + run_cmd docker exec roc_toolkit_android \ + su -Ppc "scripts/android_emu/project.sh run_tests" user fi diff --git a/scripts/android_emu/emulator.sh b/scripts/android_emu/emulator.sh new file mode 100755 index 000000000..7716cdd7e --- /dev/null +++ b/scripts/android_emu/emulator.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -euo pipefail + +function color_msg() { + printf '%s \033[1;35m%s\033[0m\n' "---" "$1" +} + +function run_cmd() { + echo "+++ $*" + "$@" || exit 1 +} + +export PATH="${ANDROID_SDK_ROOT}/tools/bin:${PATH}" +export PATH="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${PATH}" + +action="${1:-}" + +if [[ "${action}" == enable_kvm ]] +then + color_msg "enabling kvm" + + 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 +fi + +if [[ "${action}" == create_routes ]] +then + color_msg "creating routes" + + adb shell "ip a" | grep 'state UP' | cut -d':' -f2 | awk '{print $1}' | cut -d'@' -f1 | + while read iface + do + if ! adb shell ip route show table all | \ + grep -qF "224.0.0.0/4 dev ${iface} table local" + then + run_cmd adb shell "su 0 ip route add 224.0.0.0/4 dev ${iface} table local" + fi + done +fi + +if [[ "${action}" == start_avd ]] +then + # create avd if it doesn't exist + if ! avdmanager list avd -c | grep -qF roc_device + then + color_msg "creating avd" + run_cmd device \ + --name roc_device --image "default" --arch "${ABI}" --api "${API}" \ + create + fi + + # show avd list + color_msg "checking avd" + run_cmd avdmanager list avd + + # start emulator if it's not started + if ! adb devices | grep -qF emulator + then + color_msg "starting device" + run_cmd device --name roc_device start + fi + + # show device list + color_msg "checking device" + run_cmd adb devices +fi diff --git a/scripts/android_emu/run.sh b/scripts/android_emu/project.sh similarity index 85% rename from scripts/android_emu/run.sh rename to scripts/android_emu/project.sh index 48200fb2c..d245030fb 100755 --- a/scripts/android_emu/run.sh +++ b/scripts/android_emu/project.sh @@ -11,8 +11,6 @@ function run_cmd() { "$@" || exit 1 } -action="${1:-}" - if [ -z "${ANDROID_NDK_ROOT:-}" ] then export ANDROID_NDK_ROOT="${ANDROID_SDK_ROOT}/ndk/${NDK_VERSION}" @@ -62,7 +60,9 @@ export PATH="${ANDROID_SDK_ROOT}/tools/bin:${PATH}" export PATH="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${PATH}" export PATH="${toolchain_root}/bin:${PATH}" -if [[ "${action}" == install ]] +action="${1:-}" + +if [[ "${action}" == install_deps ]] then color_msg "installing dependencies" @@ -90,22 +90,7 @@ then --build-3rdparty=libuv,openfec,openssl,speexdsp,cpputest fi -if [[ "${action}" == prep ]] -then - color_msg "configuring routes" - - adb shell "ip a" | grep 'state UP' | cut -d':' -f2 | awk '{print $1}' | cut -d'@' -f1 | - while read iface - do - if ! adb shell ip route show table all | \ - grep -qF "224.0.0.0/4 dev ${iface} table local" - then - run_cmd adb shell "su 0 ip route add 224.0.0.0/4 dev ${iface} table local" - fi - done -fi - -if [[ "${action}" == test ]] +if [[ "${action}" == run_tests ]] then color_msg "running tests" diff --git a/scripts/android_emu/start.sh b/scripts/android_emu/start.sh deleted file mode 100755 index 3a0847835..000000000 --- a/scripts/android_emu/start.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -function color_msg() { - printf '%s \033[1;35m%s\033[0m\n' "---" "$1" -} - -function run_cmd() { - echo "+++ $*" - "$@" || exit 1 -} - -export PATH="$ANDROID_SDK_ROOT/tools/bin:${PATH}" -export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:${PATH}" - -# create avd if it doesn't exist -if ! avdmanager list avd -c | grep -qF roc_device -then - color_msg "creating avd" - run_cmd device \ - --name roc_device --image "default" --arch "${ABI}" --api "${API}" \ - create -fi - -# show avd list -color_msg "checking avd" -run_cmd avdmanager list avd - -# start emulator if it's not started -if ! adb devices | grep -qF emulator -then - color_msg "starting device" - run_cmd device --name roc_device start -fi - -# show device list -color_msg "checking device" -run_cmd adb devices