38 lines
1.9 KiB
Bash
Executable File
38 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
if [ "${MESHPORT_PUBLIC_CONFIG:-0}" = 1 ]; then
|
|
cp apps/meshport_lab/assets/config/default.example.toml apps/meshport_lab/assets/config/default.toml
|
|
else
|
|
sh scripts/prepare-lab-default.sh
|
|
fi
|
|
mode="${1:---release}"
|
|
case "$mode" in --debug|--release) ;; *) printf '%s\n' 'usage: build-lab-android.sh [--debug|--release]' >&2; exit 2;; esac
|
|
sdk="${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}"
|
|
ndk="$sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/bin"
|
|
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$ndk/aarch64-linux-android26-clang"
|
|
export CC_aarch64_linux_android="$CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER"
|
|
export AR_aarch64_linux_android="$ndk/llvm-ar"
|
|
export CARGO_TARGET_AARCH64_LINUX_ANDROID_RUSTFLAGS='-C link-arg=-Wl,-z,max-page-size=16384'
|
|
if [ "$mode" = --release ]; then
|
|
scripts/cargo-local.sh build -p meshport-ffi --target aarch64-linux-android --features system-vpn --release --locked
|
|
profile=release
|
|
else
|
|
scripts/cargo-local.sh build -p meshport-ffi --target aarch64-linux-android --features system-vpn --locked
|
|
profile=debug
|
|
fi
|
|
sh scripts/build-singbox-library.sh android
|
|
mkdir -p apps/meshport_lab/android/app/src/main/jniLibs/arm64-v8a
|
|
cp "target/aarch64-linux-android/$profile/libmeshport_ffi.so" apps/meshport_lab/android/app/src/main/jniLibs/arm64-v8a/
|
|
cp target/singbox/android-arm64/libmeshport_proxy.so apps/meshport_lab/android/app/src/main/jniLibs/arm64-v8a/
|
|
build_number="${MESHPORT_BUILD_NUMBER:-$(date +%s)}"
|
|
cd apps/meshport_lab
|
|
flutter build apk "$mode" --target-platform android-arm64 --build-number="$build_number"
|
|
cd ../..
|
|
mkdir -p outputs/android
|
|
prefix=MeshPort
|
|
if [ "${MESHPORT_ANDROID_STANDALONE:-0}" = 1 ]; then prefix=MeshPort-Standalone; fi
|
|
output="$PWD/outputs/android/$prefix-0.1.0-$build_number-$profile.apk"
|
|
cp "apps/meshport_lab/build/app/outputs/flutter-apk/app-$profile.apk" "$output"
|
|
printf '%s\n' "$output"
|