Inspired by HNKServer/honoka-chan-apk-server, but implemented as a JNI-based embedded runtime instead of the original approach. - Add an Android Compose controller app that starts and stops honoka-chan through JNI, shows runtime and health status, manages data directory mounting, and supports backup import/export for data.db - Add an embeddable Go server entrypoint plus JNI-exported status, health, and reload hooks so desktop and Android builds share the same startup and shutdown path - Add Android build scripts, runtime packaging, and project documentation, including generated default config.json content for honoka_runtime.zip - Add runtime bundle hash tracking so updated honoka_runtime.zip assets are automatically redeployed while preserving config.json and user data files - Add in-app service settings for unlock_all_special_rotation with immediate config persistence and automatic reload when the service is running - Split SQLite driver selection by platform, using go-sqlite3 on Android and modernc.org/sqlite elsewhere to avoid Android x86_64 seccomp crashes - Update startup, database initialization, and system health/reload handlers to support the embedded runtime and Android control flow Signed-off-by: Sean Du <do4suki@gmail.com>
62 lines
1.6 KiB
Bash
Executable File
62 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/common.sh"
|
|
|
|
require_cmd go
|
|
|
|
ABI="${1:-arm64-v8a}"
|
|
MIN_SDK="${MIN_SDK:-26}"
|
|
NDK_ROOT="${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT:-}}"
|
|
|
|
[[ -n "$NDK_ROOT" ]] || die "ANDROID_NDK_HOME is not set"
|
|
[[ -d "$NDK_ROOT" ]] || die "ANDROID_NDK_HOME does not exist: $NDK_ROOT"
|
|
|
|
HOST_TAG="${ANDROID_NDK_HOST_TAG:-linux-x86_64}"
|
|
TOOLCHAIN="$NDK_ROOT/toolchains/llvm/prebuilt/$HOST_TAG/bin"
|
|
[[ -d "$TOOLCHAIN" ]] || die "NDK toolchain not found: $TOOLCHAIN"
|
|
|
|
case "$ABI" in
|
|
arm64-v8a)
|
|
export GOOS=android
|
|
export GOARCH=arm64
|
|
export CGO_ENABLED=1
|
|
export CC="$TOOLCHAIN/aarch64-linux-android${MIN_SDK}-clang"
|
|
OUTPUT_DIR="$ANDROID_DIR/app/src/main/jniLibs/arm64-v8a"
|
|
;;
|
|
armeabi-v7a)
|
|
export GOOS=android
|
|
export GOARCH=arm
|
|
export GOARM=7
|
|
export CGO_ENABLED=1
|
|
export CC="$TOOLCHAIN/armv7a-linux-androideabi${MIN_SDK}-clang"
|
|
OUTPUT_DIR="$ANDROID_DIR/app/src/main/jniLibs/armeabi-v7a"
|
|
;;
|
|
x86_64)
|
|
export GOOS=android
|
|
export GOARCH=amd64
|
|
export CGO_ENABLED=1
|
|
export CC="$TOOLCHAIN/x86_64-linux-android${MIN_SDK}-clang"
|
|
OUTPUT_DIR="$ANDROID_DIR/app/src/main/jniLibs/x86_64"
|
|
;;
|
|
*)
|
|
die "unsupported abi: $ABI"
|
|
;;
|
|
esac
|
|
|
|
[[ -x "$CC" ]] || die "clang not found: $CC"
|
|
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
cd "$PROJECT_ROOT"
|
|
|
|
log "building Go shared library for $ABI"
|
|
go build -trimpath -buildmode=c-shared \
|
|
-ldflags="-s -w" \
|
|
-o "$OUTPUT_DIR/libhonokachan.so" \
|
|
./cmd/honoka-android
|
|
|
|
rm -f "$OUTPUT_DIR/libhonokachan.h"
|
|
|
|
log "built $OUTPUT_DIR/libhonokachan.so"
|