-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-android.sh
More file actions
executable file
·92 lines (74 loc) · 3.07 KB
/
Copy pathbuild-android.sh
File metadata and controls
executable file
·92 lines (74 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
set -e
# ──────────────────────────────────────────────
# Bloom Jump — Android build script
# ──────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
# ── NDK / SDK environment ────────────────────
export ANDROID_HOME=/Users/amlug/Library/Android/sdk
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/30.0.14904198"
NDK_BIN="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/bin"
export CC_aarch64_linux_android="$NDK_BIN/aarch64-linux-android24-clang"
export CXX_aarch64_linux_android="$NDK_BIN/aarch64-linux-android24-clang++"
export AR_aarch64_linux_android="$NDK_BIN/llvm-ar"
LLVM_STRIP="$NDK_BIN/llvm-strip"
# ── Parse flags ──────────────────────────────
INSTALL=0
RUN=0
BUILD_TYPE="assembleDebug"
APK_PATH="android/app/build/outputs/apk/debug/app-debug.apk"
for arg in "$@"; do
case "$arg" in
--install)
INSTALL=1
;;
--run)
INSTALL=1
RUN=1
;;
--release)
BUILD_TYPE="assembleRelease"
APK_PATH="android/app/build/outputs/apk/release/app-release.apk"
;;
esac
done
# ── Paths ────────────────────────────────────
SO_OUTPUT="bloom_jump"
JNILIBS_DIR="android/app/src/main/jniLibs/arm64-v8a"
ASSETS_SRC="assets"
ASSETS_DST="android/app/src/main/assets/assets"
PACKAGE="com.bloom.jump"
ACTIVITY="com.bloomengine.jump.BloomActivity"
# ── Step 1: Compile with Perry ───────────────
echo "==> Compiling with Perry (target: android)..."
perry compile --target android src/main.ts -o bloom_jump
# ── Step 2: Strip and copy .so ───────────────
echo "==> Stripping .so..."
"$LLVM_STRIP" "$SO_OUTPUT"
echo "==> Copying .so to jniLibs..."
mkdir -p "$JNILIBS_DIR"
cp "$SO_OUTPUT" "$JNILIBS_DIR/libbloom_jump.so"
# ── Step 3: Regenerate assets (perry compile --target android truncates them) ───
echo "==> Regenerating assets..."
node tools/generate-assets.js > /dev/null 2>&1
echo "==> Syncing assets..."
mkdir -p "$ASSETS_DST"
rsync -a --delete --checksum "$ASSETS_SRC/" "$ASSETS_DST/"
# ── Step 4: Build APK ───────────────────────
echo "==> Building APK ($BUILD_TYPE)..."
cd android
./gradlew "$BUILD_TYPE"
cd ..
echo "==> APK: $APK_PATH"
# ── Step 5: Install (optional) ──────────────
if [ "$INSTALL" -eq 1 ]; then
echo "==> Installing APK on device..."
adb install -r "$APK_PATH"
fi
# ── Step 6: Launch (optional) ───────────────
if [ "$RUN" -eq 1 ]; then
echo "==> Launching $PACKAGE..."
adb shell am start -n "$PACKAGE/$ACTIVITY"
fi
echo "==> Done."