-
Notifications
You must be signed in to change notification settings - Fork 6
/
android-build-tests.bash
executable file
·47 lines (37 loc) · 1.64 KB
/
android-build-tests.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -eEuxo pipefail
if [[ "${ANDROID_API_LEVEL:-x}" == "x" ]]; then
echo "ANDROID_API_LEVEL required"
exit 127
fi
if [[ "${ANDROID_NDK_VERSION:-x}" == "x" ]]; then
echo "ANDROID_NDK_VERSION required"
exit 127
fi
if [[ "${ANDROID_ARCH:-x}" == "x" ]]; then
echo "ANDROID_ARCH required"
exit 127
else
if [[ "${ANDROID_ARCH}" == "arm64-v8a" ]]; then
export ANDROID_ARCH="aarch64"
fi
fi
if [[ "${ANDROID_SDK_ROOT:-x}" == "x" ]]; then
echo "ANDROID_SDK_ROOT required"
exit 127
fi
_ndk_root=(${ANDROID_SDK_ROOT}/ndk/${ANDROID_NDK_VERSION}/toolchains/llvm/prebuilt/*)
# This workaround may be needed if upgrading android api level
#cat << EOF > ${_ndk_root}/lib/clang/17/lib/linux/${ANDROID_ARCH}/libgcc.a
#INPUT(-lunwind)
#EOF
export PKG_CONFIG_SYSROOT_DIR="${_ndk_root}/sysroot"
export TARGET_CC="${_ndk_root}/bin/${ANDROID_ARCH}-linux-android${ANDROID_API_LEVEL}-clang"
export TARGET_CFLAGS="-I${_ndk_root}/sysroot/usr/include -I${_ndk_root}/sysroot/usr/include/${ANDROID_ARCH}-linux-android"
export TARGET_AR="${_ndk_root}/bin/llvm-ar"
export TARGET_RANLIB="${_ndk_root}/bin/llvm-ranlib"
export CGO_CFLAGS="-I${_ndk_root}/sysroot/usr/include -I${_ndk_root}/sysroot/usr/include/${ANDROID_ARCH}-linux-android"
cargo test --no-run --target ${ANDROID_ARCH}-linux-android --config target.${ANDROID_ARCH}-linux-android.linker="\"${_ndk_root}/bin/${ANDROID_ARCH}-linux-android34-clang\"" --config target.${ANDROID_ARCH}-linux-android.ar="\"${_ndk_root}/bin/llvm-ar\"" 2>&1 | tee output-cargo-test
cat output-cargo-test | grep Executable | sed -E 's/[^(]*\(([^)]*)\)/\1/' > output-test-executables
echo "BUILD TESTS:"
cat output-test-executables