Files
chanora/tools/build-android-rust.sh
T
Edison Jwa dc9c5c0a4e feat: multi-platform bug fixes, Android audio path, and build tooling
Flutter UI fixes:
- Fix stale channel badge/speaker when moved by others (derive current
  channel from ownClientId instead of optimistic local state)
- Fix Linux PTT via focused fallback key handler
- Distinguish ServerQuery clients with terminal icon in client list
- Reduce duplicate current-channel badge display
- Prevent PTT key-bind save from permanently closing voice settings
- Fix Linux GTK reopen-after-close (quit app on window destroy)
- Fix focused PTT: consume key events, release held keys on
  disconnect/leave-channel/mode/backend changes, suppress stale errors

Flutter Rust bridge:
- Thread is_server_query flag through protocol→bridge→Dart
- Add own_client_id to BridgeSnapshot DTO
- Add log_file_path_str() for platform log path queries

Rust protocol:
- Add ServerQuery test coverage (query_client_type_maps_to_server_query_flag)
- Split reqwest TLS: native-tls for desktop/iOS, rustls for Android

Rust audio:
- Upgrade cpal 0.16→0.17.3 with API adjustments (SampleRate, description())
- Suppress Android-only dead-code warnings (open_log_file, keyring_account)

Android build tooling:
- tools/build-opus-android.sh: NDK auto-discovery, correct CMake
  Android variables (ANDROID_ABI, ANDROID_PLATFORM), portable baseline
- tools/build-android-rust.sh: build+copy Rust cdylib for arm64-v8a,
  armeabi-v7a, x86_64 into android/app/src/main/jniLibs/
- Add jniLibs/ to .gitignore

Rust bridge:
- Guard open_log_file() on non-Android (Android uses logcat)
2026-05-18 00:13:21 +09:00

76 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
REPO_ROOT="$(pwd)"
NDK_ROOT="${ANDROID_NDK_HOME:-}"
if [[ -z "$NDK_ROOT" && -n "${ANDROID_HOME:-}" ]]; then
NDK_ROOT="$(find "$ANDROID_HOME/ndk" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sort | tail -1 || true)"
fi
if [[ -z "$NDK_ROOT" && -n "${ANDROID_SDK_ROOT:-}" ]]; then
NDK_ROOT="$(find "$ANDROID_SDK_ROOT/ndk" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sort | tail -1 || true)"
fi
ANDROID_PLATFORM=28
JNI_LIBS_DIR="$REPO_ROOT/apps/chanora_flutter/android/app/src/main/jniLibs"
declare -a BUILDS=(
"arm64-v8a;aarch64-linux-android;/tmp/opus-android-arm64-v8a"
"armeabi-v7a;armv7-linux-androideabi;/tmp/opus-android-armeabi-v7a"
"x86_64;x86_64-linux-android;/tmp/opus-android-x86_64"
)
bar() { printf '%s\n' '========================================================================'; }
require_cmd() {
local cmd=$1
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "ERROR: '$cmd' is required but not on PATH." >&2
exit 1
fi
}
main() {
bar
echo "Chanora Android Rust build"
echo "Repo root : $REPO_ROOT"
echo "NDK : $NDK_ROOT"
echo "Android platform: $ANDROID_PLATFORM"
bar
require_cmd cargo
require_cmd cargo-ndk
if [[ ! -d "$NDK_ROOT" ]]; then
echo "ERROR: Android NDK not found. Set ANDROID_NDK_HOME or ANDROID_HOME." >&2
exit 1
fi
export ANDROID_NDK_HOME="$NDK_ROOT"
export LIBOPUS_STATIC=1
export LIBOPUS_NO_PKG=1
for build in "${BUILDS[@]}"; do
IFS=';' read -r abi triple opus_dir <<< "$build"
if [[ ! -f "$opus_dir/lib/libopus.a" ]]; then
echo "ERROR: missing $opus_dir/lib/libopus.a" >&2
echo "Run tools/build-opus-android.sh first." >&2
exit 1
fi
echo "Building Rust bridge for $abi ($triple)"
export LIBOPUS_LIB_DIR="$opus_dir"
cargo ndk --platform "$ANDROID_PLATFORM" -t "$abi" build --release -p chanora_bridge
mkdir -p "$JNI_LIBS_DIR/$abi"
cp "$REPO_ROOT/target/$triple/release/libchanora_bridge.so" "$JNI_LIBS_DIR/$abi/"
done
bar
echo "Android Rust libraries copied to $JNI_LIBS_DIR"
}
main "$@"