Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

add ensu build run scripts

Prateek Sunal96764236ff89
diff --git a/mobile/native/android/apps/ensu/README.md b/mobile/native/android/apps/ensu/README.md
index 1b6f685403..e4d1ff53de 100644
--- a/mobile/native/android/apps/ensu/README.md
+++ b/mobile/native/android/apps/ensu/README.md
@@ -9,6 +9,24 @@
- Rust toolchain and `cargo-ndk` (`cargo install cargo-ndk`)
- Python 3 (used to patch llama.cpp mtmd sources)
+## Quick scripts
+
+From `mobile/native/android/apps/ensu`:
+
+```bash
+./build.sh # builds Rust + debug APK
+./build.sh release # builds Rust + release APK
+./run.sh # builds + installs + launches on connected adb device
+```
+
+Helpful flags:
+
+- `--skip-rust` to skip Rust/jni rebuild
+- `--endpoint <url>` to set `ENTE_API_ENDPOINT`
+- `--device <serial>` for `run.sh`
+
+Run `./build.sh --help` or `./run.sh --help` for full options.
+
## Building
### 1. Build Rust Libraries
diff --git a/mobile/native/android/apps/ensu/build.sh b/mobile/native/android/apps/ensu/build.sh
new file mode 100755
index 0000000000..2ef8e6feb5
--- /dev/null
+++ b/mobile/native/android/apps/ensu/build.sh
@@ -0,0 +1,89 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "$0")" && pwd)"
+RUST_BUILD_SCRIPT="$ROOT/../../packages/rust/tool/build_android.sh"
+
+MODE="debug"
+SKIP_RUST=0
+SKIP_APP=0
+ENDPOINT=""
+
+usage() {
+ cat <<'EOF'
+Build Ensu Android app.
+
+Usage:
+ ./build.sh [debug|release] [options]
+
+Options:
+ --skip-rust Skip Rust/jni build step
+ --skip-app Skip Gradle app build step
+ --endpoint <url> Set ENTE_API_ENDPOINT for this build
+ -h, --help Show help
+
+Examples:
+ ./build.sh
+ ./build.sh release
+ ./build.sh debug --endpoint https://api.example.com
+EOF
+}
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ debug|release)
+ MODE="$1"
+ shift
+ ;;
+ --skip-rust)
+ SKIP_RUST=1
+ shift
+ ;;
+ --skip-app)
+ SKIP_APP=1
+ shift
+ ;;
+ --endpoint)
+ ENDPOINT="${2:-}"
+ if [[ -z "$ENDPOINT" ]]; then
+ echo "Missing value for --endpoint" >&2
+ exit 1
+ fi
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Unknown argument: $1" >&2
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [[ -n "$ENDPOINT" ]]; then
+ export ENTE_API_ENDPOINT="$ENDPOINT"
+fi
+
+if [[ "$SKIP_RUST" -eq 0 ]]; then
+ echo "==> Building Rust Android artifacts"
+ "$RUST_BUILD_SCRIPT"
+fi
+
+if [[ "$SKIP_APP" -eq 0 ]]; then
+ cd "$ROOT"
+
+ if [[ "$MODE" == "release" ]]; then
+ TASK=":app-ui:assembleRelease"
+ APK_PATH="app-ui/build/outputs/apk/release/app-ui-release.apk"
+ else
+ TASK=":app-ui:assembleDebug"
+ APK_PATH="app-ui/build/outputs/apk/debug/app-ui-debug.apk"
+ fi
+
+ echo "==> Running Gradle task $TASK"
+ ./gradlew "$TASK"
+ echo "βœ… APK: $ROOT/$APK_PATH"
+fi
diff --git a/mobile/native/android/apps/ensu/run.sh b/mobile/native/android/apps/ensu/run.sh
new file mode 100755
index 0000000000..bedfc67774
--- /dev/null
+++ b/mobile/native/android/apps/ensu/run.sh
@@ -0,0 +1,112 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "$0")" && pwd)"
+MODE="debug"
+SERIAL=""
+SKIP_BUILD=0
+SKIP_RUST=0
+ENDPOINT=""
+
+usage() {
+ cat <<'EOF'
+Build + install + launch Ensu Android app.
+
+Usage:
+ ./run.sh [debug|release] [options]
+
+Options:
+ --device <serial> Target adb device serial
+ --skip-build Skip build step
+ --skip-rust Pass through to build step
+ --endpoint <url> Set ENTE_API_ENDPOINT for this run/build
+ -h, --help Show help
+
+Examples:
+ ./run.sh
+ ./run.sh --device emulator-5554
+ ./run.sh release --skip-rust
+EOF
+}
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ debug|release)
+ MODE="$1"
+ shift
+ ;;
+ --device)
+ SERIAL="${2:-}"
+ if [[ -z "$SERIAL" ]]; then
+ echo "Missing value for --device" >&2
+ exit 1
+ fi
+ shift 2
+ ;;
+ --skip-build)
+ SKIP_BUILD=1
+ shift
+ ;;
+ --skip-rust)
+ SKIP_RUST=1
+ shift
+ ;;
+ --endpoint)
+ ENDPOINT="${2:-}"
+ if [[ -z "$ENDPOINT" ]]; then
+ echo "Missing value for --endpoint" >&2
+ exit 1
+ fi
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Unknown argument: $1" >&2
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if ! command -v adb >/dev/null 2>&1; then
+ echo "adb not found in PATH" >&2
+ exit 1
+fi
+
+ADB_CMD=(adb)
+if [[ -n "$SERIAL" ]]; then
+ ADB_CMD+=( -s "$SERIAL" )
+fi
+
+if [[ "$SKIP_BUILD" -eq 0 ]]; then
+ BUILD_ARGS=("$MODE")
+ if [[ "$SKIP_RUST" -eq 1 ]]; then
+ BUILD_ARGS+=("--skip-rust")
+ fi
+ if [[ -n "$ENDPOINT" ]]; then
+ BUILD_ARGS+=("--endpoint" "$ENDPOINT")
+ fi
+ "$ROOT/build.sh" "${BUILD_ARGS[@]}"
+fi
+
+if [[ "$MODE" == "release" ]]; then
+ APK_PATH="$ROOT/app-ui/build/outputs/apk/release/app-ui-release.apk"
+else
+ APK_PATH="$ROOT/app-ui/build/outputs/apk/debug/app-ui-debug.apk"
+fi
+
+if [[ ! -f "$APK_PATH" ]]; then
+ echo "APK not found: $APK_PATH" >&2
+ exit 1
+fi
+
+echo "==> Installing $APK_PATH"
+"${ADB_CMD[@]}" install -r "$APK_PATH"
+
+echo "==> Launching io.ente.ensu"
+"${ADB_CMD[@]}" shell monkey -p io.ente.ensu -c android.intent.category.LAUNCHER 1 >/dev/null
+
+echo "βœ… Ensu launched on Android"
diff --git a/mobile/native/darwin/Apps/ensu/README.md b/mobile/native/darwin/Apps/ensu/README.md
index b27e9619f2..4fd761f6d4 100644
--- a/mobile/native/darwin/Apps/ensu/README.md
+++ b/mobile/native/darwin/Apps/ensu/README.md
@@ -4,6 +4,23 @@
All commands below assume you run them from `darwin/Apps/ensu`.
+## Quick scripts
+
+```bash
+./build.sh # Debug build for iOS simulator
+./build.sh device # Debug build for connected iOS device
+./build.sh archive # Release archive
+./run.sh # Build + install + launch on iOS simulator
+```
+
+Helpful flags:
+
+- `--destination-id <id>` to force a specific simulator/device
+- `--endpoint <url>` to set `ENTE_API_ENDPOINT`
+- `--skip-build` for `run.sh`
+
+Run `./build.sh --help` or `./run.sh --help` for full options.
+
## Generated bindings & dependencies
- SwiftMath is fetched via SwiftPM (`https://github.com/mgriebling/SwiftMath.git`).
diff --git a/mobile/native/darwin/Apps/ensu/build.sh b/mobile/native/darwin/Apps/ensu/build.sh
new file mode 100755
index 0000000000..9806eadf91
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/build.sh
@@ -0,0 +1,136 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "$0")" && pwd)"
+PROJECT="ensu.xcodeproj"
+SCHEME="ensu"
+DERIVED_DATA_PATH="$ROOT/build"
+
+MODE="sim"
+DESTINATION_ID=""
+ENDPOINT=""
+
+usage() {
+ cat <<'EOF'
+Build Ensu Apple app.
+
+Usage:
+ ./build.sh [sim|device|archive] [options]
+
+Modes:
+ sim Debug build for iOS simulator (default)
+ device Debug build for connected iOS device
+ archive Release archive for App Store/TestFlight flow
+
+Options:
+ --destination-id <id> Force specific destination id (sim/device)
+ --endpoint <url> Set ENTE_API_ENDPOINT for this build
+ -h, --help Show help
+
+Examples:
+ ./build.sh
+ ./build.sh sim
+ ./build.sh device
+ ./build.sh archive
+EOF
+}
+
+pick_destination_id() {
+ local platform="$1"
+ xcodebuild -project "$PROJECT" -scheme "$SCHEME" -showdestinations 2>/dev/null \
+ | sed -n "s/.*platform:${platform},.*id:\([^,}]*\).*/\1/p" \
+ | grep -v '^dvtdevice-' \
+ | head -n 1
+}
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ sim|device|archive)
+ MODE="$1"
+ shift
+ ;;
+ --destination-id)
+ DESTINATION_ID="${2:-}"
+ if [[ -z "$DESTINATION_ID" ]]; then
+ echo "Missing value for --destination-id" >&2
+ exit 1
+ fi
+ shift 2
+ ;;
+ --endpoint)
+ ENDPOINT="${2:-}"
+ if [[ -z "$ENDPOINT" ]]; then
+ echo "Missing value for --endpoint" >&2
+ exit 1
+ fi
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Unknown argument: $1" >&2
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+cd "$ROOT"
+
+if [[ -n "$ENDPOINT" ]]; then
+ export ENTE_API_ENDPOINT="$ENDPOINT"
+fi
+
+case "$MODE" in
+ sim)
+ if [[ -z "$DESTINATION_ID" ]]; then
+ DESTINATION_ID="$(pick_destination_id 'iOS Simulator')"
+ fi
+ if [[ -z "$DESTINATION_ID" ]]; then
+ echo "No iOS Simulator destination found. Open Simulator.app once and retry." >&2
+ exit 1
+ fi
+
+ echo "==> Building Debug for simulator (id=$DESTINATION_ID)"
+ xcodebuild \
+ -project "$PROJECT" \
+ -scheme "$SCHEME" \
+ -configuration Debug \
+ -sdk iphonesimulator \
+ -destination "id=$DESTINATION_ID" \
+ -derivedDataPath "$DERIVED_DATA_PATH"
+ ;;
+ device)
+ if [[ -z "$DESTINATION_ID" ]]; then
+ DESTINATION_ID="$(pick_destination_id 'iOS')"
+ fi
+ if [[ -z "$DESTINATION_ID" ]]; then
+ echo "No connected iOS device found. Connect a device or pass --destination-id." >&2
+ exit 1
+ fi
+
+ echo "==> Building Debug for device (id=$DESTINATION_ID)"
+ xcodebuild \
+ -project "$PROJECT" \
+ -scheme "$SCHEME" \
+ -configuration Debug \
+ -sdk iphoneos \
+ -destination "id=$DESTINATION_ID" \
+ -derivedDataPath "$DERIVED_DATA_PATH"
+ ;;
+ archive)
+ echo "==> Building Release archive"
+ xcodebuild \
+ -project "$PROJECT" \
+ -scheme "$SCHEME" \
+ -configuration Release \
+ -sdk iphoneos \
+ -destination 'generic/platform=iOS' \
+ -archivePath "$DERIVED_DATA_PATH/Archive/ensu.xcarchive" \
+ archive
+ ;;
+esac
+
+echo "βœ… Done"
diff --git a/mobile/native/darwin/Apps/ensu/run.sh b/mobile/native/darwin/Apps/ensu/run.sh
new file mode 100755
index 0000000000..539b3c03a1
--- /dev/null
+++ b/mobile/native/darwin/Apps/ensu/run.sh
@@ -0,0 +1,105 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "$0")" && pwd)"
+APP_BUNDLE_ID="io.ente.ensu"
+APP_PATH="$ROOT/build/Build/Products/Debug-iphonesimulator/ensu.app"
+
+DESTINATION_ID=""
+SKIP_BUILD=0
+ENDPOINT=""
+
+usage() {
+ cat <<'EOF'
+Build + install + launch Ensu on iOS Simulator.
+
+Usage:
+ ./run.sh [options]
+
+Options:
+ --destination-id <id> Use specific simulator id
+ --skip-build Skip build step
+ --endpoint <url> Set ENTE_API_ENDPOINT for build
+ -h, --help Show help
+
+Examples:
+ ./run.sh
+ ./run.sh --destination-id <SIMULATOR_UUID>
+EOF
+}
+
+pick_simulator_id() {
+ xcodebuild -project ensu.xcodeproj -scheme ensu -showdestinations 2>/dev/null \
+ | sed -n 's/.*platform:iOS Simulator,.*id:\([^,}]*\).*/\1/p' \
+ | grep -v '^dvtdevice-' \
+ | head -n 1
+}
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --destination-id)
+ DESTINATION_ID="${2:-}"
+ if [[ -z "$DESTINATION_ID" ]]; then
+ echo "Missing value for --destination-id" >&2
+ exit 1
+ fi
+ shift 2
+ ;;
+ --skip-build)
+ SKIP_BUILD=1
+ shift
+ ;;
+ --endpoint)
+ ENDPOINT="${2:-}"
+ if [[ -z "$ENDPOINT" ]]; then
+ echo "Missing value for --endpoint" >&2
+ exit 1
+ fi
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Unknown argument: $1" >&2
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+cd "$ROOT"
+
+if [[ -z "$DESTINATION_ID" ]]; then
+ DESTINATION_ID="$(pick_simulator_id)"
+fi
+if [[ -z "$DESTINATION_ID" ]]; then
+ echo "No iOS Simulator destination found. Open Simulator.app once and retry." >&2
+ exit 1
+fi
+
+if [[ "$SKIP_BUILD" -eq 0 ]]; then
+ BUILD_ARGS=(sim --destination-id "$DESTINATION_ID")
+ if [[ -n "$ENDPOINT" ]]; then
+ BUILD_ARGS+=(--endpoint "$ENDPOINT")
+ fi
+ "$ROOT/build.sh" "${BUILD_ARGS[@]}"
+fi
+
+if [[ ! -d "$APP_PATH" ]]; then
+ echo "App not found: $APP_PATH" >&2
+ echo "Run ./build.sh sim first." >&2
+ exit 1
+fi
+
+echo "==> Booting simulator $DESTINATION_ID"
+xcrun simctl boot "$DESTINATION_ID" >/dev/null 2>&1 || true
+
+echo "==> Installing app"
+xcrun simctl install "$DESTINATION_ID" "$APP_PATH"
+
+echo "==> Launching $APP_BUNDLE_ID"
+xcrun simctl launch "$DESTINATION_ID" "$APP_BUNDLE_ID"
+
+echo "βœ… Ensu launched on iOS Simulator"