diff --git a/core/build-android.sh b/core/build-android.sh index 2d2885d..966ac9e 100755 --- a/core/build-android.sh +++ b/core/build-android.sh @@ -11,6 +11,12 @@ cd "$(dirname "$0")" APP="../android/app/src/main" ABIS=(arm64-v8a x86_64) +# Optional Cargo features, e.g. TETHER_FEATURES=iroh-transport for the iroh core. +# Plain string (not an array) for macOS bash 3.2 + `set -u`. +FEATURES="${TETHER_FEATURES:-}" +FEAT_ARGS="" +[ -n "$FEATURES" ] && FEAT_ARGS="--features $FEATURES" && echo "▸ features: $FEATURES" + if ! command -v cargo-ndk >/dev/null; then echo "missing cargo-ndk → cargo install cargo-ndk; also install the Android NDK and set ANDROID_NDK_HOME" >&2 exit 1 @@ -18,10 +24,12 @@ fi echo "▸ building .so for ${ABIS[*]}…" rustup target add aarch64-linux-android x86_64-linux-android >/dev/null 2>&1 || true -cargo ndk -t arm64-v8a -t x86_64 -o "$APP/jniLibs" build --release +# shellcheck disable=SC2086 # intentional word-split of FEAT_ARGS +cargo ndk -t arm64-v8a -t x86_64 -o "$APP/jniLibs" build --release $FEAT_ARGS echo "▸ generating Kotlin bindings…" -cargo build --release --lib +# shellcheck disable=SC2086 +cargo build --release --lib $FEAT_ARGS cargo run --release --bin uniffi-bindgen -- \ generate --library target/release/libtethercore.dylib \ --language kotlin --out-dir "$APP/java"