Skip to content

Commit

Permalink
gh-635 Update android scripts and add ndk26
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv committed Jun 17, 2024
1 parent 5fedaf4 commit a6c7355
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 105 deletions.
101 changes: 62 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
9 changes: 5 additions & 4 deletions docs/sphinx/development/continuous_integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------
Expand Down
14 changes: 10 additions & 4 deletions scripts/android_emu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
70 changes: 70 additions & 0 deletions scripts/android_emu/emulator.sh
Original file line number Diff line number Diff line change
@@ -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
23 changes: 4 additions & 19 deletions scripts/android_emu/run.sh → scripts/android_emu/project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down
39 changes: 0 additions & 39 deletions scripts/android_emu/start.sh

This file was deleted.

0 comments on commit a6c7355

Please sign in to comment.