android fixes
This commit is contained in:
1 parent
c30fddb1ef
commit
5532a7ce06
7 files changed
+101
-4
No files matched your search
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build the native library of the Flutter app (crate meow-ffi).
|
||||
#
|
||||
# scripts/build-ffi.sh linux [debug|release] [OUT_DIR] → OUT_DIR/libmeow_ffi.so
|
||||
# scripts/build-ffi.sh android [debug|release] [JNI_DIR] → JNI_DIR/<abi>/libmeow_ffi.so
|
||||
#
|
||||
# Called automatically by the Flutter builds of ../bastet (linux/CMakeLists.txt and
|
||||
# android/app/build.gradle.kts); can also be run by hand. Android needs the NDK (found
|
||||
# through ANDROID_NDK_HOME, or the newest one under $ANDROID_HOME|~/Android/Sdk/ndk) and
|
||||
# `cargo install cargo-ndk`; ABIs can be narrowed with MEOW_ANDROID_ABIS="arm64-v8a".
|
||||
set -euo pipefail
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
TARGET="${1:?usage: build-ffi.sh linux|android [debug|release] [out]}"
|
||||
PROFILE="${2:-release}"
|
||||
case "$PROFILE" in
|
||||
release) PFLAG=(--release) ;;
|
||||
debug) PFLAG=() ;;
|
||||
*) echo "profile must be debug or release" >&2; exit 2 ;;
|
||||
esac
|
||||
cd "$ROOT"
|
||||
|
||||
case "$TARGET" in
|
||||
linux)
|
||||
cargo build -p meow-ffi "${PFLAG[@]}"
|
||||
if [ -n "${3:-}" ]; then
|
||||
mkdir -p "$3"
|
||||
cp "target/$PROFILE/libmeow_ffi.so" "$3/"
|
||||
fi
|
||||
;;
|
||||
android)
|
||||
OUT="${3:-$ROOT/../bastet/android/app/src/main/jniLibs}"
|
||||
if [ -z "${ANDROID_NDK_HOME:-}" ]; then
|
||||
SDK="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Android/Sdk}}"
|
||||
NDK="$(ls -d "$SDK"/ndk/*/ 2>/dev/null | sort -V | tail -1 || true)"
|
||||
[ -n "$NDK" ] || { echo "Android NDK not found (set ANDROID_NDK_HOME)" >&2; exit 1; }
|
||||
export ANDROID_NDK_HOME="${NDK%/}"
|
||||
fi
|
||||
ABIS=(${MEOW_ANDROID_ABIS:-arm64-v8a armeabi-v7a x86_64})
|
||||
TARGS=()
|
||||
for a in "${ABIS[@]}"; do TARGS+=(-t "$a"); done
|
||||
# API 24 (Android 7) is Flutter's minimum too.
|
||||
cargo ndk "${TARGS[@]}" --platform 24 -o "$OUT" build -p meow-ffi "${PFLAG[@]}"
|
||||
;;
|
||||
*) echo "unknown target $TARGET" >&2; exit 2 ;;
|
||||
esac
|
||||
Reference in new issue
Block a user