Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ carries several Mbit/s per connection (#24).

```sh
android/build.sh # debug + release APK in Docker (ci/Dockerfile.android)
VTESSE_ANDROID_IMAGE=<image> android/build.sh # use a ready image (JDK 17, SDK/NDK/CMake, gradle, ANDROID_HOME)
adb install -r android/app/build/outputs/apk/debug/app-debug.apk
```

Expand Down
23 changes: 19 additions & 4 deletions android/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
# Output: android/app/build/outputs/apk/{debug,release}/. Gradle and its
# dependency cache live in android/.gradle-cache (not in the repository).
#
# VTESSE_ANDROID_IMAGE=<image> uses a ready Android image instead of building
# ci/Dockerfile.android. The image must provide JDK 17, the SDK/NDK/CMake of
# that Dockerfile, `gradle` on PATH, and export ANDROID_HOME (or
# ANDROID_SDK_ROOT) - the script checks the last two before building. Without
# the variable the image is built as vtesse-android.
#
# Release signing (optional; without it the release APK is unsigned):
# VTESSE_KEYSTORE=/path/to/key.jks plus VTESSE_KEYSTORE_PASSWORD, VTESSE_KEY_ALIAS,
# VTESSE_KEY_PASSWORD in the environment (CI: from repository secrets), or
Expand All @@ -29,11 +35,20 @@ if [ -n "${VTESSE_KEYSTORE:-}" ]; then
export VTESSE_KEYSTORE_PASSWORD VTESSE_KEY_ALIAS VTESSE_KEY_PASSWORD
fi

docker build -q -t vtesse-android -f "$ROOT/ci/Dockerfile.android" "$ROOT/ci" >/dev/null
IMAGE=${VTESSE_ANDROID_IMAGE:-}
ENTRY=
if [ -z "$IMAGE" ]; then
IMAGE=vtesse-android
docker build -q -t "$IMAGE" -f "$ROOT/ci/Dockerfile.android" "$ROOT/ci" >/dev/null
else
ENTRY=--entrypoint= # a ready image's own ENTRYPOINT must not swallow the commands
docker run --rm $ENTRY "$IMAGE" sh -c 'command -v gradle >/dev/null && [ -n "${ANDROID_HOME:-}${ANDROID_SDK_ROOT:-}" ]' || {
echo "$IMAGE: needs gradle on PATH and ANDROID_HOME or ANDROID_SDK_ROOT set" >&2; exit 1; }
fi
Comment thread
compot-dev marked this conversation as resolved.
mkdir -p "$HERE/.gradle-cache/home"
# shellcheck disable=SC2086 # SIGN is a list of docker options
# shellcheck disable=SC2086 # SIGN and ENTRY are lists of docker options
docker run --rm --user "$(id -u):$(id -g)" -e GRADLE_USER_HOME=/src/android/.gradle-cache \
-e HOME=/src/android/.gradle-cache/home $SIGN \
-v "$ROOT:/src" -w /src/android vtesse-android \
-e HOME=/src/android/.gradle-cache/home $SIGN $ENTRY \
-v "$ROOT:/src" -w /src/android "$IMAGE" \
gradle --no-daemon -q ${*:-assembleDebug assembleRelease}
ls -l "$HERE"/app/build/outputs/apk/*/*.apk
Loading