Files
iron-arc/tools/build_rust_android.sh
T

24 lines
880 B
Bash
Executable File

#!/usr/bin/env bash
# Builds the Rust CDylib for Android and places it into app jniLibs.
set -euo pipefail
cd "$(dirname "$0")/.."
export ANDROID_NDK_HOME="${ANDROID_NDK_HOME:-$HOME/Android/Sdk/ndk/28.2.13676358}"
cargo ndk --platform 24 \
-t arm64-v8a -t armeabi-v7a -t x86_64 \
-o app/android/app/src/main/jniLibs \
build --release -p ffi
for abi in arm64-v8a armeabi-v7a x86_64; do
so="app/android/app/src/main/jniLibs/$abi/libffi.so"
# 16 KB pages are mandatory for 64-bit ABIs; 32-bit ARM still uses 4 KB.
case "$abi" in
arm64-v8a|x86_64) expect=0x4000 ;;
*) expect=0x1000 ;;
esac
if readelf -lW "$so" | awk -v e="$expect" '$1=="LOAD" && $NF!=e {found=1} END{exit !found}'; then
echo "ERROR: $abi is not aligned to $expect" >&2
exit 1
fi
echo "OK: $abi aligned to $expect ($(stat -c%s "$so") bytes)"
done
echo 'OK: all ABIs 16 KB aligned'