Iris: "the organization of the rust rewrite is a mess right now... there shouldn't be anything related to the app inside of iris. Iris is supposed to be the UI framework alone." And, on the crate count: "I'm confused why the app only code needs more than one crate though." Nine cargo workspaces become three, and the port's project code -- which sat in five places, four of them inside the framework -- becomes one crate, `ai-app`, in `app-rust/`: client-core -> app-rust/src/client iris/transcript-ui -> app-rust/src/ui iris/transcript-fixture -> app-rust/src/ui/fixture.rs + tests/ + touch/ iris/desktop-app -> app-rust/src/desktop + src/bin_desktop.rs iris/android-app -> app-rust/src/android + android-project/ android-shell -> app-rust/src/shell iris/ keeps core, macro, the iris crate, tabs-ui and rig-input, and now mentions no session, transcript, setup or server anywhere. Only two of the old splits had a reason that survived reading. event-model stays a crate at the repo root because server/ depends on it too, so a crate is what makes the backend and the app agree by construction. The two Android .so names looked like a hard constraint -- a package produces one library artifact -- until P2 turned out to already plan merging those two Android apps into one; both faces now come out of libai_app.so, picked apart by features so `--no-default-features --features shell` keeps wgpu, parley and iris out of the Compose app's APK. docs/RUST.md's "One app crate" has the rest, including what each remaining feature is for. DECISIONS.md and SUBAGENTS.md move into docs/ with everything else. Verified: ./run-tests.sh and `cd iris && cargo test` green, clippy and fmt clean in all five workspaces, `cargo ndk -t x86_64` links libai_app.so, build-apk.sh produces an APK that installs and launches on this checkout's emulator (Gl ... virgl, as expected), and the phone-sized headless screenshot renders the transcript unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
121 lines
5.7 KiB
Bash
Executable File
121 lines
5.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Builds the Android app end to end: the cdylib (cargo ndk from this
|
|
# directory, straight into android-project/app/src/main/jniLibs/) then the
|
|
# APK (Gradle, from android-project/). Written to stop re-typing
|
|
# the same incantation by hand every time (ANDROID_HOME/NDK exports, the
|
|
# cargo ndk invocation, the keystore env for a release build, apksigner/
|
|
# aapt2 verification) -- see docs/RUST.md's P0 box. Same shape as `app/
|
|
# build-apk.sh` (the Compose app's own build script) and `app/
|
|
# iris-scroll.sh` (no coordinates, set -eu, exit 0 on success).
|
|
#
|
|
# Usage: ./build-apk.sh [debug|release] [--abi arm64-v8a|x86_64] [--features "a b c"]
|
|
# debug/release default to debug (matches this-machine-android's "the
|
|
# emulator stays on debug" rule -- pass `release` explicitly for a phone
|
|
# build). --abi defaults to arm64-v8a (a phone/real device); pass
|
|
# x86_64 for this checkout's own AVD. --features defaults to
|
|
# "transcript-screen bench" -- deliberately *without* `force-gles`, and
|
|
# nothing should add it back for the emulator's sake.
|
|
#
|
|
# **The emulator does not need a GLES build, because it has no hardware
|
|
# Vulkan to be steered away from** (docs/RUST.md, "What the emulator
|
|
# gives a GPU app", 2026-09-08): its guest's only Vulkan is SwiftShader
|
|
# in software, its GLES is the host's real GPU through virgl, and iris's
|
|
# own runtime fallback -- `Backends::PRIMARY`, no adapter, rebuild on
|
|
# `Backends::GL` -- takes an ordinary build there by itself. So the
|
|
# emulator and the phone run the *same binary* and differ only in what
|
|
# that binary finds, which is the whole point: a build flag that changed
|
|
# the backend would mean the thing measured here is not the thing
|
|
# shipped.
|
|
#
|
|
# `force-gles` (`iris/Cargo.toml`'s own doc) pins the backend at compile
|
|
# time for a backend-isolation measurement (RUST.md's I5, "Where iris's
|
|
# frame time goes"), and the desktop is the better place to run it now
|
|
# (`run-headless.sh ... --features iris/force-gles`). It was never meant
|
|
# to reach a real device, but this script's old default put it in every
|
|
# arm64 build regardless, so the P0 bench APK delivered to Iris's phone
|
|
# forced GLES there too -- the named hypothesis in RUST.md's P0 box
|
|
# ("iris bench crash on the phone, 2026-09-06"). Never pass it for a
|
|
# build meant for a phone.
|
|
set -eu
|
|
cd "$(dirname "$0")"
|
|
|
|
BUILD_TYPE="debug"
|
|
ABI="arm64-v8a"
|
|
FEATURES="transcript-screen bench"
|
|
case "${1:-}" in
|
|
debug|release) BUILD_TYPE="$1"; shift ;;
|
|
esac
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--abi) ABI="$2"; shift 2 ;;
|
|
--features) FEATURES="$2"; shift 2 ;;
|
|
*) echo "build-apk.sh: unknown argument: $1" >&2; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
SDK_ROOT="$HOME/Android/Sdk"
|
|
export ANDROID_HOME="$SDK_ROOT"
|
|
export ANDROID_SDK_ROOT="$SDK_ROOT"
|
|
NDK_DIR=$(ls -d "$SDK_ROOT"/ndk/*/ 2>/dev/null | sort -V | tail -1)
|
|
if [ -z "$NDK_DIR" ]; then
|
|
echo "build-apk.sh: no NDK found under $SDK_ROOT/ndk" >&2
|
|
exit 1
|
|
fi
|
|
export ANDROID_NDK_HOME="$NDK_DIR"
|
|
|
|
# Only the ABI asked for goes into the APK. cargo ndk adds its output beside
|
|
# whatever earlier builds left here, and Gradle packages every directory it
|
|
# finds -- a debug x86_64 emulator build left behind made an arm64 "release"
|
|
# 339 MB on 2026-09-06.
|
|
rm -rf android-project/app/src/main/jniLibs
|
|
# ...and Gradle's own copy of them, which `rm -rf jniLibs` does not reach.
|
|
# `mergeReleaseNativeLibs` is *up to date* against its cached inputs, so a
|
|
# build that switches ABI packages the previous ABI: an `--abi x86_64`
|
|
# release APK containing `lib/arm64-v8a/libmain.so` installed fine and
|
|
# aborted at startup with `Could not get adapter!: NotFound {
|
|
# active_backends: VULKAN }` under libndk_translation -- which reads
|
|
# exactly like the phone's own Vulkan problem and is nothing of the kind.
|
|
# Scoped to the merge task's directory rather than all of `app/build`, so
|
|
# an ABI change costs the native merge and not the whole Gradle build.
|
|
rm -rf android-project/app/build/intermediates/merged_native_libs \
|
|
android-project/app/build/intermediates/stripped_native_libs \
|
|
android-project/app/build/intermediates/merged_jni_libs
|
|
echo "build-apk.sh: cargo ndk -t $ABI build ${BUILD_TYPE:+(${BUILD_TYPE})} --features \"$FEATURES\""
|
|
if [ "$BUILD_TYPE" = "release" ]; then
|
|
cargo ndk -t "$ABI" -P 29 -o android-project/app/src/main/jniLibs/ build --lib \
|
|
--profile android-release --no-default-features --features "$FEATURES"
|
|
else
|
|
cargo ndk -t "$ABI" -P 29 -o android-project/app/src/main/jniLibs/ build --lib \
|
|
--profile android-dev --no-default-features --features "$FEATURES"
|
|
fi
|
|
|
|
GRADLE_TASK="assembleDebug"
|
|
APK_DIR="android-project/app/build/outputs/apk/debug"
|
|
APK_NAME="app-debug.apk"
|
|
if [ "$BUILD_TYPE" = "release" ]; then
|
|
GRADLE_TASK="assembleRelease"
|
|
APK_DIR="android-project/app/build/outputs/apk/release"
|
|
APK_NAME="app-release.apk"
|
|
# Same key `app/build-apk.sh` (the Compose app) generates once under
|
|
# ~/.config/ai-app/release.jks -- see AGENTS.md's "Checking your work".
|
|
export AI_APP_KEYSTORE="$HOME/.config/ai-app/release.jks"
|
|
if [ ! -f "$AI_APP_KEYSTORE" ]; then
|
|
echo "build-apk.sh: no release key at $AI_APP_KEYSTORE -- run app/build-apk.sh once first" >&2
|
|
exit 1
|
|
fi
|
|
export AI_APP_KEYSTORE_PASSWORD
|
|
AI_APP_KEYSTORE_PASSWORD=$(cat "$AI_APP_KEYSTORE.password")
|
|
fi
|
|
|
|
(cd android-project && gradle ":app:$GRADLE_TASK" --console=plain)
|
|
|
|
APK_PATH="$(pwd)/$APK_DIR/$APK_NAME"
|
|
BUILD_TOOLS=$(ls -d "$SDK_ROOT"/build-tools/*/ | sort -V | tail -1)
|
|
echo "--- aapt2 dump badging ---"
|
|
"${BUILD_TOOLS}aapt2" dump badging "$APK_PATH" | head -5
|
|
if [ "$BUILD_TYPE" = "release" ]; then
|
|
echo "--- apksigner verify ---"
|
|
"${BUILD_TOOLS}apksigner" verify --print-certs "$APK_PATH"
|
|
fi
|
|
echo "$APK_PATH"
|