action: add Android build test #3
Workflow file for this run
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
name: Build test/ Android NDK r12b | |
on: | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
name: Android NDK build on Ubuntu for arm64-v8a | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: -${{ github.event.pull_request.commits }} | |
- name: Check if rebuild required | |
uses: ./.github/actions/check-rebuild | |
with: | |
mode: android | |
- if: env.rebuild == '1' | |
uses: nttld/setup-ndk@v1 | |
with: | |
ndk-version: r12b | |
link-to-sdk: true | |
## @todo Make cache works (daily update cache on main branch / restore the cache on each PR (w/o saving)) | |
- name: Prepare Build | |
if: env.rebuild == '1' | |
run: | | |
echo "::group::Install required packages" | |
sudo apt-get update | |
sudo apt-get install tar wget gzip libglib2.0-dev libjson-glib-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libunwind-dev googletest liborc-0.4-dev flex bison libopencv-dev pkg-config python3-dev python3-numpy python3 | |
echo "::endgroup::" | |
if [[ -d ~/android/gst_root_android/arm64 ]] && [[ -f ~/android/gst_root_android/arm64/lib/libgstreamer-1.0.so ]]; then | |
echo "Gst-Root-Android cached." | |
else | |
echo "::group::Download prebuilt Android-Gstreamer libraries" | |
mkdir -p ~/android/gst_root_android/arm64 | |
pushd ~/android/gst_root_android/arm64 | |
wget http://ci.nnstreamer.ai/warehouse/gstreamer-prebuilts-for-android-device/gst_root_android-custom-1.12.4-ndkr12b-20190213-0900/gstreamer-1.0-android-arm64-1.12.4-runtime.tar.bz2 | |
wget http://ci.nnstreamer.ai/warehouse/gstreamer-prebuilts-for-android-device/gst_root_android-custom-1.12.4-ndkr12b-20190213-0900/gstreamer-1.0-android-arm64-1.12.4.tar.bz2 | |
tar -xf gstreamer-1.0-android-arm64-1.12.4-runtime.tar.bz2 | |
tar -xf gstreamer-1.0-android-arm64-1.12.4.tar.bz2 | |
popd | |
echo "::endgroup::" | |
fi | |
- name: NDK Build | |
if: env.rebuild == '1' | |
run: | | |
export GSTREAMER_ROOT_ANDROID=~/android/gst_root_android | |
export TARGET_ARCH_ABI=arm64-v8a | |
export ANDROID_ABI=arm64-v8a | |
export APP_ALLOW_MISSING_DEPS=true | |
export NNSTREAMER_ROOT=$(pwd) | |
target_host=aarch64-linux-android | |
export AR=$target_host-ar | |
export AS=$target_host-clang | |
export CC=$target_host-clang | |
export CXX=$target_host-clang++ | |
export LD=$target_host-ld | |
export STRIP=$target_host-strip | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/android/gst_root_android/arm64/lib/ | |
cd jni | |
echo "::group::Run package_android.sh" | |
tools/package_android.sh | |
echo "::endgroup::" | |
echo "::group::Build NNStreamer with ndk-build" | |
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk NDK_APPLICATION_MK=./Application.mk -j$(nproc) | |
echo "::endgroup::" | |
# Workaround for the gstreamer-android prebuild binary build glitches | |
result=$(readelf -d ~/android/gst_root_android/arm64/lib/libfontconfig.so | grep "/data/nnstreamer/cerbero.custom-1.12.4-ndkr12b-20190213-0900/build/dist/android_arm64/lib") | |
if [[ ! -z $result ]]; then | |
echo "Warning: the given prebuilt binaries for Android have incorrect rpaths." | |
sudo mkdir -p /data/nnstreamer/cerbero.custom-1.12.4-ndkr12b-20190213-0900/build/dist/android_arm64/ | |
sudo ln -s ~/android/gst_root_android/arm64/lib /data/nnstreamer/cerbero.custom-1.12.4-ndkr12b-20190213-0900/build/dist/android_arm64/lib | |
fi | |
cd .. |