build(android): add --device/--abi to build only the needed architecture
An on-device test build compiled all four ABIs (arm64/arm/x86/x86_64), so three of the four Rust compiles were thrown away. That dominated the build time when iterating against a connected phone. --device resolves the attached device's ABI via adb and targets just that triple; --abi <target> selects one explicitly; ABI= works as an env var. Default behaviour is unchanged (all four), since a distributable universal APK genuinely needs them. bun run android:build:device bun run android:build:release:device
This commit is contained in:
+3
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jellytau",
|
"name": "jellytau",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"packageManager": "bun@1.3.5",
|
"packageManager": "bun@1.3.5",
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
"check:boundary": "bash scripts/check-frontend-boundary.sh",
|
"check:boundary": "bash scripts/check-frontend-boundary.sh",
|
||||||
"android:build": "./scripts/build-android.sh",
|
"android:build": "./scripts/build-android.sh",
|
||||||
"android:build:release": "./scripts/build-android.sh release",
|
"android:build:release": "./scripts/build-android.sh release",
|
||||||
|
"android:build:device": "./scripts/build-android.sh --device",
|
||||||
|
"android:build:release:device": "./scripts/build-android.sh release --device",
|
||||||
"android:build:clean": "rm -rf node_modules/.vite dist .svelte-kit .next build target src-tauri/target && bun install && bun run build",
|
"android:build:clean": "rm -rf node_modules/.vite dist .svelte-kit .next build target src-tauri/target && bun install && bun run build",
|
||||||
"android:deploy": "./scripts/deploy-android.sh",
|
"android:deploy": "./scripts/deploy-android.sh",
|
||||||
"android:dev": "./scripts/build-and-deploy.sh",
|
"android:dev": "./scripts/build-and-deploy.sh",
|
||||||
|
|||||||
@@ -18,15 +18,50 @@ echo ""
|
|||||||
# Parse args: build type (debug/release) and optional --clean flag.
|
# Parse args: build type (debug/release) and optional --clean flag.
|
||||||
# By default the build is INCREMENTAL — Cargo and Vite reuse their caches.
|
# By default the build is INCREMENTAL — Cargo and Vite reuse their caches.
|
||||||
# Pass --clean (or CLEAN=1) to wipe all caches for a from-scratch build.
|
# Pass --clean (or CLEAN=1) to wipe all caches for a from-scratch build.
|
||||||
|
#
|
||||||
|
# ABI selection: by default Tauri builds all four ABIs (arm64/arm/x86/x86_64),
|
||||||
|
# which is what a distributable universal APK needs — but for an on-device test
|
||||||
|
# it means three wasted Rust compiles. Pass --device (or ABI=aarch64) to build
|
||||||
|
# only the connected device's architecture; --abi <t> targets one explicitly.
|
||||||
BUILD_TYPE="debug"
|
BUILD_TYPE="debug"
|
||||||
CLEAN="${CLEAN:-0}"
|
CLEAN="${CLEAN:-0}"
|
||||||
|
ABI="${ABI:-}"
|
||||||
|
next_is_abi=0
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
|
if [ "$next_is_abi" = "1" ]; then
|
||||||
|
ABI="$arg"
|
||||||
|
next_is_abi=0
|
||||||
|
continue
|
||||||
|
fi
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--clean) CLEAN=1 ;;
|
--clean) CLEAN=1 ;;
|
||||||
|
--abi) next_is_abi=1 ;;
|
||||||
|
--device) ABI="device" ;;
|
||||||
debug|release) BUILD_TYPE="$arg" ;;
|
debug|release) BUILD_TYPE="$arg" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Resolve --device to the attached device's Rust target triple.
|
||||||
|
if [ "$ABI" = "device" ]; then
|
||||||
|
device_abi="$(adb shell getprop ro.product.cpu.abi 2>/dev/null | tr -d '\r\n')"
|
||||||
|
case "$device_abi" in
|
||||||
|
arm64-v8a) ABI="aarch64" ;;
|
||||||
|
armeabi-v7a) ABI="armv7" ;;
|
||||||
|
x86_64) ABI="x86_64" ;;
|
||||||
|
x86) ABI="i686" ;;
|
||||||
|
*)
|
||||||
|
echo "⚠️ Could not detect device ABI (got '${device_abi:-none}') — building all targets."
|
||||||
|
ABI=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[ -n "$ABI" ] && echo "🎯 Device ABI $device_abi → building only '$ABI'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARGET_ARGS=()
|
||||||
|
if [ -n "$ABI" ]; then
|
||||||
|
TARGET_ARGS=(--target "$ABI")
|
||||||
|
fi
|
||||||
|
|
||||||
# Step 0: Optionally clear build caches for a fully fresh build.
|
# Step 0: Optionally clear build caches for a fully fresh build.
|
||||||
if [ "$CLEAN" = "1" ]; then
|
if [ "$CLEAN" = "1" ]; then
|
||||||
echo "🧹 Clearing build caches (clean build)..."
|
echo "🧹 Clearing build caches (clean build)..."
|
||||||
@@ -48,10 +83,10 @@ if [ "$BUILD_TYPE" = "release" ]; then
|
|||||||
# after sync-android-sources.sh, since gen/android is (re)generated there.
|
# after sync-android-sources.sh, since gen/android is (re)generated there.
|
||||||
./scripts/write-keystore-properties.sh
|
./scripts/write-keystore-properties.sh
|
||||||
echo "📦 Building release APK..."
|
echo "📦 Building release APK..."
|
||||||
bun run tauri android build --apk true
|
bun run tauri android build --apk true "${TARGET_ARGS[@]}"
|
||||||
else
|
else
|
||||||
echo "📦 Building debug APK..."
|
echo "📦 Building debug APK..."
|
||||||
bun run tauri android build --apk true --debug
|
bun run tauri android build --apk true --debug "${TARGET_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user