gallery/scripts/build.sh
Greg Pomerantz e1982eade4 M1: metadata scan + sqlite DB + placeholder list
- scan.rs: recursive walk of Pictures/DCIM (GALLERY_SCAN_DIRS override),
  image-ext detection, mtime/size capture, no symlink-dir following
- db.rs: rusqlite(bundled) store; incremental apply (insert/update/delete)
  keyed on path with mtime/size change detection; derived columns reset on
  change; Android DB path in Android/data/<pkg>/files (EXTERNAL_DATA_DIR is
  unset in this NativeActivity setup)
- lib.rs: start_scan() background thread -> invoke_from_event_loop ->
  VecModel + status line; called from desktop and Android entry points
- main.slint: ListView of paths (M1), status line with scan stats
- main.rs: fix desktop bin for 1.18.1 (no slint::Result; ComponentHandle)
- build.sh: export NDK clang CC_/CXX_/AR_ per target (bundled sqlite)
- tests: 5k-file scan < 2s, incremental apply, roundtrip

Verified on emulator: 5002 files in 153-226 ms; relaunch 0+ 0~ 0-;
touch -> 1~, delete -> 1-.
2026-10-27 13:28:33 -04:00

49 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the gallery Android APK (and optionally install it).
#
# ./scripts/build.sh # release x86_64 (emulator) + install
# ./scripts/build.sh aarch64 # release aarch64 (real device) + install
# ./scripts/build.sh debug # debug x86_64 + install (faster builds)
# ./scripts/build.sh <arch> no-install
#
# Desktop (Linux): cargo run (needs libfontconfig1 + pkg-config)
# Desktop (macOS): cargo run (pure Rust, nothing extra)
set -euo pipefail
cd "$(dirname "$0")/.."
export ANDROID_HOME=$HOME/android-sdk
export ANDROID_NDK_ROOT=$HOME/android-sdk/ndk/27.0.12077973
export PATH="$HOME/.cargo/bin:$ANDROID_HOME/platform-tools:$PATH"
# C/C++ cross-compilers for bundled native deps (libsqlite3-sys via rusqlite).
# The `cc` crate picks these up per target triple (min sdk 26).
NDK_BIN=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin
export CC_x86_64_linux_android=$NDK_BIN/x86_64-linux-android26-clang
export CXX_x86_64_linux_android=$NDK_BIN/x86_64-linux-android26-clang++
export AR_x86_64_linux_android=$NDK_BIN/llvm-ar
export CC_aarch64_linux_android=$NDK_BIN/aarch64-linux-android26-clang
export CXX_aarch64_linux_android=$NDK_BIN/aarch64-linux-android26-clang++
export AR_aarch64_linux_android=$NDK_BIN/llvm-ar
# Debug-keystore signing is fine for personal use / Play internal testing.
export CARGO_APK_RELEASE_KEYSTORE=$HOME/.android/debug.keystore
export CARGO_APK_RELEASE_KEYSTORE_PASSWORD=android
arg1=${1:-x86_64}
arg2=${2:-install}
profile=--release
case $arg1 in
debug) target=x86_64-linux-android; profile="" ;;
x86_64) target=x86_64-linux-android ;;
aarch64) target=aarch64-linux-android ;;
*) echo "unknown arch: $arg1" >&2; exit 1 ;;
esac
cargo apk2 build $profile --target "$target" --lib
apk=$(ls target/*/apk/gallery.apk | head -1)
echo "APK: $apk ($(du -h "$apk" | cut -f1))"
if [ "$arg2" = install ] && command -v adb >/dev/null; then
adb install -r "$apk"
adb shell am start -n wow.gmp.gallery/android.app.NativeActivity || true
fi