From b083076b28f5fa91e84c4f01076d5d6ba60ae3e5 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Wed, 5 Oct 2022 08:52:29 +0700 Subject: [PATCH 01/59] refactor(android): Use builder scripts --- android/KMEA/build.sh | 5 ++ android/build.sh | 185 +++++++++++++++++++++++++++++++++++------- 2 files changed, 161 insertions(+), 29 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 0bfe1b4f47..7017740c83 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -157,6 +157,11 @@ if [ "$DO_COPY" = true ]; then fi fi +# Cursory check that KMW exists +if [ ! -f "$KMEA_ASSETS/keymanandroid.js" ]; then + die "ERROR: keymanweb not built" +fi + echo "Gradle Build of KMEA" cd $KMA_ROOT/KMEA diff --git a/android/build.sh b/android/build.sh index d03c73432d..8887c0e96e 100755 --- a/android/build.sh +++ b/android/build.sh @@ -1,12 +1,8 @@ #!/usr/bin/env bash +# # Build Keyman Engine for Android, Keyman for Android, and FirstVoices Android app -# Use '-clean' flag to clean build artifacts (won't do other build steps) -# Set sensible script defaults: -# set -e: Terminate script if a command returns an error -set -e -# set -u: Terminate script if an unset variable is used -#set -u: Not set because of $RELEASE_OEM +set -eu # set -x: Debugging use, print each statement # set -x @@ -16,13 +12,77 @@ THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BA . "$(dirname "$THIS_SCRIPT")/../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + +# This script runs from its own folder +cd "$THIS_SCRIPT_PATH" + +################################ Main script ################################ + +builder_describe \ + "Build Keyman Engine for Android, Keyman for Android, and FirstVoices Android app." \ + clean \ + build \ + "publish Publishes the APKs to the Play Store." \ + ":app Keyman for Android" \ + ":engine Keyman Engine for Android" \ + ":samples Sample and Test apps" \ + ":fv OEM FirstVoices app" \ + "--ci Don't start the Gradle daemon. Use for CI" \ + "--debug,-d Local debug build; use for development builds" \ + "--download-resources Download asset .kmp files from downloads.keyman.com" \ + "--no-kmw-build,-nkmwb Don't build KMW. Just copy existing artifacts" \ + "--no-kmw,-nkmw Don't build KMW. Don't copy artifacts" \ + "--upload-sentry,-us Uploads debug symbols, etc, to Sentry" + +builder_parse "$@" + +KMEA_FLAGS="" +KMAPRO_FLAGS="" +SAMPLE_FLAGS="" +# FV will always use these +FV_FLAGS="-download-resources -lib-nobuild" + +# Build flags that only apply to KMEA +if builder_has_option --no-kmw-build; then + KMEA_FLAGS="-no-kmw-build" +elif builder_has_option --no-kmw; then + KMEA_FLAGS="-no-kmw" +fi + +# Build flags that apply to apps that include asset .kmp files +if builder_has_option --download-resources; then + KMAPRO_FLAGs="$KMAPRO_FLAGS -download-resources" +fi + +# Build flags that apply to all targets +if builder_has_option --ci; then + KMEA_FLAGS="$KMEA_FLAGS -no-daemon" + KMAPRO_FLAGS="$KMAPRO_FLAGS -no-daemon" + SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" + FV_FLAGS="$FV_FLAGS -no-daemon" +fi + +if builder_has_option --debug; then + KMEA_FLAGS="$KMEA_FLAGS -debug" + KMAPRO_FLAGS="$KMAPRO_FLAGS -debug" + SAMPLE_FLAGS="$SAMPLE_FLAGS -debug" + FV_FLAGS="$FV_FLAGS -debug" +fi + +if builder_has_option --upload-sentry; then + KMEA_FLAGS="$KMEA_FLAGS -upload-sentry" + KMAPRO_FLAGS="$KMAPRO_FLAGS -upload-sentry" + FV_FLAGS="$FV_FLAGS -upload-sentry" +fi + # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 # Clean build artifacts: keyman-engine.aar libaries, output and upload directories -clean ( ) { +function _clean() { cd "$KEYMAN_ROOT/android" find . -name "keyman-engine.aar" | while read fname; do @@ -45,41 +105,108 @@ clean ( ) { fi } -echo Build KMEA and KMAPro: +function _build_engine() { + cd "$KEYMAN_ROOT/android/KMEA" + ./build.sh $KMEA_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: KMEA/build.sh failed" + fi +} + +function _build_app() { + cd "$KEYMAN_ROOT/android/KMAPro" + ./build.sh $KMAPRO_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: KMAPro/build.sh failed" + fi +} + +function _build_samples() { + cd "$KEYMAN_ROOT/android/samples/KMSample1" + ./build.sh $SAMPLE_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: KMSample1/build.sh failed" + fi + + cd "$KEYMAN_ROOT/android/samples/KMSample2" + ./build.sh SAMPLE_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: KMSample2/build.sh failed" + fi + + cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" + ./build.sh $SAMPLE_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: KeyboardHarness/build.sh failed" + fi +} + +function _build_fv() { + pushd "$KEYMAN_ROOT/oem/firstvoices/android" + ./build.sh $FV_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: oem/firstvoices/android/build.sh failed" + fi +} # Check about cleaning artifact paths -if [[ "$1" == "-clean" ]] ; then - clean - exit +if builder_start_action clean; then + _clean + builder_finish_action success clean fi # Building Keyman Engine for Android - -cd "$KEYMAN_ROOT/android/KMEA" -./build.sh "$@" - -if [ $? -ne 0 ]; then - die "ERROR: KMEA/build.sh failed" +if builder_start_action build:engine; then + _build_engine + builder_finish_action success build:engine fi # Building Keyman for Android +if builder_start_action build:app; then + _build_app + builder_finish_action success build:app +fi -cd "$KEYMAN_ROOT/android/KMAPro" -./build.sh "$@" +# Default build action +if builder_start_action build; then + _build_engine + _build_app + builder_finish_action success build +fi -if [ $? -ne 0 ]; then - die "ERROR: KMAPro/build.sh failed" +# Building Sample apps +if builder_start_action build:samples; then + _build_samples + builder_finish_action success build:samples fi cd "$KEYMAN_ROOT/android" # Building OEM apps - -if [ ! -z "$RELEASE_OEM" ]; then - pushd "$KEYMAN_ROOT/oem/firstvoices/android" - ./build.sh -download-keyboards -lib-nobuild "$@" - - if [ $? -ne 0 ]; then - die "ERROR: oem/firstvoices/android/build.sh failed" - fi +if builder_start_action build:fv; then + _build_fv + builder_finish_action success build:fv +fi + +cd "$KEYMAN_ROOT/android" + +# Publish Keyman for Android to Play Store +if builder_start_action publish:app; then + echo "publishing Keyman for Android" + + $KEYMAN_ROOT/android/build-publish.sh -no-daemon -kmapro + builder_finish_action success publish:app +fi + +if builder_start_action publish:fv; then + echo "publishing OEM FirstVoices app" + + $KEYMAN_ROOT/android/build-publish.sh -no-daemon -fv + builder_finish_action success publish:fv fi From 619d833ccffa794b322b831cfaa436d569f05eb1 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 6 Oct 2022 07:12:33 +0700 Subject: [PATCH 02/59] chore(android): Add temporary .build-builder file for CI --- android/.build-builder | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 android/.build-builder diff --git a/android/.build-builder b/android/.build-builder new file mode 100644 index 0000000000..3769f7152b --- /dev/null +++ b/android/.build-builder @@ -0,0 +1,4 @@ +The presence of this file tells CI to use the new builder_ style parameters for build.sh + +Once all branches for 16.0+ are updated to merge #7407, then we +can remove this file and the corresponding bash test branches in CI. From ba08ababfe00015cd26bd06302f42f9bba8473a0 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 6 Oct 2022 08:45:29 +0700 Subject: [PATCH 03/59] fix(android/engine): Fix casing of Samples path --- android/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/build.sh b/android/build.sh index 8887c0e96e..c07f4db43e 100755 --- a/android/build.sh +++ b/android/build.sh @@ -124,14 +124,14 @@ function _build_app() { } function _build_samples() { - cd "$KEYMAN_ROOT/android/samples/KMSample1" + cd "$KEYMAN_ROOT/android/Samples/KMSample1" ./build.sh $SAMPLE_FLAGS if [ $? -ne 0 ]; then die "ERROR: KMSample1/build.sh failed" fi - cd "$KEYMAN_ROOT/android/samples/KMSample2" + cd "$KEYMAN_ROOT/android/Samples/KMSample2" ./build.sh SAMPLE_FLAGS if [ $? -ne 0 ]; then From b11145c3ce6d851b59bcd43cb44d3a01cb01cf72 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 6 Oct 2022 14:26:30 +0700 Subject: [PATCH 04/59] chore(android): Remove unnecessary build action --- android/build.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/android/build.sh b/android/build.sh index c07f4db43e..6130d84287 100755 --- a/android/build.sh +++ b/android/build.sh @@ -173,13 +173,6 @@ if builder_start_action build:app; then builder_finish_action success build:app fi -# Default build action -if builder_start_action build; then - _build_engine - _build_app - builder_finish_action success build -fi - # Building Sample apps if builder_start_action build:samples; then _build_samples From 62d2aff51841ecc1f8ba60ec392f13e7b4b56c04 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 20 Oct 2022 08:50:13 +0700 Subject: [PATCH 05/59] fix(android/engine): Add keyboardharness target --- android/build.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/android/build.sh b/android/build.sh index 6130d84287..1baa02e222 100755 --- a/android/build.sh +++ b/android/build.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # -# Build Keyman Engine for Android, Keyman for Android, and FirstVoices Android app +# Build Keyman Engine for Android, Keyman for Android, OEM FirstVoices Android app, +# Samples: KMsample1 and KMSample2, Test - KeyboardHarness set -eu # set -x: Debugging use, print each statement @@ -26,7 +27,8 @@ builder_describe \ "publish Publishes the APKs to the Play Store." \ ":app Keyman for Android" \ ":engine Keyman Engine for Android" \ - ":samples Sample and Test apps" \ + ":samples Sample apps: KMSample1 and KMSample2" \ + ":keyboardharness Test/KeyboardHarness app" \ ":fv OEM FirstVoices app" \ "--ci Don't start the Gradle daemon. Use for CI" \ "--debug,-d Local debug build; use for development builds" \ @@ -137,7 +139,9 @@ function _build_samples() { if [ $? -ne 0 ]; then die "ERROR: KMSample2/build.sh failed" fi +} +function _build_keyboardharness() { cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" ./build.sh $SAMPLE_FLAGS @@ -179,6 +183,12 @@ if builder_start_action build:samples; then builder_finish_action success build:samples fi +# Building KeyboardHarness app +if builder_start_action build:keyboardharness; then + _build_keyboardharness + builder_finish_action success build:keyboardharness +fi + cd "$KEYMAN_ROOT/android" # Building OEM apps From 44e791911f4802d8c721ff8702dc9292349489ff Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 20 Oct 2022 10:33:32 +0700 Subject: [PATCH 06/59] chore(android): Update README for builder script --- android/README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/android/README.md b/android/README.md index 155faefcaf..579095ed12 100644 --- a/android/README.md +++ b/android/README.md @@ -16,11 +16,11 @@ Keyman for Android uses [Sentry](https://sentry.io) for crash reporting at a ser ### Compiling From Command Line 1. Launch a command prompt and cd to the directory **keyman/android** -2. Run the top level build script `./build.sh -debug` which will: +2. Run the top level build script `./build.sh build:engine build:app --debug` which will: * Compile KMEA (and its KMW dependency) * Download default keyboard and dictionary resources as needed * Compile KMAPro - * Note: to force an update to the latest keyboard and dictionary packages, use the `-download-resources` flag. + * Note: to force an update to the latest keyboard and dictionary packages, use the `--download-resources` flag. 3. The APK will be found in **keyman/android/KMAPro/kMAPro/build/outputs/apk/debug/kMAPro-debug.apk** @@ -70,14 +70,13 @@ There are two included sample projects that can be modified to test a keyboard. **android/Samples/KMSample1** app runs a bare Keyman app for testing a keyboard. **android/Samples/KMSample2** app provides prompts for setting KMSample2 as a system level keyboard. -Both sample apps include a default Tamil keyboard. +Both sample apps include a default Tamil keyboard and sample dictionary. Building these projects follow the same steps as KMAPro: -1. Build KMEA -2. cd to the desired KMSample directory -3. `./build.sh` -4. Open Android Studio to run the app +1. cd to the desired KMSample directory +2. `./build.sh build:engine build:app` +3. Open Android Studio to run the app ### Tests: KeyboardHarness @@ -89,14 +88,14 @@ Building these projects follow the same steps as KMAPro: * Build the keyboardharness.kmp keyboard package 3. Add the keyboard in *android/Tests/KeyboardHarness/app/src/main/java/com/keyman/android/tests/keyboardHarness/MainActivity.java* 4. cd to android/Tests/KeyboardHarness/ -5. `./build.sh` +5. `./build.sh build:engine build:app` 6. Open Android Studio to run the app -------------------------------------------------------------- ## How to Build Keyman Engine for Android -1. Open a terminal or Git Bash prompt and go to Keyman Engine for Android project folder (e.g. `cd ~/keyman/android/KMEA/`) -2. Run `./build.sh` +1. Open a terminal or Git Bash prompt and go to the Android project folder (e.g. `cd ~/keyman/android/`) +2. Run `./build.sh build:engine --debug` Keyman Engine for Android library (**keyman-engine.aar**) is now ready to be imported in any project. From e7e8dc6908ba70c5d4f743c58eed501c7c37372f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 20 Oct 2022 11:05:45 +0700 Subject: [PATCH 07/59] chore(android/samples): Update builder scripts --- android/Samples/KMSample1/build.sh | 114 +++++++++++++++++------------ android/Samples/KMSample2/build.sh | 114 +++++++++++++++++------------ android/build.sh | 10 +-- 3 files changed, 143 insertions(+), 95 deletions(-) diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 9bb3300c7d..0a09396ba5 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -1,61 +1,85 @@ #!/usr/bin/env bash -# Build KMSample1 +# +# Samples: KMsample1 -set -e -set -u +set -eu +# set -x: Debugging use, print each statement +# set -x -display_usage ( ) { - echo "build.sh [-no-daemon] [-debug]" - echo - echo "Build KM Sample 1" - echo " -no-daemon Don't start the Gradle daemon. Use for CI" - echo " -debug Compile only Debug variant" - exit 1 -} +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" +## END STANDARD BUILD SCRIPT INCLUDE -echo Build KMSample1 +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + +# This script runs from its own folder +cd "$THIS_SCRIPT_PATH" + +################################ Main script ################################ + +builder_describe \ + "Build KMSample1 app for Android." \ + clean \ + build \ + ":app KMSample1" \ + "--ci Don't start the Gradle daemon. Use for CI" \ + "--debug,-d Local debug build; use for development builds" + +builder_parse "$@" + +SAMPLE_FLAGS="" + +# Build flags that apply to all targets +if builder_has_option --ci; then + SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" +fi + +if builder_has_option --debug; then + SAMPLE_FLAGS="$SAMPLE_FLAGS assembleDebug" +else + SAMPLE_FLAGS="$SAMPLE_FLAGS build" +fi # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 -NO_DAEMON=false -ONLY_DEBUG=false +# Clean build artifacts: output and upload directories +function _clean() { + cd "$KEYMAN_ROOT/android/Samples/KMSample1/" -# Parse args -while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -no-daemon) - NO_DAEMON=true - ;; - -debug) - ONLY_DEBUG=true - ;; - -h|-\?) - display_usage - ;; - esac - shift # past argument -done + if [ -d "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" ]; then + echo "Cleaning KMSample1 build outputs directory" + rm -rf "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" + fi -echo -echo "NO_DAEMON: $NO_DAEMON" -echo "ONLY_DEBUG: $ONLY_DEBUG" -echo + if [ -d "$KEYMAN_ROOT/android/upload" ]; then + echo "Cleaning upload directory" + rm -rf "$KEYMAN_ROOT/android/upload" + fi +} -if [ "$NO_DAEMON" = true ]; then - DAEMON_FLAG=--no-daemon -else - DAEMON_FLAG= +function _build_app() { + cd "$KEYMAN_ROOT/android/Samples/KMSample1" + ./gradlew clean $SAMPLE_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: KMSample1/build.sh failed" + fi +} + + +# Check about cleaning artifact paths +if builder_start_action clean; then + _clean + builder_finish_action success clean fi -if [ "$ONLY_DEBUG" = true ]; then - BUILD_FLAG=assembleDebug -else - BUILD_FLAG=build +# Building KMSample1 +if builder_start_action build:app; then + _build_app + builder_finish_action success build:app fi - -./gradlew $DAEMON_FLAG clean $BUILD_FLAG - diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index 02b7a56b25..2d2f1c77db 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -1,61 +1,85 @@ #!/usr/bin/env bash -# Build KMSample2 +# +# Samples: KMSample2 -set -e -set -u +set -eu +# set -x: Debugging use, print each statement +# set -x -display_usage ( ) { - echo "build.sh [-no-daemon] [-debug]" - echo - echo "Build KM Sample 2" - echo " -no-daemon Don't start the Gradle daemon. Use for CI" - echo " -debug Compile only Debug variant" - exit 1 -} +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" +## END STANDARD BUILD SCRIPT INCLUDE -echo Build KMSample2 +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + +# This script runs from its own folder +cd "$THIS_SCRIPT_PATH" + +################################ Main script ################################ + +builder_describe \ + "Build KMSample2 app for Android." \ + clean \ + build \ + ":app KMSample2" \ + "--ci Don't start the Gradle daemon. Use for CI" \ + "--debug,-d Local debug build; use for development builds" + +builder_parse "$@" + +SAMPLE_FLAGS="" + +# Build flags that apply to all targets +if builder_has_option --ci; then + SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" +fi + +if builder_has_option --debug; then + SAMPLE_FLAGS="$SAMPLE_FLAGS assembleDebug" +else + SAMPLE_FLAGS="$SAMPLE_FLAGS build" +fi # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 -NO_DAEMON=false -ONLY_DEBUG=false +# Clean build artifacts: output and upload directories +function _clean() { + cd "$KEYMAN_ROOT/android/Samples/KMSample2/" -# Parse args -while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -no-daemon) - NO_DAEMON=true - ;; - -debug) - ONLY_DEBUG=true - ;; - -h|-\?) - display_usage - ;; - esac - shift # past argument -done + if [ -d "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" ]; then + echo "Cleaning KMSample2 build outputs directory" + rm -rf "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" + fi -echo -echo "NO_DAEMON: $NO_DAEMON" -echo "ONLY_DEBUG: $ONLY_DEBUG" -echo + if [ -d "$KEYMAN_ROOT/android/upload" ]; then + echo "Cleaning upload directory" + rm -rf "$KEYMAN_ROOT/android/upload" + fi +} -if [ "$NO_DAEMON" = true ]; then - DAEMON_FLAG=--no-daemon -else - DAEMON_FLAG= +function _build_app() { + cd "$KEYMAN_ROOT/android/Samples/KMSample2" + ./gradlew clean $SAMPLE_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: KMSample2/build.sh failed" + fi +} + + +# Check about cleaning artifact paths +if builder_start_action clean; then + _clean + builder_finish_action success clean fi -if [ "$ONLY_DEBUG" = true ]; then - BUILD_FLAG=assembleDebug -else - BUILD_FLAG=build +# Building KMSample2 +if builder_start_action build:app; then + _build_app + builder_finish_action success build:app fi - -./gradlew $DAEMON_FLAG clean $BUILD_FLAG - diff --git a/android/build.sh b/android/build.sh index 1baa02e222..ebd07174ca 100755 --- a/android/build.sh +++ b/android/build.sh @@ -54,21 +54,21 @@ fi # Build flags that apply to apps that include asset .kmp files if builder_has_option --download-resources; then - KMAPRO_FLAGs="$KMAPRO_FLAGS -download-resources" + KMAPRO_FLAGS="$KMAPRO_FLAGS -download-resources" fi # Build flags that apply to all targets if builder_has_option --ci; then KMEA_FLAGS="$KMEA_FLAGS -no-daemon" KMAPRO_FLAGS="$KMAPRO_FLAGS -no-daemon" - SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" + SAMPLE_FLAGS="$SAMPLE_FLAGS --ci" # builder flag FV_FLAGS="$FV_FLAGS -no-daemon" fi if builder_has_option --debug; then KMEA_FLAGS="$KMEA_FLAGS -debug" KMAPRO_FLAGS="$KMAPRO_FLAGS -debug" - SAMPLE_FLAGS="$SAMPLE_FLAGS -debug" + SAMPLE_FLAGS="$SAMPLE_FLAGS --debug" # builder flag FV_FLAGS="$FV_FLAGS -debug" fi @@ -127,14 +127,14 @@ function _build_app() { function _build_samples() { cd "$KEYMAN_ROOT/android/Samples/KMSample1" - ./build.sh $SAMPLE_FLAGS + ./build.sh build:app $SAMPLE_FLAGS if [ $? -ne 0 ]; then die "ERROR: KMSample1/build.sh failed" fi cd "$KEYMAN_ROOT/android/Samples/KMSample2" - ./build.sh SAMPLE_FLAGS + ./build.sh build:app $SAMPLE_FLAGS if [ $? -ne 0 ]; then die "ERROR: KMSample2/build.sh failed" From 9535299b848b950614a882490868e9529909681f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 21 Oct 2022 09:12:04 +0700 Subject: [PATCH 08/59] chore(android): Update KeyboardHarness to use builder script --- android/Tests/KeyboardHarness/build.sh | 113 +++++++++++++++---------- android/build.sh | 19 +++-- 2 files changed, 82 insertions(+), 50 deletions(-) diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index 331c28aa07..3dbb70e062 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -1,60 +1,85 @@ #!/usr/bin/env bash -# Build KeyboardHarness test app +# +# Tests: KeyboardHarness +set -eu +# set -x: Debugging use, print each statement +# set -x -display_usage ( ) { - echo "build.sh [-no-daemon] [-debug]" - echo - echo "Build KeyboardHarness test app" - echo " -no-daemon Don't start the Gradle daemon. Use for CI" - echo " -debug Compile only Debug variant" - exit 1 -} +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" +## END STANDARD BUILD SCRIPT INCLUDE -echo Build KeyboardHarness test app +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + +# This script runs from its own folder +cd "$THIS_SCRIPT_PATH" + +################################ Main script ################################ + +builder_describe \ + "Build KeyboardHarness test app for Android." \ + clean \ + build \ + ":app KeyboardHarness" \ + "--ci Don't start the Gradle daemon. Use for CI" \ + "--debug,-d Local debug build; use for development builds" + +builder_parse "$@" + +BUILD_FLAGS="" + +# Build flags that apply to all targets +if builder_has_option --ci; then + BUILD_FLAGS="$BUILD_FLAGS -no-daemon" +fi + +if builder_has_option --debug; then + BUILD_FLAGS="$BUILD_FLAGS assembleDebug" +else + BUILD_FLAGS="$BUILD_FLAGS build" +fi # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 -NO_DAEMON=false -ONLY_DEBUG=false +# Clean build artifacts: output and upload directories +function _clean() { + cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" -# Parse args -while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -no-daemon) - NO_DAEMON=true - ;; - -debug) - ONLY_DEBUG=true - ;; - -h|-\?) - display_usage - ;; - esac - shift # past argument -done + if [ -d "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/build/outputs" ]; then + echo "Cleaning KeyboardHarness build outputs directory" + rm -rf "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/build/outputs" + fi -echo -echo "NO_DAEMON: $NO_DAEMON" -echo "ONLY_DEBUG: $ONLY_DEBUG" -echo + if [ -d "$KEYMAN_ROOT/android/upload" ]; then + echo "Cleaning upload directory" + rm -rf "$KEYMAN_ROOT/android/upload" + fi +} -if [ "$NO_DAEMON" = true ]; then - DAEMON_FLAG=--no-daemon -else - DAEMON_FLAG= +function _build_app() { + cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" + ./gradlew clean $BUILD_FLAGS + + if [ $? -ne 0 ]; then + die "ERROR: KeyboardHarness/build.sh failed" + fi +} + + +# Check about cleaning artifact paths +if builder_start_action clean; then + _clean + builder_finish_action success clean fi -if [ "$ONLY_DEBUG" = true ]; then - BUILD_FLAG=assembleDebug -else - BUILD_FLAG=build +# Building KeyboardHarness +if builder_start_action build:app; then + _build_app + builder_finish_action success build:app fi - -echo Build KeyboardHarness -./gradlew $DAEMON_FLAG clean $BUILD_FLAG - diff --git a/android/build.sh b/android/build.sh index ebd07174ca..2a67403c63 100755 --- a/android/build.sh +++ b/android/build.sh @@ -105,6 +105,15 @@ function _clean() { echo "Cleaning upload directory" rm -rf "$KEYMAN_ROOT/android/upload" fi + + cd "$KEYMAN_ROOT/android/Samples/KMSample1" + ./build.sh clean + + cd "$KEYMAN_ROOT/android/Samples/KMSample2" + ./build.sh clean + + cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" + ./build.sh clean } function _build_engine() { @@ -189,27 +198,25 @@ if builder_start_action build:keyboardharness; then builder_finish_action success build:keyboardharness fi -cd "$KEYMAN_ROOT/android" - # Building OEM apps if builder_start_action build:fv; then _build_fv builder_finish_action success build:fv fi -cd "$KEYMAN_ROOT/android" - # Publish Keyman for Android to Play Store if builder_start_action publish:app; then echo "publishing Keyman for Android" - $KEYMAN_ROOT/android/build-publish.sh -no-daemon -kmapro + cd "$KEYMAN_ROOT/android" + ./build-publish.sh -no-daemon -kmapro builder_finish_action success publish:app fi if builder_start_action publish:fv; then echo "publishing OEM FirstVoices app" - $KEYMAN_ROOT/android/build-publish.sh -no-daemon -fv + cd "$KEYMAN_ROOT/android" + ./build-publish.sh -no-daemon -fv builder_finish_action success publish:fv fi From 8bf94b3e68fd64ff8d0f17985a4e26d1930e3374 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 21 Oct 2022 11:27:35 +0700 Subject: [PATCH 09/59] fix(android): Add configure step --- android/build.sh | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/android/build.sh b/android/build.sh index 2a67403c63..1a5d4ac9f7 100755 --- a/android/build.sh +++ b/android/build.sh @@ -24,6 +24,7 @@ builder_describe \ "Build Keyman Engine for Android, Keyman for Android, and FirstVoices Android app." \ clean \ build \ + "configure Download asset .kmp files from downloads.keyman.com" \ "publish Publishes the APKs to the Play Store." \ ":app Keyman for Android" \ ":engine Keyman Engine for Android" \ @@ -32,7 +33,6 @@ builder_describe \ ":fv OEM FirstVoices app" \ "--ci Don't start the Gradle daemon. Use for CI" \ "--debug,-d Local debug build; use for development builds" \ - "--download-resources Download asset .kmp files from downloads.keyman.com" \ "--no-kmw-build,-nkmwb Don't build KMW. Just copy existing artifacts" \ "--no-kmw,-nkmw Don't build KMW. Don't copy artifacts" \ "--upload-sentry,-us Uploads debug symbols, etc, to Sentry" @@ -52,11 +52,6 @@ elif builder_has_option --no-kmw; then KMEA_FLAGS="-no-kmw" fi -# Build flags that apply to apps that include asset .kmp files -if builder_has_option --download-resources; then - KMAPRO_FLAGS="$KMAPRO_FLAGS -download-resources" -fi - # Build flags that apply to all targets if builder_has_option --ci; then KMEA_FLAGS="$KMEA_FLAGS -no-daemon" @@ -116,6 +111,30 @@ function _clean() { ./build.sh clean } +function _configure() { + . "$KEYMAN_ROOT/resources/build/build-download-resources.sh" + + # Keyman for Android .kmp dependencies + KEYBOARD_PACKAGE_ID="sil_euro_latin" + KEYBOARDS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" + MODEL_PACKAGE_ID="nrc.en.mtnt" + MODELS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${MODEL_PACKAGE_ID}.model.kmp" + + downloadKeyboardPackage "$KEYBOARD_PACKAGE_ID" "$KEYBOARDS_TARGET" + downloadModelPackage "$MODEL_PACKAGE_ID" "$MODELS_TARGET" + + # FirstVoices .csv and .kmp dependencies (dictionaries downloaded within the app) + FV_KEYBOARD_PACKAGE_ID="fv_all" + FV_KEYBOARDS_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/${FV_KEYBOARD_PACKAGE_ID}.kmp" + KEYBOARDS_CSV="$KEYMAN_ROOT/oem/firstvoices/keyboards.csv" + KEYBOARDS_CSV_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/keyboards.csv" + + echo "Copying keyboards.csv" + cp "$KEYBOARDS_CSV" "$KEYBOARDS_CSV_TARGET" + + downloadKeyboardPackage "$FV_KEYBOARD_PACKAGE_ID" "$FV_KEYBOARDS_TARGET" +} + function _build_engine() { cd "$KEYMAN_ROOT/android/KMEA" ./build.sh $KMEA_FLAGS @@ -174,6 +193,12 @@ if builder_start_action clean; then builder_finish_action success clean fi +# Download .kmp resources +if builder_start_action configure; then + _configure + builder_finish_action success configure +fi + # Building Keyman Engine for Android if builder_start_action build:engine; then _build_engine From 810c203df4e5df43f01b540f1342078434e4fe18 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 3 Feb 2023 14:15:03 +0700 Subject: [PATCH 10/59] refactor(android/engine): Start updating kmea build.sh --- android/KMEA/build.sh | 47 ++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 503d5d5b1f..36463f220c 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -2,17 +2,12 @@ # Build Keyman Engine Android using Keyman Web artifacts # # Abbreviations: -# KMA - Keyman Android -# KMEA - Keyman Engine Android +# KMA - Keyman for Android +# KMEA - Keyman Engine for Android # KMW - Keyman Web -# Set sensible script defaults: -# set -e: Terminate script if a command returns an error -set -e -# set -u: Terminate script if an unset variable is used -set -u -# set -x: Debugging use, print each statement # set -x +set -eu ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary @@ -20,6 +15,32 @@ THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BA . "$(dirname "$THIS_SCRIPT")/../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + +# This script runs from its own folder +cd "$THIS_SCRIPT_PATH" + +# ################################ Main script ################################ + +# Definition of global compile constants + + +builder_describe "Builds Keyman Engine for Android (KMEA)." \ + "@../../web/build/app/embed/$KMW_CONFIG/keyman.js" \ + "clean" \ + "confiugre" \ + "build" \ + "test Runs unit tests." \ + ":app Builds KMEA" \ + +builder_describe_outputs \ + build:app ./app/build/outputs/aar/keyman-android.aar + +builder_parse "$@" + +#### Build + + display_usage ( ) { echo "build.sh [-no-kmw-build] | [-no-kmw] [-no-daemon] | [-no-test] | [-upload-sentry] | [-debug]" echo @@ -47,16 +68,6 @@ KMA_ROOT="$KEYMAN_ROOT/android" KMW_ROOT="$KEYMAN_ROOT/web" KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} # Default is building KMW and copying artifacts DO_BUILD=true From 3455ba419ac8b9f9260209858a1e03e5b8383404 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Wed, 8 Feb 2023 13:42:16 +0700 Subject: [PATCH 11/59] chore(android/engine): Minimal update to builder script --- android/KMEA/build.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 36463f220c..c94cc82a62 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -24,11 +24,14 @@ cd "$THIS_SCRIPT_PATH" # Definition of global compile constants +DEBUG="debug" +RELEASE="release" + builder_describe "Builds Keyman Engine for Android (KMEA)." \ - "@../../web/build/app/embed/$KMW_CONFIG/keyman.js" \ + "@../../web build" \ "clean" \ - "confiugre" \ + "configure" \ "build" \ "test Runs unit tests." \ ":app Builds KMEA" \ From 1e0272c5c8d0a629e7d7e3cbf4007b123c90c473 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 9 Feb 2023 16:53:12 +0700 Subject: [PATCH 12/59] refactor(android/engine): Update builder actions --- android/KMEA/build.sh | 234 ++++++++++++++++++++++++------------------ 1 file changed, 133 insertions(+), 101 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index c94cc82a62..c0663d002e 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -33,8 +33,8 @@ builder_describe "Builds Keyman Engine for Android (KMEA)." \ "clean" \ "configure" \ "build" \ - "test Runs unit tests." \ - ":app Builds KMEA" \ + "test Runs lint and unit tests." \ + ":app Builds KMEA" builder_describe_outputs \ build:app ./app/build/outputs/aar/keyman-android.aar @@ -44,7 +44,7 @@ builder_parse "$@" #### Build -display_usage ( ) { +function display_usage () { echo "build.sh [-no-kmw-build] | [-no-kmw] [-no-daemon] | [-no-test] | [-upload-sentry] | [-debug]" echo echo "Build Keyman Engine Android (KMEA) using Keyman Web (KMW) artifacts" @@ -70,7 +70,7 @@ SHLVL=0 KMA_ROOT="$KEYMAN_ROOT/android" KMW_ROOT="$KEYMAN_ROOT/web" KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" - +ARTIFACT="app-release.aar" # Default is building KMW and copying artifacts DO_BUILD=true @@ -82,38 +82,41 @@ KMWFLAGS="build:embed" KMW_CONFIG=release # Parse args -while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -no-kmw-build) - DO_BUILD=false - DO_COPY=true - ;; - -no-kmw) - DO_BUILD=false - DO_COPY=false - ;; - -no-daemon) - NO_DAEMON=true - ;; - -upload-sentry) - # Overrides default set by build-utils.sh - UPLOAD_SENTRY=true - ;; - -debug) - DEBUG_BUILD=true - KMWFLAGS="$KMWFLAGS --debug" - KMW_CONFIG=debug - ;; - -h|-\?) - display_usage - ;; - -no-test) - DO_TEST=false - ;; - esac - shift # past argument -done + +function _skip() { + while [[ $# -gt 0 ]] ; do + key="$1" + case $key in + -no-kmw-build) + DO_BUILD=false + DO_COPY=true + ;; + -no-kmw) + DO_BUILD=false + DO_COPY=false + ;; + -no-daemon) + NO_DAEMON=true + ;; + -upload-sentry) + # Overrides default set by build-utils.sh + UPLOAD_SENTRY=true + ;; + -debug) + DEBUG_BUILD=true + KMWFLAGS="$KMWFLAGS --debug" + KMW_CONFIG=debug + ;; + -h|-\?) + display_usage + ;; + -no-test) + DO_TEST=false + ;; + esac + shift # past argument + done +} # Local development optimization - cross-target Sentry uploading when requested # by developer. As it's not CI, the Web artifacts won't exist otherwise... @@ -123,6 +126,47 @@ if [[ $VERSION_ENVIRONMENT == "local" ]] && [[ $UPLOAD_SENTRY == true ]]; then KMWFLAGS="$KMWFLAGS -upload-sentry" fi +#### Build action definitions #### + +if builder_has_option --debug; then + DEBUG_BUILD=true + KMW_CONFIG=debug + ARTIFACT="app-debug.aar" +fi + +if builder_has_option --ci; then + NO_DAEMON=true +fi + + +if builder_start_action configure; then + + # Copy KeymanWeb artifacts + echo "Copying KMW artifacts" + cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/ajax-loader.gif $KMEA_ASSETS/ajax-loader.gif + cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/keyman.js $KMEA_ASSETS/keymanandroid.js + cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/keyman.js.map $KMEA_ASSETS/keyman.js.map + cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/kmwosk.css $KMEA_ASSETS/kmwosk.css + cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/globe-hint.css $KMEA_ASSETS/globe-hint.css + cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/keymanweb-osk.ttf $KMEA_ASSETS/keymanweb-osk.ttf + + cp $KEYMAN_ROOT/common/web/sentry-manager/build/index.js $KMEA_ASSETS/keyman-sentry.js + + echo "Copying es6-shim polyfill" + cp $KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js $KMEA_ASSETS/es6-shim.min.js + + if [ $? -ne 0 ]; then + die "ERROR: copying artifacts failed" + fi + + # Cursory check that KMW exists + if [ ! -f "$KMEA_ASSETS/keymanandroid.js" ]; then + die "ERROR: keymanweb not built" + fi + + builder_finish_action success configure +fi + echo echo "DO_BUILD: $DO_BUILD" echo "DO_COPY: $DO_COPY" @@ -139,83 +183,71 @@ else DAEMON_FLAG= fi +if builder_start_action clean:app; then + if [ -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" ]; then + rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" + echo "Cleaned $ARTIFACT" + else + echo "Nothing to clean" + fi + + builder_finish_action success clean:app +fi + + # Destinations that will need the keymanweb artifacts -PLATFORM=`uname -s` -if [ "$DO_BUILD" = true ]; then - echo "Building keyman web engine" +if builder_start_action build:app; then + echo "Gradle Build of KMEA" + cd $KMA_ROOT/KMEA - "$KMW_ROOT/build.sh" $KMWFLAGS - - if [ $? -ne 0 ]; then - die "ERROR: keymanweb build failed. Exiting" + if [ "$DEBUG_BUILD" = true ]; then + BUILD_FLAGS="assembleDebug lintDebug" + TEST_FLAGS="testDebug" + ARTIFACT="app-debug.aar" + if [ "$DO_TEST" = true ]; then + # Report JUnit test results to CI + echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" fi -fi -if [ "$DO_COPY" = true ]; then - echo "Copying KMW artifacts" - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/ajax-loader.gif $KMEA_ASSETS/ajax-loader.gif - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/keyman.js $KMEA_ASSETS/keymanandroid.js - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/keyman.js.map $KMEA_ASSETS/keyman.js.map - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/kmwosk.css $KMEA_ASSETS/kmwosk.css - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/globe-hint.css $KMEA_ASSETS/globe-hint.css - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/keymanweb-osk.ttf $KMEA_ASSETS/keymanweb-osk.ttf - - cp $KEYMAN_ROOT/common/web/sentry-manager/build/index.js $KMEA_ASSETS/keyman-sentry.js - - echo "Copying es6-shim polyfill" - cp $KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js $KMEA_ASSETS/es6-shim.min.js - - if [ $? -ne 0 ]; then - die "ERROR: copying artifacts failed" + else + BUILD_FLAGS="aR lint" + TEST_FLAGS="testRelease" + ARTIFACT="app-release.aar" + if [ "$DO_TEST" = true ]; then + # Report JUnit test results to CI + echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" fi -fi - -# Cursory check that KMW exists -if [ ! -f "$KMEA_ASSETS/keymanandroid.js" ]; then - die "ERROR: keymanweb not built" -fi - -echo "Gradle Build of KMEA" -cd $KMA_ROOT/KMEA - -if [ "$DEBUG_BUILD" = true ]; then - BUILD_FLAGS="assembleDebug lintDebug" - TEST_FLAGS="testDebug" - ARTIFACT="app-debug.aar" - if [ "$DO_TEST" = true ]; then - # Report JUnit test results to CI - echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" fi -else - BUILD_FLAGS="aR lint" - TEST_FLAGS="testRelease" - ARTIFACT="app-release.aar" - if [ "$DO_TEST" = true ]; then - # Report JUnit test results to CI - echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" - fi -fi -echo "BUILD_FLAGS $BUILD_FLAGS" -./gradlew $DAEMON_FLAG clean $BUILD_FLAGS -if [ $? -ne 0 ]; then + echo "BUILD_FLAGS $BUILD_FLAGS" + ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS + if [ $? -ne 0 ]; then die "ERROR: Build of KMEA failed" -fi -if [ "$DO_TEST" = true ]; then + fi + + if [ "$DO_TEST" = true ]; then echo "TEST_FLAGS $TEST_FLAGS" ./gradlew $DAEMON_FLAG $TEST_FLAGS if [ $? -ne 0 ]; then - die "ERROR: KMEA test cases failed" + die "ERROR: KMEA test cases failed" fi + fi + + builder_finish_action success build:app fi -echo "Copying Keyman Engine for Android to KMAPro, Sample apps, and Tests" -mv $KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar -cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample1/app/libs/keyman-engine.aar -cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample2/app/libs/keyman-engine.aar -cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Tests/KeyboardHarness/app/libs/keyman-engine.aar -if [ ! -z ${RELEASE_OEM+x} ]; then - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/../oem/firstvoices/android/app/libs/keyman-engine.aar -fi -cd ..\ +function _copy_artifacts() { + echo "Copying Keyman Engine for Android to KMAPro, Sample apps, and Tests" + mv $KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar + cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample1/app/libs/keyman-engine.aar + cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample2/app/libs/keyman-engine.aar + cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Tests/KeyboardHarness/app/libs/keyman-engine.aar + if [ ! -z ${RELEASE_OEM+x} ]; then + cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/../oem/firstvoices/android/app/libs/keyman-engine.aar + fi + cd ..\ +} + +# why do we need this extra brace? +} From 4a78fd18eadb3003e0f5d1e08b2fb10ee4884774 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 10 Feb 2023 08:06:15 +0700 Subject: [PATCH 13/59] refactor(android/engine): Split out build and test action --- android/KMEA/build.sh | 124 ++++++++++++------------------------------ 1 file changed, 36 insertions(+), 88 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index c0663d002e..1249207806 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -6,7 +6,7 @@ # KMEA - Keyman Engine for Android # KMW - Keyman Web -# set -x +#set -x set -eu ## START STANDARD BUILD SCRIPT INCLUDE @@ -44,19 +44,6 @@ builder_parse "$@" #### Build -function display_usage () { - echo "build.sh [-no-kmw-build] | [-no-kmw] [-no-daemon] | [-no-test] | [-upload-sentry] | [-debug]" - echo - echo "Build Keyman Engine Android (KMEA) using Keyman Web (KMW) artifacts" - echo " -no-kmw-build Don't build KMW. Just copy existing artifacts" - echo " -no-kmw Don't build KMW. Don't copy artifacts" - echo " -no-daemon Don't start the Gradle daemon. Use for CI" - echo " -no-test Don't run the unit-test suite. Use for development builds" - echo " to facilitate manual debugging and testing" - echo " -upload-sentry Uploads debug symbols, etc, to Sentry" - echo " -debug Local debug build; use for development builds" - exit 1 -} echo Build KMEA @@ -72,51 +59,12 @@ KMW_ROOT="$KEYMAN_ROOT/web" KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" ARTIFACT="app-release.aar" -# Default is building KMW and copying artifacts -DO_BUILD=true -DO_COPY=true -DO_TEST=true -NO_DAEMON=false DEBUG_BUILD=false -KMWFLAGS="build:embed" +#KMWFLAGS="build:embed" KMW_CONFIG=release # Parse args -function _skip() { - while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -no-kmw-build) - DO_BUILD=false - DO_COPY=true - ;; - -no-kmw) - DO_BUILD=false - DO_COPY=false - ;; - -no-daemon) - NO_DAEMON=true - ;; - -upload-sentry) - # Overrides default set by build-utils.sh - UPLOAD_SENTRY=true - ;; - -debug) - DEBUG_BUILD=true - KMWFLAGS="$KMWFLAGS --debug" - KMW_CONFIG=debug - ;; - -h|-\?) - display_usage - ;; - -no-test) - DO_TEST=false - ;; - esac - shift # past argument - done -} # Local development optimization - cross-target Sentry uploading when requested # by developer. As it's not CI, the Web artifacts won't exist otherwise... @@ -130,12 +78,12 @@ fi if builder_has_option --debug; then DEBUG_BUILD=true - KMW_CONFIG=debug ARTIFACT="app-debug.aar" fi +DAEMON_FLAG= if builder_has_option --ci; then - NO_DAEMON=true + DAEMON_FLAG=--no-daemon fi @@ -168,21 +116,9 @@ if builder_start_action configure; then fi echo -echo "DO_BUILD: $DO_BUILD" -echo "DO_COPY: $DO_COPY" -echo "DO_TEST: $DO_TEST" -echo "NO_DAEMON: $NO_DAEMON" echo "DEBUG_BUILD: $DEBUG_BUILD" -echo "KMWFLAGS: $KMWFLAGS" -echo "KMW_CONFIG: $KMW_CONFIG" echo -if [ "$NO_DAEMON" = true ]; then - DAEMON_FLAG=--no-daemon -else - DAEMON_FLAG= -fi - if builder_start_action clean:app; then if [ -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" ]; then rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" @@ -203,38 +139,50 @@ if builder_start_action build:app; then cd $KMA_ROOT/KMEA if [ "$DEBUG_BUILD" = true ]; then - BUILD_FLAGS="assembleDebug lintDebug" - TEST_FLAGS="testDebug" + BUILD_FLAGS="assembleDebug -x lintDebug -x test" ARTIFACT="app-debug.aar" - if [ "$DO_TEST" = true ]; then - # Report JUnit test results to CI - echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" - fi else - BUILD_FLAGS="aR lint" - TEST_FLAGS="testRelease" + BUILD_FLAGS="aR -x lint -x test" ARTIFACT="app-release.aar" - if [ "$DO_TEST" = true ]; then - # Report JUnit test results to CI - echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" - fi fi echo "BUILD_FLAGS $BUILD_FLAGS" + # Build without test ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS if [ $? -ne 0 ]; then die "ERROR: Build of KMEA failed" fi - if [ "$DO_TEST" = true ]; then - echo "TEST_FLAGS $TEST_FLAGS" - ./gradlew $DAEMON_FLAG $TEST_FLAGS - if [ $? -ne 0 ]; then - die "ERROR: KMEA test cases failed" + builder_finish_action success build:app +fi + +if builder_start_action test:app; then + echo "Gradle test of KMEA" + cd $KMA_ROOT/KMEA + + if [ "$DEBUG_BUILD" = true ]; then + TEST_FLAGS="-x assembleDebug lintDebug testDebug" + ARTIFACT="app-debug.aar" + if builder_has_option --ci; then + # Report JUnit test results to CI + echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" + fi + else + TEST_FLAGS="-x aR lint testRelease" + ARTIFACT="app-release.aar" + if builder_has_option --ci; then + # Report JUnit test results to CI + echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" fi fi - builder_finish_action success build:app + echo "TEST_FLAGS $TEST_FLAGS" + ./gradlew $DAEMON_FLAG $TEST_FLAGS + if [ $? -ne 0 ]; then + die "ERROR: KMEA test cases failed" + fi + + builder_finish_action success test:app fi function _copy_artifacts() { @@ -249,5 +197,5 @@ function _copy_artifacts() { cd ..\ } -# why do we need this extra brace? -} +# TODO: why do we need this extra brace? +} \ No newline at end of file From 18e2a213e5c9f63efd8c33f7f5d4ed2e21af91ea Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 10 Feb 2023 13:26:20 +0700 Subject: [PATCH 14/59] fix(android/engine): Fix builder dependency --- android/KMEA/build.sh | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 1249207806..98571f3566 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -24,12 +24,20 @@ cd "$THIS_SCRIPT_PATH" # Definition of global compile constants +KMA_ROOT="$KEYMAN_ROOT/android" +KMW_ROOT="$KEYMAN_ROOT/web" +KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" +ARTIFACT="app-release.aar" + +DEBUG_BUILD=false +KMW_CONFIG=release + DEBUG="debug" RELEASE="release" builder_describe "Builds Keyman Engine for Android (KMEA)." \ - "@../../web build" \ + "@../../web configure" \ "clean" \ "configure" \ "build" \ @@ -44,24 +52,12 @@ builder_parse "$@" #### Build - -echo Build KMEA - # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 -# Path definitions -KMA_ROOT="$KEYMAN_ROOT/android" -KMW_ROOT="$KEYMAN_ROOT/web" -KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" -ARTIFACT="app-release.aar" - -DEBUG_BUILD=false -#KMWFLAGS="build:embed" -KMW_CONFIG=release # Parse args @@ -78,6 +74,7 @@ fi if builder_has_option --debug; then DEBUG_BUILD=true + KMW_CONFIG=debug ARTIFACT="app-debug.aar" fi @@ -160,6 +157,7 @@ if builder_start_action test:app; then echo "Gradle test of KMEA" cd $KMA_ROOT/KMEA + # Gradle flags to test w/o building if [ "$DEBUG_BUILD" = true ]; then TEST_FLAGS="-x assembleDebug lintDebug testDebug" ARTIFACT="app-debug.aar" From 244962bf09d21e60b18f21690d7a3876d1b26da0 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Fri, 10 Feb 2023 13:46:59 +0700 Subject: [PATCH 15/59] chore(web): fixup dependencies in web build scripts @jahorton may wish to review: * Additional module outputs * Fixup engine paths --- web/build.sh | 9 +++++---- web/src/engine/build.sh | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/build.sh b/web/build.sh index 608837e11c..9f81a1f1e8 100755 --- a/web/build.sh +++ b/web/build.sh @@ -116,10 +116,11 @@ builder_describe_outputs \ configure:samples ../node_modules \ configure:tools ../node_modules \ build:embed $(output_path $EMBEDDED $RELEASE)/keyman.js \ + build:engine build/engine/main/obj/keymanweb.js \ build:web $(output_path $WEB $RELEASE)/keymanweb.js \ build:ui $(output_path $UI $RELEASE)/kmwuibutton.js \ - build:samples $PREDICTIVE_TEXT_OUTPUT -# Deliberately excluding build:tools b/c its script provides the definitions. + build:samples $PREDICTIVE_TEXT_OUTPUT \ + build:tools build/tools/building/sourcemap-root/index.js builder_parse "$@" @@ -352,13 +353,13 @@ copy_outputs ( ) { # ``` compile ( ) { if [ $# -lt 1 ]; then - fail "Scripting error: insufficient argument count!" + builder_die "Scripting error: insufficient argument count!" fi local COMPILE_TARGET=$1 local COMPILED_INTERMEDIATE_PATH="$(output_path $COMPILE_TARGET $INTERMEDIATE)" - $compilecmd -b src/$COMPILE_TARGET -v + $compilecmd -b src/$COMPILE_TARGET -v || builder_die "Build command $compilecmd -b src/$COMIPILE_TARGET -v failed with exit code $?" echo $COMPILE_TARGET TypeScript compiled under $COMPILED_INTERMEDIATE_PATH } diff --git a/web/src/engine/build.sh b/web/src/engine/build.sh index 16316c8983..31389b9194 100755 --- a/web/src/engine/build.sh +++ b/web/src/engine/build.sh @@ -97,10 +97,9 @@ builder_describe "Builds engine modules for Keyman Engine for Web (KMW)." \ # "upload-symbols Uploads build product to Sentry for error report symbolification. Only defined for $DOC_BUILD_EMBED_WEB" \ builder_describe_outputs \ - configure ../node_modules \ - configure:device-detect ../node_modules \ - configure:element-wrappers ../node_modules \ - configure:main ../node_modules \ + configure:device-detect ../../../node_modules \ + configure:element-wrappers ../../../node_modules \ + configure:main ../../../node_modules \ build:device-detect $(output_path $DEVICEDETECT $OUTPUT_DIR)/index.js \ build:element-wrappers $(output_path $ELEMENTWRAPPERS $OUTPUT_DIR)/index.js \ build:main $(output_path $MAIN $OUTPUT_DIR)/keymanweb.js From baa443de2cf42f4e1986b0724dbeed1f0a9e4410 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Fri, 10 Feb 2023 18:24:10 +1100 Subject: [PATCH 16/59] Update web/build.sh Co-authored-by: Joshua Horton --- web/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/build.sh b/web/build.sh index 9f81a1f1e8..1acd35aad6 100755 --- a/web/build.sh +++ b/web/build.sh @@ -359,7 +359,7 @@ compile ( ) { local COMPILE_TARGET=$1 local COMPILED_INTERMEDIATE_PATH="$(output_path $COMPILE_TARGET $INTERMEDIATE)" - $compilecmd -b src/$COMPILE_TARGET -v || builder_die "Build command $compilecmd -b src/$COMIPILE_TARGET -v failed with exit code $?" + $compilecmd -b src/$COMPILE_TARGET -v || builder_die "Build command $compilecmd -b src/$COMPILE_TARGET -v failed with exit code $?" echo $COMPILE_TARGET TypeScript compiled under $COMPILED_INTERMEDIATE_PATH } From 4830e3d9d71ce7afdc74a4b93fdd5034c98a8b21 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 16 Feb 2023 12:54:03 +0700 Subject: [PATCH 17/59] fix(android/engine): Use :engine instead of :app target --- android/KMEA/build.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 98571f3566..5ec6bb221d 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -29,7 +29,6 @@ KMW_ROOT="$KEYMAN_ROOT/web" KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" ARTIFACT="app-release.aar" -DEBUG_BUILD=false KMW_CONFIG=release DEBUG="debug" @@ -42,10 +41,10 @@ builder_describe "Builds Keyman Engine for Android (KMEA)." \ "configure" \ "build" \ "test Runs lint and unit tests." \ - ":app Builds KMEA" + ":engine Builds KMEA" builder_describe_outputs \ - build:app ./app/build/outputs/aar/keyman-android.aar + build:engine ./app/build/outputs/aar/keyman-android.aar builder_parse "$@" @@ -73,7 +72,6 @@ fi #### Build action definitions #### if builder_has_option --debug; then - DEBUG_BUILD=true KMW_CONFIG=debug ARTIFACT="app-debug.aar" fi @@ -112,11 +110,7 @@ if builder_start_action configure; then builder_finish_action success configure fi -echo -echo "DEBUG_BUILD: $DEBUG_BUILD" -echo - -if builder_start_action clean:app; then +if builder_start_action clean:engine; then if [ -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" ]; then rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" echo "Cleaned $ARTIFACT" @@ -124,18 +118,18 @@ if builder_start_action clean:app; then echo "Nothing to clean" fi - builder_finish_action success clean:app + builder_finish_action success clean:engine fi # Destinations that will need the keymanweb artifacts -if builder_start_action build:app; then +if builder_start_action build:engine; then echo "Gradle Build of KMEA" cd $KMA_ROOT/KMEA - if [ "$DEBUG_BUILD" = true ]; then + if builder_has_option --debug; then BUILD_FLAGS="assembleDebug -x lintDebug -x test" ARTIFACT="app-debug.aar" else @@ -150,17 +144,18 @@ if builder_start_action build:app; then die "ERROR: Build of KMEA failed" fi - builder_finish_action success build:app + builder_finish_action success build:engine fi -if builder_start_action test:app; then +if builder_start_action test:engine; then echo "Gradle test of KMEA" cd $KMA_ROOT/KMEA # Gradle flags to test w/o building - if [ "$DEBUG_BUILD" = true ]; then + if builder_has_option --debug; then TEST_FLAGS="-x assembleDebug lintDebug testDebug" ARTIFACT="app-debug.aar" + echo "Building debug" if builder_has_option --ci; then # Report JUnit test results to CI echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" @@ -168,6 +163,7 @@ if builder_start_action test:app; then else TEST_FLAGS="-x aR lint testRelease" ARTIFACT="app-release.aar" + echo "Building release" if builder_has_option --ci; then # Report JUnit test results to CI echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" @@ -180,7 +176,7 @@ if builder_start_action test:app; then die "ERROR: KMEA test cases failed" fi - builder_finish_action success test:app + builder_finish_action success test:engine fi function _copy_artifacts() { From f075ebe3aa5d0387e1f2c1ffab324c573c357b94 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 10:32:38 +0700 Subject: [PATCH 18/59] refactor(android/engine): Fix --debug options --- android/KMEA/build.sh | 94 +++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 57 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index bb6eaae729..8c050051d4 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -27,14 +27,15 @@ cd "$THIS_SCRIPT_PATH" KMA_ROOT="$KEYMAN_ROOT/android" KMW_ROOT="$KEYMAN_ROOT/web" KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" -ARTIFACT="app-release.aar" - KMW_CONFIG=release +BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test +TEST_FLAGS="-x aR lint testRelease" # Gradle test w/o build +JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" +ARTIFACT="app-release.aar" DEBUG="debug" RELEASE="release" - builder_describe "Builds Keyman Engine for Android (KMEA)." \ "@../../web configure" \ "clean" \ @@ -43,13 +44,33 @@ builder_describe "Builds Keyman Engine for Android (KMEA)." \ "test Runs lint and unit tests." \ ":engine Builds KMEA" -builder_describe_outputs \ - build:engine ./app/build/outputs/aar/keyman-android.aar - +# parse before describe_outputs to check debug flags builder_parse "$@" +if builder_has_option --debug; then + builder_heading "### Debug config ####" + KMW_CONFIG="$DEBUG" + BUILD_FLAGS="assembleDebug -x lintDebug -x test" + TEST_FLAGS="-x assembleDebug lintDebug testDebug" + JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" + ARTIFACT="app-debug.aar" +fi + +builder_describe_outputs \ + build:engine ./app/build/outputs/aar/${ARTIFACT} + #### Build +function _copy_artifacts() { + echo "Copying Keyman Engine for Android to KMAPro, Sample apps, and Tests" + mv $KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar + cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample1/app/libs/keyman-engine.aar + cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample2/app/libs/keyman-engine.aar + cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Tests/KeyboardHarness/app/libs/keyman-engine.aar + if [ ! -z ${RELEASE_OEM+x} ]; then + cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/../oem/firstvoices/android/app/libs/keyman-engine.aar + fi +} # # Prevents 'clear' on exit of mingw64 bash shell @@ -68,18 +89,12 @@ if [[ $VERSION_ENVIRONMENT == "local" ]] && [[ $UPLOAD_SENTRY == true ]]; then KMWFLAGS="$KMWFLAGS -upload-sentry" fi -#### Build action definitions #### - -if builder_has_option --debug; then - KMW_CONFIG=debug - ARTIFACT="app-debug.aar" -fi - DAEMON_FLAG= if builder_has_option --ci; then DAEMON_FLAG=--no-daemon fi +#### Build action definitions #### if builder_start_action configure; then @@ -128,21 +143,16 @@ if builder_start_action build:engine; then echo "Gradle Build of KMEA" cd $KMA_ROOT/KMEA - if builder_has_option --debug; then - BUILD_FLAGS="assembleDebug -x lintDebug -x test" - ARTIFACT="app-debug.aar" - else - BUILD_FLAGS="aR -x lint -x test" - ARTIFACT="app-release.aar" - fi - echo "BUILD_FLAGS $BUILD_FLAGS" # Build without test ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS if [ $? -ne 0 ]; then - die "ERROR: Build of KMEA failed" + builder_die "ERROR: Build of KMEA failed" fi + # TODO: remove _copy_artifacts() when all the Android projects have builder + _copy_artifacts + builder_finish_action success build:engine fi @@ -150,46 +160,16 @@ if builder_start_action test:engine; then echo "Gradle test of KMEA" cd $KMA_ROOT/KMEA - # Gradle flags to test w/o building - if builder_has_option --debug; then - TEST_FLAGS="-x assembleDebug lintDebug testDebug" - ARTIFACT="app-debug.aar" - echo "Building debug" - if builder_has_option --ci; then - # Report JUnit test results to CI - echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" - fi - else - TEST_FLAGS="-x aR lint testRelease" - ARTIFACT="app-release.aar" - echo "Building release" - if builder_has_option --ci; then - # Report JUnit test results to CI - echo "##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" - fi + if builder_has_option --ci; then + # Report JUnit test results to CI + echo "$JUNIT_RESULTS" fi - die "ERROR: Build of KMEA failed" - echo "TEST_FLAGS $TEST_FLAGS" + echo "TEST_FLAGS: $TEST_FLAGS" ./gradlew $DAEMON_FLAG $TEST_FLAGS if [ $? -ne 0 ]; then - builder_die "ERROR: KMEA test cases failed" + builder_die "ERROR: KMEA test cases failed" fi builder_finish_action success test:engine fi - -function _copy_artifacts() { - echo "Copying Keyman Engine for Android to KMAPro, Sample apps, and Tests" - mv $KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample1/app/libs/keyman-engine.aar - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample2/app/libs/keyman-engine.aar - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Tests/KeyboardHarness/app/libs/keyman-engine.aar - if [ ! -z ${RELEASE_OEM+x} ]; then - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/../oem/firstvoices/android/app/libs/keyman-engine.aar - fi - cd ..\ -} - -# TODO: why do we need this extra brace? -} \ No newline at end of file From 6c0303b3522b60a6b1320b02d5079ed9f12c1973 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 11:00:17 +0700 Subject: [PATCH 19/59] refactor(android/engine): Handle --ci flag --- android/KMEA/build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 8c050051d4..0cb9ef7652 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -42,7 +42,8 @@ builder_describe "Builds Keyman Engine for Android (KMEA)." \ "configure" \ "build" \ "test Runs lint and unit tests." \ - ":engine Builds KMEA" + ":engine Builds KMEA" \ + "--ci Don't start the Gradle daemon. For CI" # parse before describe_outputs to check debug flags builder_parse "$@" @@ -63,7 +64,7 @@ builder_describe_outputs \ function _copy_artifacts() { echo "Copying Keyman Engine for Android to KMAPro, Sample apps, and Tests" - mv $KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar + cp $KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample1/app/libs/keyman-engine.aar cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample2/app/libs/keyman-engine.aar cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Tests/KeyboardHarness/app/libs/keyman-engine.aar From 0555028892b9d02129c6aa937b5226c44d194aeb Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 11:39:09 +0700 Subject: [PATCH 20/59] refactor(android/samples): Update KMSample builder scripts --- android/Samples/KMSample1/build.sh | 57 ++++++++++++++--------------- android/Samples/KMSample2/build.sh | 59 ++++++++++++++---------------- 2 files changed, 55 insertions(+), 61 deletions(-) diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 0a09396ba5..fd000c1c80 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -8,7 +8,7 @@ set -eu ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary -THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" . "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE @@ -19,36 +19,41 @@ cd "$THIS_SCRIPT_PATH" ################################ Main script ################################ -builder_describe \ - "Build KMSample1 app for Android." \ - clean \ - build \ +builder_describe "Build KMSample1 app for Android." \ + "@../../KMEA configure" \ + "clean" \ + "build" \ ":app KMSample1" \ - "--ci Don't start the Gradle daemon. Use for CI" \ - "--debug,-d Local debug build; use for development builds" + "--ci Don't start the Gradle daemon. Use for CI" +# parse before describe_outputs to check debug flags builder_parse "$@" -SAMPLE_FLAGS="" +CONFIG="release" +SAMPLE_FLAGS="build" +ARTIFACT="app-release.apk" + +if builder_has_option --debug; then + CONFIG="debug" + SAMPLE_FLAGS="assembleDebug" + ARTIFACT="app-debug.apk" +fi # Build flags that apply to all targets if builder_has_option --ci; then SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" fi -if builder_has_option --debug; then - SAMPLE_FLAGS="$SAMPLE_FLAGS assembleDebug" -else - SAMPLE_FLAGS="$SAMPLE_FLAGS build" -fi +builder_describe_outputs \ + build:app ./app/build/outputs/apk/$CONFIG/$ARTIFACT # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 -# Clean build artifacts: output and upload directories -function _clean() { +# Check about cleaning artifact paths and upload directories +if builder_start_action clean; then cd "$KEYMAN_ROOT/android/Samples/KMSample1/" if [ -d "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" ]; then @@ -60,26 +65,18 @@ function _clean() { echo "Cleaning upload directory" rm -rf "$KEYMAN_ROOT/android/upload" fi -} -function _build_app() { - cd "$KEYMAN_ROOT/android/Samples/KMSample1" - ./gradlew clean $SAMPLE_FLAGS - - if [ $? -ne 0 ]; then - die "ERROR: KMSample1/build.sh failed" - fi -} - - -# Check about cleaning artifact paths -if builder_start_action clean; then - _clean builder_finish_action success clean fi # Building KMSample1 if builder_start_action build:app; then - _build_app + cd "$KEYMAN_ROOT/android/Samples/KMSample1" + ./gradlew clean $SAMPLE_FLAGS + + if [ $? -ne 0 ]; then + builder_die "ERROR: KMSample1/build.sh failed" + fi + builder_finish_action success build:app fi diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index 2d2f1c77db..0d121d8c50 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -8,7 +8,7 @@ set -eu ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary -THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" . "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE @@ -19,36 +19,41 @@ cd "$THIS_SCRIPT_PATH" ################################ Main script ################################ -builder_describe \ - "Build KMSample2 app for Android." \ - clean \ - build \ - ":app KMSample2" \ - "--ci Don't start the Gradle daemon. Use for CI" \ - "--debug,-d Local debug build; use for development builds" +builder_describe "Build KMSample2 app for Android." \ + "@../../KMEA configure" \ + "clean" \ + "build" \ + ":app KMSample1" \ + "--ci Don't start the Gradle daemon. Use for CI" +# parse before describe_outputs to check debug flags builder_parse "$@" -SAMPLE_FLAGS="" +CONFIG="release" +SAMPLE_FLAGS="build" +ARTIFACT="app-release.apk" + +if builder_has_option --debug; then + CONFIG="debug" + SAMPLE_FLAGS="assembleDebug" + ARTIFACT="app-debug.apk" +fi # Build flags that apply to all targets if builder_has_option --ci; then SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" fi -if builder_has_option --debug; then - SAMPLE_FLAGS="$SAMPLE_FLAGS assembleDebug" -else - SAMPLE_FLAGS="$SAMPLE_FLAGS build" -fi +builder_describe_outputs \ + build:app ./app/build/outputs/apk/$CONFIG/$ARTIFACT # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 -# Clean build artifacts: output and upload directories -function _clean() { +# Check about cleaning artifact paths and upload directories +if builder_start_action clean; then cd "$KEYMAN_ROOT/android/Samples/KMSample2/" if [ -d "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" ]; then @@ -60,26 +65,18 @@ function _clean() { echo "Cleaning upload directory" rm -rf "$KEYMAN_ROOT/android/upload" fi -} -function _build_app() { - cd "$KEYMAN_ROOT/android/Samples/KMSample2" - ./gradlew clean $SAMPLE_FLAGS - - if [ $? -ne 0 ]; then - die "ERROR: KMSample2/build.sh failed" - fi -} - - -# Check about cleaning artifact paths -if builder_start_action clean; then - _clean builder_finish_action success clean fi # Building KMSample2 if builder_start_action build:app; then - _build_app + cd "$KEYMAN_ROOT/android/Samples/KMSample2" + ./gradlew clean $SAMPLE_FLAGS + + if [ $? -ne 0 ]; then + builder_die "ERROR: KMSample2/build.sh failed" + fi + builder_finish_action success build:app fi From cb29cd05992b5222b66fc0cd35218f48546aaa0d Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 12:57:19 +0700 Subject: [PATCH 21/59] Apply suggestions from code review Co-authored-by: Marc Durdin --- android/KMEA/build.sh | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 0cb9ef7652..af9a30e871 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -37,7 +37,7 @@ DEBUG="debug" RELEASE="release" builder_describe "Builds Keyman Engine for Android (KMEA)." \ - "@../../web configure" \ + "@../../web" \ "clean" \ "configure" \ "build" \ @@ -113,25 +113,13 @@ if builder_start_action configure; then echo "Copying es6-shim polyfill" cp $KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js $KMEA_ASSETS/es6-shim.min.js - if [ $? -ne 0 ]; then - builder_die "ERROR: copying artifacts failed" - fi - # Cursory check that KMW exists - if [ ! -f "$KMEA_ASSETS/keymanandroid.js" ]; then - builder_die "ERROR: keymanweb not built" - fi builder_finish_action success configure fi if builder_start_action clean:engine; then - if [ -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" ]; then - rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" - echo "Cleaned $ARTIFACT" - else - echo "Nothing to clean" - fi + rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" builder_finish_action success clean:engine fi @@ -141,15 +129,11 @@ fi if builder_start_action build:engine; then - echo "Gradle Build of KMEA" - cd $KMA_ROOT/KMEA + cd "$KMA_ROOT/KMEA" echo "BUILD_FLAGS $BUILD_FLAGS" # Build without test ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS - if [ $? -ne 0 ]; then - builder_die "ERROR: Build of KMEA failed" - fi # TODO: remove _copy_artifacts() when all the Android projects have builder _copy_artifacts @@ -158,8 +142,7 @@ if builder_start_action build:engine; then fi if builder_start_action test:engine; then - echo "Gradle test of KMEA" - cd $KMA_ROOT/KMEA + cd "$KMA_ROOT/KMEA" if builder_has_option --ci; then # Report JUnit test results to CI @@ -168,9 +151,6 @@ if builder_start_action test:engine; then echo "TEST_FLAGS: $TEST_FLAGS" ./gradlew $DAEMON_FLAG $TEST_FLAGS - if [ $? -ne 0 ]; then - builder_die "ERROR: KMEA test cases failed" - fi builder_finish_action success test:engine fi From b034757cb5d606d56fe0cae253c686d780c5920e Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 13:17:52 +0700 Subject: [PATCH 22/59] refactor(android/engine): Address more review comments for KMEA builder --- android/KMEA/build.sh | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index af9a30e871..0ac230b07e 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Build Keyman Engine Android using Keyman Web artifacts +# Build Keyman Engine for Android using Keyman Web artifacts # # Abbreviations: # KMA - Keyman for Android @@ -27,14 +27,10 @@ cd "$THIS_SCRIPT_PATH" KMA_ROOT="$KEYMAN_ROOT/android" KMW_ROOT="$KEYMAN_ROOT/web" KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" -KMW_CONFIG=release +CONFIG="release" BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test TEST_FLAGS="-x aR lint testRelease" # Gradle test w/o build JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" -ARTIFACT="app-release.aar" - -DEBUG="debug" -RELEASE="release" builder_describe "Builds Keyman Engine for Android (KMEA)." \ "@../../web" \ @@ -50,13 +46,14 @@ builder_parse "$@" if builder_has_option --debug; then builder_heading "### Debug config ####" - KMW_CONFIG="$DEBUG" + CONFIG="debug" BUILD_FLAGS="assembleDebug -x lintDebug -x test" TEST_FLAGS="-x assembleDebug lintDebug testDebug" JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" - ARTIFACT="app-debug.aar" fi +ARTIFACT="app-$CONFIG.aar" + builder_describe_outputs \ build:engine ./app/build/outputs/aar/${ARTIFACT} @@ -97,34 +94,33 @@ fi #### Build action definitions #### +if builder_start_action clean:engine; then + # Clean debug and release artifacts + rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/app-debug.aar" + rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/app-release.aar" + + builder_finish_action success clean:engine +fi + if builder_start_action configure; then # Copy KeymanWeb artifacts echo "Copying KMW artifacts" - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/ajax-loader.gif $KMEA_ASSETS/ajax-loader.gif - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/keyman.js $KMEA_ASSETS/keymanandroid.js - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/keyman.js.map $KMEA_ASSETS/keyman.js.map - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/kmwosk.css $KMEA_ASSETS/kmwosk.css - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/globe-hint.css $KMEA_ASSETS/globe-hint.css - cp $KMW_ROOT/build/app/embed/$KMW_CONFIG/osk/keymanweb-osk.ttf $KMEA_ASSETS/keymanweb-osk.ttf + cp $KMW_ROOT/build/app/embed/$CONFIG/osk/ajax-loader.gif $KMEA_ASSETS/ajax-loader.gif + cp $KMW_ROOT/build/app/embed/$CONFIG/keyman.js $KMEA_ASSETS/keymanandroid.js + cp $KMW_ROOT/build/app/embed/$CONFIG/keyman.js.map $KMEA_ASSETS/keyman.js.map + cp $KMW_ROOT/build/app/embed/$CONFIG/osk/kmwosk.css $KMEA_ASSETS/kmwosk.css + cp $KMW_ROOT/build/app/embed/$CONFIG/osk/globe-hint.css $KMEA_ASSETS/globe-hint.css + cp $KMW_ROOT/build/app/embed/$CONFIG/osk/keymanweb-osk.ttf $KMEA_ASSETS/keymanweb-osk.ttf cp $KEYMAN_ROOT/common/web/sentry-manager/build/index.js $KMEA_ASSETS/keyman-sentry.js echo "Copying es6-shim polyfill" cp $KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js $KMEA_ASSETS/es6-shim.min.js - - builder_finish_action success configure fi -if builder_start_action clean:engine; then - rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT" - - builder_finish_action success clean:engine -fi - - # Destinations that will need the keymanweb artifacts From a02ae169616fe06fb9f5b8b23e0d2177f24c5b0f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 13:27:25 +0700 Subject: [PATCH 23/59] chore(android/engine): Rename abbreviations --- android/KMEA/build.sh | 61 +++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 0ac230b07e..8b3c112574 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -1,10 +1,6 @@ #!/usr/bin/env bash # Build Keyman Engine for Android using Keyman Web artifacts # -# Abbreviations: -# KMA - Keyman for Android -# KMEA - Keyman Engine for Android -# KMW - Keyman Web #set -x set -eu @@ -24,21 +20,21 @@ cd "$THIS_SCRIPT_PATH" # Definition of global compile constants -KMA_ROOT="$KEYMAN_ROOT/android" -KMW_ROOT="$KEYMAN_ROOT/web" -KMEA_ASSETS="$KMA_ROOT/KMEA/app/src/main/assets" +KEYMAN_ANDROID_ROOT="$KEYMAN_ROOT/android" +KEYMAN_WEB_ROOT="$KEYMAN_ROOT/web" +ENGINE_ASSETS="$KEYMAN_ANDROID_ROOT/KMEA/app/src/main/assets" CONFIG="release" BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test TEST_FLAGS="-x aR lint testRelease" # Gradle test w/o build JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" -builder_describe "Builds Keyman Engine for Android (KMEA)." \ +builder_describe "Builds Keyman Engine for Android." \ "@../../web" \ "clean" \ "configure" \ "build" \ "test Runs lint and unit tests." \ - ":engine Builds KMEA" \ + ":engine Builds Engine" \ "--ci Don't start the Gradle daemon. For CI" # parse before describe_outputs to check debug flags @@ -60,13 +56,13 @@ builder_describe_outputs \ #### Build function _copy_artifacts() { - echo "Copying Keyman Engine for Android to KMAPro, Sample apps, and Tests" - cp $KMA_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample1/app/libs/keyman-engine.aar - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Samples/KMSample2/app/libs/keyman-engine.aar - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/Tests/KeyboardHarness/app/libs/keyman-engine.aar + echo "Copying Keyman Engine for Android to Keyman App, Sample apps, and Tests" + cp $KEYMAN_ANDROID_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar + cp $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KEYMAN_ANDROID_ROOT/Samples/KMSample1/app/libs/keyman-engine.aar + cp $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KEYMAN_ANDROID_ROOT/Samples/KMSample2/app/libs/keyman-engine.aar + cp $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KEYMAN_ANDROID_ROOT/Tests/KeyboardHarness/app/libs/keyman-engine.aar if [ ! -z ${RELEASE_OEM+x} ]; then - cp $KMA_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KMA_ROOT/../oem/firstvoices/android/app/libs/keyman-engine.aar + cp $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KEYMAN_ANDROID_ROOT/../oem/firstvoices/android/app/libs/keyman-engine.aar fi } @@ -78,15 +74,6 @@ SHLVL=0 # Parse args - -# Local development optimization - cross-target Sentry uploading when requested -# by developer. As it's not CI, the Web artifacts won't exist otherwise... -# unless the developer manually runs the correct build configuration accordingly. -if [[ $VERSION_ENVIRONMENT == "local" ]] && [[ $UPLOAD_SENTRY == true ]]; then - # TODO: handle the -upload-sentry in its eventual new form - KMWFLAGS="$KMWFLAGS -upload-sentry" -fi - DAEMON_FLAG= if builder_has_option --ci; then DAEMON_FLAG=--no-daemon @@ -96,8 +83,8 @@ fi if builder_start_action clean:engine; then # Clean debug and release artifacts - rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/app-debug.aar" - rm -f "$KMA_ROOT/KMEA/app/build/outputs/aar/app-release.aar" + rm -f "$KEYMAN_ANDROID_ROOT/KMEA/app/build/outputs/aar/app-debug.aar" + rm -f "$KEYMAN_ANDROID_ROOT/KMEA/app/build/outputs/aar/app-release.aar" builder_finish_action success clean:engine fi @@ -105,18 +92,18 @@ fi if builder_start_action configure; then # Copy KeymanWeb artifacts - echo "Copying KMW artifacts" - cp $KMW_ROOT/build/app/embed/$CONFIG/osk/ajax-loader.gif $KMEA_ASSETS/ajax-loader.gif - cp $KMW_ROOT/build/app/embed/$CONFIG/keyman.js $KMEA_ASSETS/keymanandroid.js - cp $KMW_ROOT/build/app/embed/$CONFIG/keyman.js.map $KMEA_ASSETS/keyman.js.map - cp $KMW_ROOT/build/app/embed/$CONFIG/osk/kmwosk.css $KMEA_ASSETS/kmwosk.css - cp $KMW_ROOT/build/app/embed/$CONFIG/osk/globe-hint.css $KMEA_ASSETS/globe-hint.css - cp $KMW_ROOT/build/app/embed/$CONFIG/osk/keymanweb-osk.ttf $KMEA_ASSETS/keymanweb-osk.ttf + echo "Copying Keyman Web artifacts" + cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/ajax-loader.gif $ENGINE_ASSETS/ajax-loader.gif + cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/keyman.js $ENGINE_ASSETS/keymanandroid.js + cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/keyman.js.map $ENGINE_ASSETS/keyman.js.map + cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/kmwosk.css $ENGINE_ASSETS/kmwosk.css + cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/globe-hint.css $ENGINE_ASSETS/globe-hint.css + cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/keymanweb-osk.ttf $ENGINE_ASSETS/keymanweb-osk.ttf - cp $KEYMAN_ROOT/common/web/sentry-manager/build/index.js $KMEA_ASSETS/keyman-sentry.js + cp $KEYMAN_ROOT/common/web/sentry-manager/build/index.js $ENGINE_ASSETS/keyman-sentry.js echo "Copying es6-shim polyfill" - cp $KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js $KMEA_ASSETS/es6-shim.min.js + cp $KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js $ENGINE_ASSETS/es6-shim.min.js builder_finish_action success configure fi @@ -125,7 +112,7 @@ fi if builder_start_action build:engine; then - cd "$KMA_ROOT/KMEA" + cd "$KEYMAN_ANDROID_ROOT/KMEA" echo "BUILD_FLAGS $BUILD_FLAGS" # Build without test @@ -138,7 +125,7 @@ if builder_start_action build:engine; then fi if builder_start_action test:engine; then - cd "$KMA_ROOT/KMEA" + cd "$KEYMAN_ANDROID_ROOT/KMEA" if builder_has_option --ci; then # Report JUnit test results to CI From 69e40e30111ad9477f841b9bf778335963c4daf8 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 13:34:10 +0700 Subject: [PATCH 24/59] chore(android/engine): Tidy up lint for debug vs release --- android/KMEA/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 8b3c112574..fa759e4695 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -24,8 +24,8 @@ KEYMAN_ANDROID_ROOT="$KEYMAN_ROOT/android" KEYMAN_WEB_ROOT="$KEYMAN_ROOT/web" ENGINE_ASSETS="$KEYMAN_ANDROID_ROOT/KMEA/app/src/main/assets" CONFIG="release" -BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test -TEST_FLAGS="-x aR lint testRelease" # Gradle test w/o build +BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test +TEST_FLAGS="-x aR lintRelease testRelease" # Gradle test w/o build JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" builder_describe "Builds Keyman Engine for Android." \ @@ -43,7 +43,7 @@ builder_parse "$@" if builder_has_option --debug; then builder_heading "### Debug config ####" CONFIG="debug" - BUILD_FLAGS="assembleDebug -x lintDebug -x test" + BUILD_FLAGS="assembleDebug -x lint -x test" TEST_FLAGS="-x assembleDebug lintDebug testDebug" JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" fi From 132e7f6f86fc63a8d616f02fda81a0712c1c615f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 13:56:58 +0700 Subject: [PATCH 25/59] chore(android/samples): Tidy up Sample builder scripts --- android/Samples/KMSample1/build.sh | 36 +++++++++++++++++------------- android/Samples/KMSample2/build.sh | 36 +++++++++++++++++------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index fd000c1c80..4783c2208a 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -9,7 +9,7 @@ set -eu ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" -. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" +. "${THIS_SCRIPT%/*}/../../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" @@ -19,9 +19,15 @@ cd "$THIS_SCRIPT_PATH" ################################ Main script ################################ +# Definition of global compile constants + +CONFIG="release" +SAMPLE_FLAGS="build" + builder_describe "Build KMSample1 app for Android." \ - "@../../KMEA configure" \ + "@../../KMEA" \ "clean" \ + "configure" \ "build" \ ":app KMSample1" \ "--ci Don't start the Gradle daemon. Use for CI" @@ -29,20 +35,14 @@ builder_describe "Build KMSample1 app for Android." \ # parse before describe_outputs to check debug flags builder_parse "$@" -CONFIG="release" -SAMPLE_FLAGS="build" -ARTIFACT="app-release.apk" - if builder_has_option --debug; then + builder_heading "### Debug config ####" CONFIG="debug" SAMPLE_FLAGS="assembleDebug" - ARTIFACT="app-debug.apk" fi -# Build flags that apply to all targets -if builder_has_option --ci; then - SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" -fi +ARTIFACT="app-$CONFIG.apk" + builder_describe_outputs \ build:app ./app/build/outputs/apk/$CONFIG/$ARTIFACT @@ -52,17 +52,24 @@ builder_describe_outputs \ # SHLVL=0 + +# Parse args + +if builder_has_option --ci; then + SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" +fi + +#### Build action definitions #### + # Check about cleaning artifact paths and upload directories if builder_start_action clean; then cd "$KEYMAN_ROOT/android/Samples/KMSample1/" if [ -d "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" ]; then - echo "Cleaning KMSample1 build outputs directory" rm -rf "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" fi if [ -d "$KEYMAN_ROOT/android/upload" ]; then - echo "Cleaning upload directory" rm -rf "$KEYMAN_ROOT/android/upload" fi @@ -74,9 +81,6 @@ if builder_start_action build:app; then cd "$KEYMAN_ROOT/android/Samples/KMSample1" ./gradlew clean $SAMPLE_FLAGS - if [ $? -ne 0 ]; then - builder_die "ERROR: KMSample1/build.sh failed" - fi builder_finish_action success build:app fi diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index 0d121d8c50..f81f23421b 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -9,7 +9,7 @@ set -eu ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" -. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" +. "${THIS_SCRIPT%/*}/../../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" @@ -19,9 +19,15 @@ cd "$THIS_SCRIPT_PATH" ################################ Main script ################################ +# Definition of global compile constants + +CONFIG="release" +SAMPLE_FLAGS="build" + builder_describe "Build KMSample2 app for Android." \ - "@../../KMEA configure" \ + "@../../KMEA" \ "clean" \ + "configure" \ "build" \ ":app KMSample1" \ "--ci Don't start the Gradle daemon. Use for CI" @@ -29,20 +35,14 @@ builder_describe "Build KMSample2 app for Android." \ # parse before describe_outputs to check debug flags builder_parse "$@" -CONFIG="release" -SAMPLE_FLAGS="build" -ARTIFACT="app-release.apk" - if builder_has_option --debug; then + builder_heading "### Debug config ####" CONFIG="debug" SAMPLE_FLAGS="assembleDebug" - ARTIFACT="app-debug.apk" fi -# Build flags that apply to all targets -if builder_has_option --ci; then - SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" -fi +ARTIFACT="app-$CONFIG.apk" + builder_describe_outputs \ build:app ./app/build/outputs/apk/$CONFIG/$ARTIFACT @@ -52,17 +52,24 @@ builder_describe_outputs \ # SHLVL=0 + +# Parse args + +if builder_has_option --ci; then + SAMPLE_FLAGS="$SAMPLE_FLAGS -no-daemon" +fi + +#### Build action definitions #### + # Check about cleaning artifact paths and upload directories if builder_start_action clean; then cd "$KEYMAN_ROOT/android/Samples/KMSample2/" if [ -d "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" ]; then - echo "Cleaning KMSample2 build outputs directory" rm -rf "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" fi if [ -d "$KEYMAN_ROOT/android/upload" ]; then - echo "Cleaning upload directory" rm -rf "$KEYMAN_ROOT/android/upload" fi @@ -74,9 +81,6 @@ if builder_start_action build:app; then cd "$KEYMAN_ROOT/android/Samples/KMSample2" ./gradlew clean $SAMPLE_FLAGS - if [ $? -ne 0 ]; then - builder_die "ERROR: KMSample2/build.sh failed" - fi builder_finish_action success build:app fi From 0b5ef22a9913634bda4d73b4564d183d751d79e8 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 15:40:05 +0700 Subject: [PATCH 26/59] refactor(android/app): Update builder for KMAPro --- android/KMAPro/build.sh | 195 ++++++++++++++++++++-------------------- 1 file changed, 96 insertions(+), 99 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 22794de677..953306bdc6 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -1,13 +1,8 @@ #!/usr/bin/env bash -# Build KMAPro +# Build Keyman for Android app (KMAPro) -# Set sensible script defaults: -# set -e: Terminate script if a command returns an error -set -e -# set -u: Terminate script if an unset variable is used -set -u -# set -x: Debugging use, print each statement # set -x +set -eu ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary @@ -15,25 +10,67 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" . "${THIS_SCRIPT%/*}/../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + . "$KEYMAN_ROOT/resources/build/build-download-resources.sh" -echo Build KMAPro +# This script runs from its own folder +cd "$THIS_SCRIPT_PATH" + +# ################################ Main script ################################ + +# Definition of global compile constants + +CONFIG="release" +BUILD_FLAGS="build -x lint -x test" # Gradle build w/o test +TEST_FLAGS="-x assembleRelease lintRelease testRelease" # Gradle test w/o build +DAEMON_FLAG= + +builder_describe "Builds Keyman for Android app." \ + "@../KMEA" \ + "clean" \ + "configure" \ + "build" \ + "test Runs lint and unit tests." \ + "--ci Don't start the Gradle daemon. For CI" \ + "--upload-sentry Upload to sentry" + +# parse before describe_outputs to check debug flags +builder_parse "$@" + +if builder_has_option --debug; then + builder_heading "### Debug config ####" + CONFIG="debug" + BUILD_FLAGS="assembleDebug -x lint -x test" + TEST_FLAGS="-x assembleDebug lintDebug testDebug" +fi + +ARTIFACT="kMAPro-$CONFIG.apk" + +builder_describe_outputs \ + build:app ./kMAPro/build/outputs/apk/$CONFIG/${ARTIFACT} + +#### Build + +function _convert_markdown_to_html() { + echo "Converting markdown to html for offline help" + cd "$KEYMAN_ROOT/android" + ./build-help.sh htm +} # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 -display_usage ( ) { - echo "build.sh [-no-daemon] [-debug] [-download-resources]" - echo - echo "Build Keyman for Android" - echo " -no-daemon Don't start the Gradle daemon. Use for CI" - echo " -upload-sentry Uploads debug symbols, etc, to Sentry" - echo " -debug Compile only Debug variant" - echo " -download-resources Download sil_euro_latin.kmp and nrc.en.mtnt.model.kmp from downloads.keyman.com" - exit 1 -} + +# Parse args + +if builder_has_option --ci; then + DAEMON_FLAG=--no-daemon +fi + +#### Build action definitions #### function makeLocalSentryRelease() { echo "Making a Sentry release for tag $VERSION_GIT_TAG" @@ -44,97 +81,57 @@ function makeLocalSentryRelease() { sentry-cli releases finalize "$VERSION_GIT_TAG" } -NO_DAEMON=false -ONLY_DEBUG=false -DO_KEYBOARDS_DOWNLOAD=false -DO_MODELS_DOWNLOAD=false -DO_SENTRY_LOCAL_UPLOAD=false -# Parse args -while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -no-daemon) - NO_DAEMON=true - ;; - -upload-sentry) - # Overrides default set by build-utils.sh - UPLOAD_SENTRY=true - ;; - -debug) - ONLY_DEBUG=true - ;; - -download-resources) - DO_KEYBOARDS_DOWNLOAD=true - DO_MODELS_DOWNLOAD=true - ;; - -h|-\?) - display_usage - ;; - esac - shift # past argument -done +#### Build action definitions #### -KEYBOARD_PACKAGE_ID="sil_euro_latin" -KEYBOARDS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" -MODEL_PACKAGE_ID="nrc.en.mtnt" -MODELS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${MODEL_PACKAGE_ID}.model.kmp" +# Check about cleaning artifact paths and upload directories +if builder_start_action clean; then + cd "$KEYMAN_ROOT/android/KMAPro/" -# Verify default keyboard and dictionary exist -if [[ ! -f "$KEYBOARDS_TARGET" ]]; then - echo "$KEYBOARDS_TARGET doesn't exist. Will download the latest version" - DO_KEYBOARDS_DOWNLOAD=true + if [ -d "$KEYMAN_ROOT/android/KMAPro/kMAPro/build/outputs" ]; then + rm -rf "$KEYMAN_ROOT/android/KMAPro/kMAPro/build/outputs" + fi + + if [ -d "$KEYMAN_ROOT/android/upload" ]; then + rm -rf "$KEYMAN_ROOT/android/upload" + fi + + builder_finish_action success clean fi -if [[ ! -f "$MODELS_TARGET" ]]; then - echo "$MODELS_TARGET doesn't exist. Will download the latest version" - DO_MODELS_DOWNLOAD=true -fi +if builder_start_action configure; then + KEYBOARD_PACKAGE_ID="sil_euro_latin" + KEYBOARDS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" + MODEL_PACKAGE_ID="nrc.en.mtnt" + MODELS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${MODEL_PACKAGE_ID}.model.kmp" -# Local development optimization to upload local symbols to Sentry -if [[ $VERSION_ENVIRONMENT == "local" && $ONLY_DEBUG == true && $UPLOAD_SENTRY == true ]]; then - DO_SENTRY_LOCAL_UPLOAD=true -fi - -echo -echo "NO_DAEMON: $NO_DAEMON" -echo "ONLY_DEBUG: $ONLY_DEBUG" -echo "DO_KEYBOARDS_DOWNLOAD: $DO_KEYBOARDS_DOWNLOAD" -echo "DO_MODELS_DOWNLOAD: $DO_MODELS_DOWNLOAD" -echo "DO_SENTRY_LOCAL_UPLOAD: $DO_SENTRY_LOCAL_UPLOAD" -echo - -if [ "$NO_DAEMON" = true ]; then - DAEMON_FLAG=--no-daemon -else - DAEMON_FLAG= -fi - -# Convert markdown to html for offline help -echo "Converting markdown to html for offline help" -cd "$KEYMAN_ROOT/android" -./build-help.sh htm -cd "$KEYMAN_ROOT/android/KMAPro" - -# Download default keyboard and dictionary -if [ "$DO_KEYBOARDS_DOWNLOAD" = true ]; then downloadKeyboardPackage "$KEYBOARD_PACKAGE_ID" "$KEYBOARDS_TARGET" -fi - -if [ "$DO_MODELS_DOWNLOAD" = true ]; then downloadModelPackage "$MODEL_PACKAGE_ID" "$MODELS_TARGET" + + builder_finish_action success configure fi -if [ "$ONLY_DEBUG" = true ]; then - BUILD_FLAGS="assembleDebug lintDebug" -else - # build = assemble + check; check = test + lint - BUILD_FLAGS=build +if builder_start_action build; then + + # Convert markdown to html for offline help + _convert_markdown_to_html + + cd "$KEYMAN_ROOT/android/KMAPro" + + echo "BUILD_FLAGS $BUILD_FLAGS" + ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS + + if builder_has_option --upload-sentry; then + makeLocalSentryRelease + fi + + builder_finish_action success build fi -echo "BUILD_FLAGS $BUILD_FLAGS" -./gradlew $DAEMON_FLAG clean $BUILD_FLAGS +if builder_start_action test; then -if [ "$DO_SENTRY_LOCAL_UPLOAD" = true ]; then - makeLocalSentryRelease -fi \ No newline at end of file + echo "TEST_FLAGS $TEST_FLAGS" + ./gradlew $DAEMON_FLAG $TEST_FLAGS + + builder_finish_action success test +fi From 2bb7443cc61f57d6384152055813031788bf00a5 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 23 Feb 2023 16:33:30 +0700 Subject: [PATCH 27/59] refactor(oem/fv/android): Update builder script --- oem/firstvoices/android/build.sh | 161 ++++++++++++++++++------------- 1 file changed, 96 insertions(+), 65 deletions(-) diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 4951d5f305..d79a8e1a6c 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -1,12 +1,8 @@ #!/usr/bin/env bash +# Build FirstVoices for Android app -# Set sensible script defaults: -# set -e: Terminate script if a command returns an error -set -e -# set -u: Terminate script if an unset variable is used -set -u -# set -x: Debugging use, print each statement # set -x +set -eu ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary @@ -14,8 +10,82 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" . "${THIS_SCRIPT%/*}/../../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + . "$KEYMAN_ROOT/resources/build/build-download-resources.sh" +# This script runs from its own folder +cd "$THIS_SCRIPT_PATH" + +# ################################ Main script ################################ + +# Definition of global compile constants + +CONFIG="release" +BUILD_FLAGS="build -x lint -x test" # Gradle build w/o test +TEST_FLAGS="-x assembleRelease lintRelease testRelease" # Gradle test w/o build +DAEMON_FLAG= + +builder_describe "Builds FirstVoices for Android app." \ + "@../../../android/KMEA" \ + "configure" \ + "build" \ + "test Runs lint and tests." \ + "--ci Don't start the GRadle daemon. For CI" \ + "--upload-sentry Upload to sentry" + +# parse before describe_outputs to check debug flags +builder_parse "$@" + +if builder_has_option --debug; then + builder_heading "### Debug config ####" + CONFIG="debug" + BUILD_FLAGS="assembleDebug -x lint -x test" + TEST_FLAGS="-x assembleDebug lintDebug testDebug" +fi + +ARTIFACT="app-$CONFIG.apk" + +builder_describe_outputs \ + build:app ./app/build/outputs/apk/$CONFIG/${ARTIFACT} + +#### Build + +# +# Prevents 'clear' on exit of mingw64 bash shell +# +SHLVL=0 + + +# Parse args + +if builder_has_option --ci; then + DAEMON_FLAG=--no-daemon +fi + +#### Build action definitions #### + +function makeLocalSentryRelease() { + echo +} + +#### Build action definitions #### + +# Check about cleaning artifact paths and upload directories +if builder_start_action clean; then + cd "$KEYMAN_ROOT/oem/firstvoices/android/" + + if [ -d "$KEYMAN_ROOT/oem/firstvoices/android/app/build/outputs" ]; then + rm -rf "$KEYMAN_ROOT/oem/firstvoices/android/app/build/outputs" + fi + + if [ -d "$KEYMAN_ROOT/android/upload" ]; then + rm -rf "$KEYMAN_ROOT/android/upload" + fi + + builder_finish_action success clean +fi + display_usage ( ) { echo "build.sh [-no-daemon] [-debug] [-no-update] [-lib-build|-no-lib-build] [-download-keyboards] [-h|-?]" echo "Build $TARGET" @@ -30,68 +100,29 @@ display_usage ( ) { exit 1 } -export TARGET=FirstVoices -KEYBOARD_PACKAGE_ID="fv_all" -KEYBOARDS_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" -KEYBOARDS_CSV="$KEYMAN_ROOT/oem/firstvoices/keyboards.csv" -KEYBOARDS_CSV_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/keyboards.csv" +if builder_start_action configure; then + KEYBOARDS_CSV="$KEYMAN_ROOT/oem/firstvoices/keyboards.csv" + KEYBOARDS_CSV_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/keyboards.csv" -# This build script assumes that the https://github.com/keymanapp/keyboards repo is in -# the same parent folder as this repo, with the default name 'keyboards' + KEYBOARD_PACKAGE_ID="fv_all" + KEYBOARDS_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" -PARAM_DEBUG= -PARAM_NO_DAEMON= -PARAM_NO_UPDATE= -PARAM_LIB_BUILD= -PARAM_NO_LIB_BUILD= -DO_KEYBOARDS_DOWNLOAD=false - -while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -download-resources) - DO_KEYBOARDS_DOWNLOAD=true - ;; - -h|-\?) - display_usage - ;; - -debug) - PARAM_DEBUG=-debug - ;; - -no-daemon) - PARAM_NO_DAEMON=-no-daemon - ;; - -no-update) - PARAM_NO_UDPATE=-no-update - ;; - -lib-build) - PARAM_LIB_BUILD=-lib-build - ;; - -no-lib-build|-lib-nobuild) - PARAM_NO_LIB_BUILD=-no-lib-build - ;; - esac - shift -done - -# Verify default keyboard package exists -if [[ ! -f "$KEYBOARDS_TARGET" || ! -f "$KEYBOARDS_CSV_TARGET" ]]; then - echo "$KEYBOARDS_TARGET and $KEYBOARDS_CSV_TARGET required. Will download the latest version" - DO_KEYBOARDS_DOWNLOAD=true -fi - -if [ ! -z "$PARAM_LIB_BUILD" ] && [ ! -z "$PARAM_NO_LIB_BUILD" ]; then - echo "ERROR: Cannot set both -lib-build and -no-lib-build" - exit 1 -fi - -# Download default keyboard package -if [ "$DO_KEYBOARDS_DOWNLOAD" = true ]; then - echo "Copying keyboards.csv" cp "$KEYBOARDS_CSV" "$KEYBOARDS_CSV_TARGET" - downloadKeyboardPackage "$KEYBOARD_PACKAGE_ID" "$KEYBOARDS_TARGET" + + builder_finish_action success configure fi -# TODO: in the future build_common.sh should probably be shared with all oem products? -./build_common.sh $PARAM_DEBUG $PARAM_NO_DAEMON $PARAM_NO_UPDATE $PARAM_LIB_BUILD $PARAM_NO_LIB_BUILD +if builder_start_action build; then + echo "BUILD_FLAGS: $BUILD_FLAGS" + ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS + + builder_finish_action success build +fi + +if builder_start_action test; then + echo "TEST_FLAGS: $TEST_FLAGS" + ./gradlew $DAEMON_FLAG $TEST_FLAGS + + builder_finish_action_success test +fi From da00510ca35a1d5a4aa30d1dafdf1a75b70fafc7 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 24 Feb 2023 10:31:44 +0700 Subject: [PATCH 28/59] fix(android): Fix several scripts --- android/Tests/KeyboardHarness/build.sh | 90 ++++++----- android/build.sh | 192 ++++++------------------ oem/firstvoices/android/build.sh | 3 +- oem/firstvoices/android/build_common.sh | 129 ---------------- 4 files changed, 97 insertions(+), 317 deletions(-) delete mode 100755 oem/firstvoices/android/build_common.sh diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index 3dbb70e062..a8cbc2eb1f 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -1,15 +1,14 @@ #!/usr/bin/env bash # -# Tests: KeyboardHarness +# Build Test app: KeyboardHarness +#set -x set -eu -# set -x: Debugging use, print each statement -# set -x ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary -THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" -. "$(dirname "$THIS_SCRIPT")/../../../resources/build/build-utils.sh" +THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" +. "${THIS_SCRIPT%/*}/../../../resources/build/build-utils.sh" ## END STANDARD BUILD SCRIPT INCLUDE . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" @@ -19,36 +18,54 @@ cd "$THIS_SCRIPT_PATH" ################################ Main script ################################ -builder_describe \ - "Build KeyboardHarness test app for Android." \ - clean \ - build \ - ":app KeyboardHarness" \ - "--ci Don't start the Gradle daemon. Use for CI" \ - "--debug,-d Local debug build; use for development builds" +# Definition of global compile constants +CONFIG="release" +BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test +TEST_FLAGS="-x aR lintRelease testRelease" # Gradle test w/o build +builder_describe "Build KeyboardHarness test app for Android." \ + "@../../KMEA" \ + "clean" \ + "build" \ + ":app KeyboardHarness" \ + "--ci Don't start the Gradle daemon. Use for CI" + +# parse before describe outputs to check debug flags builder_parse "$@" -BUILD_FLAGS="" - -# Build flags that apply to all targets -if builder_has_option --ci; then - BUILD_FLAGS="$BUILD_FLAGS -no-daemon" -fi - if builder_has_option --debug; then - BUILD_FLAGS="$BUILD_FLAGS assembleDebug" -else - BUILD_FLAGS="$BUILD_FLAGS build" + builder_heading "### Debug config ####" + CONFIG=-"debug" + BUILD_FLAGS="assembleDebug -x lint -x test" + TEST_FLAGS="-x assembleDebug lintDebug testDebug" fi +ARTIFACT="app-$CONFIG.apk" + +builder_describe_outputs \ + build:app ./app/build/outputs/apk/$CONFIG/${ARTIFACT} + +#### Build + + # # Prevents 'clear' on exit of mingw64 bash shell # SHLVL=0 -# Clean build artifacts: output and upload directories -function _clean() { + +# Parse args + +# Build flags that apply to all targets +if builder_has_option --ci; then + BUILD_FLAGS="$BUILD_FLAGS -no-daemon" + TEST_FLAGS="$TEST_FLAGS -no-daemon" +fi + +#### Build action definitions #### + +# Check about cleaning artifact paths and upload directories +if builder_start_action clean; then cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" if [ -d "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/build/outputs" ]; then @@ -60,26 +77,21 @@ function _clean() { echo "Cleaning upload directory" rm -rf "$KEYMAN_ROOT/android/upload" fi -} -function _build_app() { - cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" - ./gradlew clean $BUILD_FLAGS - - if [ $? -ne 0 ]; then - die "ERROR: KeyboardHarness/build.sh failed" - fi -} - - -# Check about cleaning artifact paths -if builder_start_action clean; then - _clean builder_finish_action success clean fi # Building KeyboardHarness if builder_start_action build:app; then - _build_app + cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" + + echo "BUILD_FLAGS: $BUILD_FLAGS" + ./gradlew clean $BUILD_FLAGS builder_finish_action success build:app fi + +if builder_start_action test; then + echo "TEST_FLAGS $TEST_FLAGS" + + builder_finish_action succes test +fi diff --git a/android/build.sh b/android/build.sh index 655f6d1da3..60c14d1125 100755 --- a/android/build.sh +++ b/android/build.sh @@ -3,9 +3,8 @@ # Build Keyman Engine for Android, Keyman for Android, OEM FirstVoices Android app, # Samples: KMsample1 and KMSample2, Test - KeyboardHarness +#set -x set -eu -# set -x: Debugging use, print each statement -# set -x ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary @@ -24,53 +23,32 @@ builder_describe \ "Build Keyman Engine for Android, Keyman for Android, and FirstVoices Android app." \ clean \ build \ - "configure Download asset .kmp files from downloads.keyman.com" \ - "publish Publishes the APKs to the Play Store." \ - ":app Keyman for Android" \ - ":engine Keyman Engine for Android" \ - ":samples Sample apps: KMSample1 and KMSample2" \ - ":keyboardharness Test/KeyboardHarness app" \ - ":fv OEM FirstVoices app" \ - "--ci Don't start the Gradle daemon. Use for CI" \ - "--debug,-d Local debug build; use for development builds" \ - "--no-kmw-build,-nkmwb Don't build KMW. Just copy existing artifacts" \ - "--no-kmw,-nkmw Don't build KMW. Don't copy artifacts" \ - "--upload-sentry,-us Uploads debug symbols, etc, to Sentry" + "publish Publishes the APKs to the Play Store." \ + ":engine=KMEA Keyman Engine for Android" \ + ":app=KMAPro Keyman for Android" \ + ":sample1=Samples/KMSample1 Sample apps: KMSample1" \ + ":sample2=Samples/KMSample2 Sample app: KMSample2" \ + ":keyboardharness=Tests/KeyboardHarness Test app: KeyboardHarness" \ + ":fv=../oem/firstvoices/android OEM FirstVoices for Android app" \ + "--ci Don't start the Gradle daemon. Use for CI" \ + "--upload-sentry Uploads debug symbols, etc, to Sentry" builder_parse "$@" -KMEA_FLAGS="" -KMAPRO_FLAGS="" -SAMPLE_FLAGS="" -# FV will always use these -FV_FLAGS="-download-resources -lib-nobuild" +DEBUG_FLAG="" +CI_FLAG="" +SENTRY_FLAG="" -# Build flags that only apply to KMEA -if builder_has_option --no-kmw-build; then - KMEA_FLAGS="-no-kmw-build" -elif builder_has_option --no-kmw; then - KMEA_FLAGS="-no-kmw" -fi - -# Build flags that apply to all targets if builder_has_option --ci; then - KMEA_FLAGS="$KMEA_FLAGS -no-daemon" - KMAPRO_FLAGS="$KMAPRO_FLAGS -no-daemon" - SAMPLE_FLAGS="$SAMPLE_FLAGS --ci" # builder flag - FV_FLAGS="$FV_FLAGS -no-daemon" + CI_FLAG="--ci" fi if builder_has_option --debug; then - KMEA_FLAGS="$KMEA_FLAGS -debug" - KMAPRO_FLAGS="$KMAPRO_FLAGS -debug" - SAMPLE_FLAGS="$SAMPLE_FLAGS --debug" # builder flag - FV_FLAGS="$FV_FLAGS -debug" + DEBUG_FLAG="--debug" fi if builder_has_option --upload-sentry; then - KMEA_FLAGS="$KMEA_FLAGS -upload-sentry" - KMAPRO_FLAGS="$KMAPRO_FLAGS -upload-sentry" - FV_FLAGS="$FV_FLAGS -upload-sentry" + SENTRY_FLAG="--upload-sentry" fi # @@ -80,111 +58,23 @@ SHLVL=0 # Clean build artifacts: keyman-engine.aar libaries, output and upload directories function _clean() { - cd "$KEYMAN_ROOT/android" - - find . -name "keyman-engine.aar" | while read fname; do - echo "Cleaning $fname" - rm $fname - done - if [ -f "$KEYMAN_ROOT/oem/firstvoices/android/app/libs/keyman-engine.aar" ]; then - echo "Cleaning OEM FirstVoices keyman-engine.aar" - rm "$KEYMAN_ROOT/oem/firstvoices/android/app/libs/keyman-engine.aar" - fi - - if [ -d "$KEYMAN_ROOT/android/KMAPro/kMAPro/build/outputs" ]; then - echo "Cleaning KMAPro build outputs directory" - rm -rf "$KEYMAN_ROOT/android/KMAPro/kMAPro/build/outputs" - fi - - if [ -d "$KEYMAN_ROOT/android/upload" ]; then - echo "Cleaning upload directory" - rm -rf "$KEYMAN_ROOT/android/upload" - fi - - cd "$KEYMAN_ROOT/android/Samples/KMSample1" - ./build.sh clean - - cd "$KEYMAN_ROOT/android/Samples/KMSample2" - ./build.sh clean - - cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" - ./build.sh clean -} - -function _configure() { - . "$KEYMAN_ROOT/resources/build/build-download-resources.sh" - - # Keyman for Android .kmp dependencies - KEYBOARD_PACKAGE_ID="sil_euro_latin" - KEYBOARDS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" - MODEL_PACKAGE_ID="nrc.en.mtnt" - MODELS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${MODEL_PACKAGE_ID}.model.kmp" - - downloadKeyboardPackage "$KEYBOARD_PACKAGE_ID" "$KEYBOARDS_TARGET" - downloadModelPackage "$MODEL_PACKAGE_ID" "$MODELS_TARGET" - - # FirstVoices .csv and .kmp dependencies (dictionaries downloaded within the app) - FV_KEYBOARD_PACKAGE_ID="fv_all" - FV_KEYBOARDS_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/${FV_KEYBOARD_PACKAGE_ID}.kmp" - KEYBOARDS_CSV="$KEYMAN_ROOT/oem/firstvoices/keyboards.csv" - KEYBOARDS_CSV_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/keyboards.csv" - - echo "Copying keyboards.csv" - cp "$KEYBOARDS_CSV" "$KEYBOARDS_CSV_TARGET" - - downloadKeyboardPackage "$FV_KEYBOARD_PACKAGE_ID" "$FV_KEYBOARDS_TARGET" -} - -function _build_engine() { cd "$KEYMAN_ROOT/android/KMEA" - ./build.sh $KMEA_FLAGS + ./build.sh clean - if [ $? -ne 0 ]; then - builder_die "ERROR: KMEA/build.sh failed" - fi -} - -function _build_app() { cd "$KEYMAN_ROOT/android/KMAPro" - ./build.sh $KMAPRO_FLAGS + ./build.sh clean - if [ $? -ne 0 ]; then - builder_die "ERROR: KMAPro/build.sh failed" - fi -} - -function _build_samples() { cd "$KEYMAN_ROOT/android/Samples/KMSample1" - ./build.sh build:app $SAMPLE_FLAGS - - if [ $? -ne 0 ]; then - die "ERROR: KMSample1/build.sh failed" - fi + ./build.sh clean cd "$KEYMAN_ROOT/android/Samples/KMSample2" - ./build.sh build:app $SAMPLE_FLAGS + ./build.sh clean - if [ $? -ne 0 ]; then - die "ERROR: KMSample2/build.sh failed" - fi -} - -function _build_keyboardharness() { cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" - ./build.sh $SAMPLE_FLAGS + ./build.sh clean - if [ $? -ne 0 ]; then - die "ERROR: KeyboardHarness/build.sh failed" - fi -} - -function _build_fv() { - pushd "$KEYMAN_ROOT/oem/firstvoices/android" - ./build.sh $FV_FLAGS - - if [ $? -ne 0 ]; then - builder_die "ERROR: oem/firstvoices/android/build.sh failed" - fi + cd "$KEYMAN_ROOT/oem/firstvoices/android" + ./build.sh clean } # Check about cleaning artifact paths @@ -193,39 +83,45 @@ if builder_start_action clean; then builder_finish_action success clean fi -# Download .kmp resources -if builder_start_action configure; then - _configure - builder_finish_action success configure -fi - # Building Keyman Engine for Android if builder_start_action build:engine; then - _build_engine + cd "$KEYMAN_ROOT/android/KMEA" + ./build.sh build:engine $CI_FLAG $DEBUG_FLAG builder_finish_action success build:engine fi # Building Keyman for Android if builder_start_action build:app; then - _build_app + cd "$KEYMAN_ROOT/android/KMAPro" + ./build.sh build $CI_FLAG $DEBUG_FLAG $SENTRY_FLAG builder_finish_action success build:app fi -# Building Sample apps -if builder_start_action build:samples; then - _build_samples - builder_finish_action success build:samples +# Building KMSample1 app +if builder_start_action build:sample1; then + cd "$KEYMAN_ROOT/android/Samples/KMSample1" + ./build.sh build $CI_FLAG $DEBUG_FLAG + builder_finish_action success build:sample1 +fi + +# Building KMSample2 app +if builder_start_action build:sample2; then + cd "$KEYMAN_ROOT/android/Samples/KMSample2" + ./build.sh build $CI_FLAG $DEBUG_FLAG + builder_finish_action success build:sample2 fi # Building KeyboardHarness app if builder_start_action build:keyboardharness; then - _build_keyboardharness + cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" + ./build.sh build $CI_FLAG $DEBUG_FLAG builder_finish_action success build:keyboardharness fi -# Building OEM apps +# Building OEM app if builder_start_action build:fv; then - _build_fv + cd "$KEYMAN_ROOT/oem/firstvoices/android" + ./build.sh build $CI_FLAG $DEBUG_FLAG builder_finish_action success build:fv fi diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index d79a8e1a6c..d1ef60e5f9 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -28,6 +28,7 @@ DAEMON_FLAG= builder_describe "Builds FirstVoices for Android app." \ "@../../../android/KMEA" \ + "clean" \ "configure" \ "build" \ "test Runs lint and tests." \ @@ -66,7 +67,7 @@ fi #### Build action definitions #### function makeLocalSentryRelease() { - echo + echo "Placeholder for uploading symbols to Sentry" } #### Build action definitions #### diff --git a/oem/firstvoices/android/build_common.sh b/oem/firstvoices/android/build_common.sh deleted file mode 100755 index 8b843f9d02..0000000000 --- a/oem/firstvoices/android/build_common.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/env bash - -# Set sensible script defaults: -# set -e: Terminate script if a command returns an error -set -e -# set -u: Terminate script if an unset variable is used -set -u -# set -x: Debugging use, print each statement -# set -x - -if [ -z "$TARGET" ]; then - exit 1 -fi - -display_usage ( ) { - echo "build_common.sh [-no-daemon] [-debug] [-no-update] [-lib-build|-no-lib-build]" - echo "Build $TARGET" - echo " -no-daemon Don't start the Gradle daemon. Use for CI" - echo " -debug Compile only Debug variant" - echo " -no-update Don't copy or build the Keyman Engine library in (assumes already present)" - echo " -lib-build Force rebuild of the Keyman Engine library" - echo " -no-lib-build Only rebuild the Keyman Engine library if it doesn't exist in /android" - exit 1 -} - -verify_KMEA ( ) { - KMEA_BUILD_EXISTS=true - [ -f "$KEYMAN_ENGINE_DST" ] || KMEA_BUILD_EXISTS=false -} - -echo Build $TARGET - -# -# Prevents 'clear' on exit of mingw64 bash shell -# -SHLVL=0 - -DO_UPDATE=true -FORCE_KMEA_BUILD=false -ALLOW_KMEA_BUILD=true -NO_DAEMON=false -ONLY_DEBUG=false - -# Parse args -while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -no-daemon) - NO_DAEMON=true - ;; - -debug) - ONLY_DEBUG=true - ;; - # Settings relating to engine build - -no-update) - DO_UPDATE=false - ALLOW_KMEA_BUILD=false - ;; - -lib-build) - FORCE_KMEA_BUILD=true - ;; - -lib-nobuild|-no-lib-build) - ALLOW_KMEA_BUILD=false - ;; - -h|-\?) - display_usage - ;; - esac - shift # past argument -done - -echo -echo "NO_DAEMON: $NO_DAEMON" -echo "ONLY_DEBUG: $ONLY_DEBUG" -echo "DO_UPDATE: $DO_UPDATE" -echo "ALLOW_KMEA_BUILD: $ALLOW_KMEA_BUILD" -echo "FORCE_KMEA_BUILD: $FORCE_KMEA_BUILD" -echo - -# The KMEA build script moves the final .aar from KMEA to KMAPro... -KMEA_BUILD_DIR=../../../android/KMEA/ -KEYMAN_ENGINE_SRC=../../../android/KMAPro/kMAPro/libs/keyman-engine.aar -KEYMAN_ENGINE_DST=app/libs/keyman-engine.aar - -# -# Build Keyman Engine -# - -if [ $DO_UPDATE = true ]; then - # Does a prior build of KMEA exist? - verify_KMEA - - if [ $ALLOW_KMEA_BUILD = true ] && [ $FORCE_KMEA_BUILD = false ] && [ $KMEA_BUILD_EXISTS = false ]; then - echo "Previous Keyman Engine build information is unavailable; rebuilding." - FORCE_KMEA_BUILD=true - fi - - if [ $FORCE_KMEA_BUILD = true ]; then - echo "Building Keyman Engine..." - pushd $KMEA_BUILD_DIR - ./build.sh "$@" - popd - fi - - verify_KMEA - - if ! [ $KMEA_BUILD_EXISTS ]; then - echo "Build failed: Could not build required Keyman Engine resources." - exit 1 - fi - - # Copy Keyman Engine aar to - cp "$KEYMAN_ENGINE_SRC" "$KEYMAN_ENGINE_DST" -fi - - -if [ "$NO_DAEMON" = true ]; then - DAEMON_FLAG=--no-daemon -else - DAEMON_FLAG= -fi - -if [ "$ONLY_DEBUG" = true ]; then - BUILD_FLAG=assembleDebug -else - BUILD_FLAG=build -fi - -./gradlew $DAEMON_FLAG clean $BUILD_FLAG From 7a1f80e70dde3dccc6dc61a3eff71389c048cf31 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 24 Feb 2023 11:33:26 +0700 Subject: [PATCH 29/59] fix(android): Update configure actions --- android/KMAPro/build.sh | 3 +++ android/KMEA/build.sh | 31 +++++++++++++------------- android/Samples/KMSample1/build.sh | 7 ++++++ android/Samples/KMSample2/build.sh | 7 ++++++ android/Tests/KeyboardHarness/build.sh | 8 +++++++ oem/firstvoices/android/build.sh | 3 +++ 6 files changed, 43 insertions(+), 16 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 953306bdc6..2199709fb3 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -100,6 +100,9 @@ if builder_start_action clean; then fi if builder_start_action configure; then + # Copy Keyman Engine for Android + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/$ARTIFACT" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar" + KEYBOARD_PACKAGE_ID="sil_euro_latin" KEYBOARDS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" MODEL_PACKAGE_ID="nrc.en.mtnt" diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index fa759e4695..3cd6dd17eb 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -48,24 +48,13 @@ if builder_has_option --debug; then JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" fi -ARTIFACT="app-$CONFIG.aar" +ARTIFACT="app-$CONFIG.aar" # Note: dependants will use keyman-engine.aar builder_describe_outputs \ build:engine ./app/build/outputs/aar/${ARTIFACT} #### Build -function _copy_artifacts() { - echo "Copying Keyman Engine for Android to Keyman App, Sample apps, and Tests" - cp $KEYMAN_ANDROID_ROOT/KMEA/app/build/outputs/aar/$ARTIFACT $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar - cp $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KEYMAN_ANDROID_ROOT/Samples/KMSample1/app/libs/keyman-engine.aar - cp $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KEYMAN_ANDROID_ROOT/Samples/KMSample2/app/libs/keyman-engine.aar - cp $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KEYMAN_ANDROID_ROOT/Tests/KeyboardHarness/app/libs/keyman-engine.aar - if [ ! -z ${RELEASE_OEM+x} ]; then - cp $KEYMAN_ANDROID_ROOT/KMAPro/kMAPro/libs/keyman-engine.aar $KEYMAN_ANDROID_ROOT/../oem/firstvoices/android/app/libs/keyman-engine.aar - fi -} - # # Prevents 'clear' on exit of mingw64 bash shell # @@ -81,10 +70,17 @@ fi #### Build action definitions #### +# Check about cleaning arifact paths and upload directories if builder_start_action clean:engine; then - # Clean debug and release artifacts - rm -f "$KEYMAN_ANDROID_ROOT/KMEA/app/build/outputs/aar/app-debug.aar" - rm -f "$KEYMAN_ANDROID_ROOT/KMEA/app/build/outputs/aar/app-release.aar" + cd "$KEYMAN_ROOT/android/KMEA/" + + if [ -d "$KEYMAN_ROOT/android/KMEA/app/build/outputs" ]; then + rm -rf "$KEYMAN_ROOT/android/KMEA/app/build/outputs" + fi + + if [ -d "$KEYMAN_ROOT/android/upload" ]; then + rm -rf "$KEYMAN_ROOT/android/upload" + fi builder_finish_action success clean:engine fi @@ -118,8 +114,11 @@ if builder_start_action build:engine; then # Build without test ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS + # Copy ARTIFACT to "keyman-engine.aar" + cp "$KEYMAN_ROOT/android/kmea/app/build/outputs/aar/${ARTIFACT}" "$KEYMAN_ROOT/android/kmea/app/build/outputs/aar/keyman-engine.aar" + # TODO: remove _copy_artifacts() when all the Android projects have builder - _copy_artifacts + #_copy_artifacts builder_finish_action success build:engine fi diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 4783c2208a..86fa1eab52 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -76,6 +76,13 @@ if builder_start_action clean; then builder_finish_action success clean fi +if builder_start_action configure; then + # Copy Keyman Engine for Android + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample1/app/libs/keyman-engine.aar" + + builder_finish_action success configure +fi + # Building KMSample1 if builder_start_action build:app; then cd "$KEYMAN_ROOT/android/Samples/KMSample1" diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index f81f23421b..7d215f650a 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -76,6 +76,13 @@ if builder_start_action clean; then builder_finish_action success clean fi +if builder_start_action configure; then + # Copy Keyman Engine for Android + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample2/app/libs/keyman-engine.aar" + + builder_finish_action success configure +fi + # Building KMSample2 if builder_start_action build:app; then cd "$KEYMAN_ROOT/android/Samples/KMSample2" diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index a8cbc2eb1f..cbd7a1ad10 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -26,6 +26,7 @@ TEST_FLAGS="-x aR lintRelease testRelease" # Gradle test w/o build builder_describe "Build KeyboardHarness test app for Android." \ "@../../KMEA" \ "clean" \ + "configure" \ "build" \ ":app KeyboardHarness" \ "--ci Don't start the Gradle daemon. Use for CI" @@ -81,6 +82,13 @@ if builder_start_action clean; then builder_finish_action success clean fi +if builder_start_action configure; then + # Copy Keyman Engine for Android + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/libs/keyman-engine.aar" + + builder_finish_action success configure +fi + # Building KeyboardHarness if builder_start_action build:app; then cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index d1ef60e5f9..7c069de558 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -102,6 +102,9 @@ display_usage ( ) { } if builder_start_action configure; then + # Copy Keyman Engine for Android + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/oem/firstvoices/android/app/libs/keyman-engine.aar" + KEYBOARDS_CSV="$KEYMAN_ROOT/oem/firstvoices/keyboards.csv" KEYBOARDS_CSV_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/keyboards.csv" From ed0d69b385165beb4fa6e3fdb45a2404bbb1ea46 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 24 Feb 2023 11:38:43 +0700 Subject: [PATCH 30/59] chore(android/engine): More cleanup --- android/KMEA/build.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 3cd6dd17eb..f3cfea84d3 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -117,9 +117,6 @@ if builder_start_action build:engine; then # Copy ARTIFACT to "keyman-engine.aar" cp "$KEYMAN_ROOT/android/kmea/app/build/outputs/aar/${ARTIFACT}" "$KEYMAN_ROOT/android/kmea/app/build/outputs/aar/keyman-engine.aar" - # TODO: remove _copy_artifacts() when all the Android projects have builder - #_copy_artifacts - builder_finish_action success build:engine fi From e1820013c64532e3613243bea2a9ac7c2d9d594f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 24 Feb 2023 13:46:00 +0700 Subject: [PATCH 31/59] fix(android): Fix output paths --- android/KMAPro/build.sh | 2 +- android/KMEA/build.sh | 4 ++-- android/Samples/KMSample1/build.sh | 2 +- android/Samples/KMSample2/build.sh | 2 +- android/Tests/KeyboardHarness/build.sh | 2 +- oem/firstvoices/android/build.sh | 16 +--------------- 6 files changed, 7 insertions(+), 21 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 2199709fb3..471c09edc7 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -48,7 +48,7 @@ fi ARTIFACT="kMAPro-$CONFIG.apk" builder_describe_outputs \ - build:app ./kMAPro/build/outputs/apk/$CONFIG/${ARTIFACT} + build:app kMAPro/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index f3cfea84d3..64f87db446 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -51,7 +51,7 @@ fi ARTIFACT="app-$CONFIG.aar" # Note: dependants will use keyman-engine.aar builder_describe_outputs \ - build:engine ./app/build/outputs/aar/${ARTIFACT} + build:engine app/build/outputs/aar/${ARTIFACT} #### Build @@ -115,7 +115,7 @@ if builder_start_action build:engine; then ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS # Copy ARTIFACT to "keyman-engine.aar" - cp "$KEYMAN_ROOT/android/kmea/app/build/outputs/aar/${ARTIFACT}" "$KEYMAN_ROOT/android/kmea/app/build/outputs/aar/keyman-engine.aar" + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${ARTIFACT}" "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" builder_finish_action success build:engine fi diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 86fa1eab52..852833fde8 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -45,7 +45,7 @@ ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ - build:app ./app/build/outputs/apk/$CONFIG/$ARTIFACT + build:app app/build/outputs/apk/$CONFIG/$ARTIFACT # # Prevents 'clear' on exit of mingw64 bash shell diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index 7d215f650a..6e5cd0b82a 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -45,7 +45,7 @@ ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ - build:app ./app/build/outputs/apk/$CONFIG/$ARTIFACT + build:app app/build/outputs/apk/$CONFIG/$ARTIFACT # # Prevents 'clear' on exit of mingw64 bash shell diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index cbd7a1ad10..42680cc598 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -44,7 +44,7 @@ fi ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ - build:app ./app/build/outputs/apk/$CONFIG/${ARTIFACT} + build:app app/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 7c069de558..15222b377b 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -48,7 +48,7 @@ fi ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ - build:app ./app/build/outputs/apk/$CONFIG/${ARTIFACT} + build:app app/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build @@ -87,20 +87,6 @@ if builder_start_action clean; then builder_finish_action success clean fi -display_usage ( ) { - echo "build.sh [-no-daemon] [-debug] [-no-update] [-lib-build|-no-lib-build] [-download-keyboards] [-h|-?]" - echo "Build $TARGET" - echo " -no-daemon Don't start the Gradle daemon. Use for CI" - echo " -debug Compile only Debug variant" - echo " -no-update Don't copy or build the Keyman Engine library in (assumes already present)" - echo " -lib-build Force rebuild of the Keyman Engine library" - echo " -no-lib-build Only rebuild the Keyman Engine library if it doesn't exist in /android" - echo " -download-resources Download fv_all.kmp from downloads.keyman.com" - echo " (dictionaries will be downloaded within the app)" - echo "" - exit 1 -} - if builder_start_action configure; then # Copy Keyman Engine for Android cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/oem/firstvoices/android/app/libs/keyman-engine.aar" From 475d5649aa069ffec81e1ec9438b5512335a94b1 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 24 Feb 2023 14:03:15 +0700 Subject: [PATCH 32/59] fix(android/app): Configure step --- android/KMAPro/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 471c09edc7..772a71aa14 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -101,7 +101,7 @@ fi if builder_start_action configure; then # Copy Keyman Engine for Android - cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/$ARTIFACT" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar" + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar" KEYBOARD_PACKAGE_ID="sil_euro_latin" KEYBOARDS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" From 29a3f2f6c5a3f665a29cb3c786bc786da24e5129 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 27 Feb 2023 09:41:11 +0700 Subject: [PATCH 33/59] fix(android/engine): Output keyman-engine.aar --- android/KMEA/app/build.gradle | 7 +++++++ android/KMEA/build.sh | 26 ++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/android/KMEA/app/build.gradle b/android/KMEA/app/build.gradle index 0caa91a70b..3f8844c51d 100644 --- a/android/KMEA/app/build.gradle +++ b/android/KMEA/app/build.gradle @@ -25,6 +25,13 @@ android { } } + // Sepcify library filename keyman-engine.aar + libraryVariants.all { variant -> + variant.outputs.all { + outputFileName = "keyman-engine.aar" + } + } + // TODO: Remove ResourceType when SDK > 17 lintOptions { disable 'ImpliedQuantity', 'MissingQuantity', 'MissingTranslation', 'ResourceType' diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 64f87db446..35d06572c3 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -27,6 +27,7 @@ CONFIG="release" BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test TEST_FLAGS="-x aR lintRelease testRelease" # Gradle test w/o build JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" +ARTIFACT="keyman-engine.aar" builder_describe "Builds Keyman Engine for Android." \ "@../../web" \ @@ -37,19 +38,6 @@ builder_describe "Builds Keyman Engine for Android." \ ":engine Builds Engine" \ "--ci Don't start the Gradle daemon. For CI" -# parse before describe_outputs to check debug flags -builder_parse "$@" - -if builder_has_option --debug; then - builder_heading "### Debug config ####" - CONFIG="debug" - BUILD_FLAGS="assembleDebug -x lint -x test" - TEST_FLAGS="-x assembleDebug lintDebug testDebug" - JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" -fi - -ARTIFACT="app-$CONFIG.aar" # Note: dependants will use keyman-engine.aar - builder_describe_outputs \ build:engine app/build/outputs/aar/${ARTIFACT} @@ -62,6 +50,16 @@ SHLVL=0 # Parse args +# parse before describe_outputs to check debug flags +builder_parse "$@" + +if builder_has_option --debug; then + builder_heading "### Debug config ####" + CONFIG="debug" + BUILD_FLAGS="assembleDebug -x lint -x test" + TEST_FLAGS="-x assembleDebug lintDebug testDebug" + JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" +fi DAEMON_FLAG= if builder_has_option --ci; then @@ -115,7 +113,7 @@ if builder_start_action build:engine; then ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS # Copy ARTIFACT to "keyman-engine.aar" - cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${ARTIFACT}" "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" + # cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${ARTIFACT}" "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" builder_finish_action success build:engine fi From 90b1bc82f221640e59ad2ec3d55616f9f01cc124 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 27 Feb 2023 11:32:29 +0700 Subject: [PATCH 34/59] fix(android): Include config in path to keyman-engine.aar --- android/KMAPro/build.sh | 1 + android/KMEA/app/build.gradle | 4 ++-- android/KMEA/build.sh | 28 +++++++++++--------------- android/Samples/KMSample1/build.sh | 1 + android/Samples/KMSample2/build.sh | 1 + android/Tests/KeyboardHarness/build.sh | 1 + oem/firstvoices/android/build.sh | 1 + 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 772a71aa14..bbcf1d325d 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -48,6 +48,7 @@ fi ARTIFACT="kMAPro-$CONFIG.apk" builder_describe_outputs \ + configure kMAPro/libs/keyman-engine.aar \ build:app kMAPro/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build diff --git a/android/KMEA/app/build.gradle b/android/KMEA/app/build.gradle index 3f8844c51d..4b4da18754 100644 --- a/android/KMEA/app/build.gradle +++ b/android/KMEA/app/build.gradle @@ -25,10 +25,10 @@ android { } } - // Sepcify library filename keyman-engine.aar + // Sepcify library filename $CONFIG/keyman-engine.aar libraryVariants.all { variant -> variant.outputs.all { - outputFileName = "keyman-engine.aar" + outputFileName = "${variant.buildType.name}/keyman-engine.aar" } } diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 35d06572c3..0179ee0801 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -27,7 +27,6 @@ CONFIG="release" BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test TEST_FLAGS="-x aR lintRelease testRelease" # Gradle test w/o build JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" -ARTIFACT="keyman-engine.aar" builder_describe "Builds Keyman Engine for Android." \ "@../../web" \ @@ -38,18 +37,6 @@ builder_describe "Builds Keyman Engine for Android." \ ":engine Builds Engine" \ "--ci Don't start the Gradle daemon. For CI" -builder_describe_outputs \ - build:engine app/build/outputs/aar/${ARTIFACT} - -#### Build - -# -# Prevents 'clear' on exit of mingw64 bash shell -# -SHLVL=0 - - -# Parse args # parse before describe_outputs to check debug flags builder_parse "$@" @@ -61,6 +48,18 @@ if builder_has_option --debug; then JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testDebugUnitTest\']" fi +builder_describe_outputs \ + build:engine app/build/outputs/aar/${CONFIG}/keyman-engine.aar + +#### Build + +# +# Prevents 'clear' on exit of mingw64 bash shell +# +SHLVL=0 + +# Parse args + DAEMON_FLAG= if builder_has_option --ci; then DAEMON_FLAG=--no-daemon @@ -112,9 +111,6 @@ if builder_start_action build:engine; then # Build without test ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS - # Copy ARTIFACT to "keyman-engine.aar" - # cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${ARTIFACT}" "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" - builder_finish_action success build:engine fi diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 852833fde8..c2c6935f37 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -45,6 +45,7 @@ ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ + configure app/libs/keyman-engine.aar \ build:app app/build/outputs/apk/$CONFIG/$ARTIFACT # diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index 6e5cd0b82a..4636eabfba 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -45,6 +45,7 @@ ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ + configure app/libs/keyman-engine.aar \ build:app app/build/outputs/apk/$CONFIG/$ARTIFACT # diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index 42680cc598..f80ff0a53a 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -44,6 +44,7 @@ fi ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ + configure app/libs/keyman-engine.aar \ build:app app/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 15222b377b..c82a53e488 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -48,6 +48,7 @@ fi ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ + configure app/libs/keyman-engine.aar \ build:app app/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build From d2030767c769d319b18ce83b9e51f60f0dcc19a5 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 27 Feb 2023 11:46:05 +0700 Subject: [PATCH 35/59] refactor(android/app): Update Gradle for final apk name --- android/KMAPro/build.sh | 4 +--- android/KMAPro/kMAPro/build.gradle | 5 +++++ android/version.gradle | 13 +++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index bbcf1d325d..2b95a81e12 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -45,11 +45,9 @@ if builder_has_option --debug; then TEST_FLAGS="-x assembleDebug lintDebug testDebug" fi -ARTIFACT="kMAPro-$CONFIG.apk" - builder_describe_outputs \ configure kMAPro/libs/keyman-engine.aar \ - build:app kMAPro/build/outputs/apk/$CONFIG/${ARTIFACT} + build:app kMAPro/build/outputs/apk/$CONFIG/keyman-${VERSION}.apk #### Build diff --git a/android/KMAPro/kMAPro/build.gradle b/android/KMAPro/kMAPro/build.gradle index f2d788df2b..df38b2ade8 100644 --- a/android/KMAPro/kMAPro/build.gradle +++ b/android/KMAPro/kMAPro/build.gradle @@ -95,6 +95,11 @@ android { } } variant.resValue "string", "app_name", 'Keyman' + appSuffix; + + // Adjust output name to "keyman-${VERSION_MD}.apk" + variant.outputs.all { + outputFileName = "keyman-" + VERSION_MD + ".apk" + } } lintOptions { disable 'MissingQuantity', 'MissingTranslation' diff --git a/android/version.gradle b/android/version.gradle index 7aef41058b..ebf68a94e0 100644 --- a/android/version.gradle +++ b/android/version.gradle @@ -35,6 +35,18 @@ def getVersionCode = { -> return 100 } +def getVersionMD = { -> + String env_version = System.getenv("VERSION") + if (env_version != null) { + // If building from script, we have build number in VERSION + println "Using build $env_version from VERSION" + return "$env_version" + } else { + String version_md = file("$rootPath/../VERSION.md").text.trim() + return "$version_md" + } +} + def getVersionName = { -> String env_version = System.getenv("VERSION_WITH_TAG") if (env_version != null) { @@ -78,6 +90,7 @@ def getVersionGitTag = { -> } ext { VERSION_CODE=getVersionCode() + VERSION_MD=getVersionMD() VERSION_NAME=getVersionName() VERSION_ENVIRONMENT=getVersionEnvironment() VERSION_TAG=System.getenv("VERSION_TAG") From 576e1b1bfebeb84e4765dcaf6d949b83538f051b Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 27 Feb 2023 11:46:27 +0700 Subject: [PATCH 36/59] refactor(oem/fv/android): Upgrade Gradle for final apk name --- oem/firstvoices/android/app/build.gradle | 6 ++++++ oem/firstvoices/android/build.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/oem/firstvoices/android/app/build.gradle b/oem/firstvoices/android/app/build.gradle index aba0c1bb43..737d3462c3 100644 --- a/oem/firstvoices/android/app/build.gradle +++ b/oem/firstvoices/android/app/build.gradle @@ -58,6 +58,12 @@ android { productFlavors { } + applicationVariants.all { variant -> + // Adjust output name to "firstvoices-${VERSION_MD}.apk" + variant.outputs.all { + outputFileName = "firstvoices-" + VERSION_MD + ".apk" + } + } lintOptions { disable 'MissingTranslation' lintConfig file("lint.xml") diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index c82a53e488..8c51ecdc56 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -49,7 +49,7 @@ ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ configure app/libs/keyman-engine.aar \ - build:app app/build/outputs/apk/$CONFIG/${ARTIFACT} + build:app app/build/outputs/apk/$CONFIG/firstvoices${ARTIFACT} #### Build From 337abea2f3c6a72c8deaa27735ed07f2329dc79b Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 27 Feb 2023 14:53:20 +0700 Subject: [PATCH 37/59] fix(android/samples): Config parameter --- android/Tests/KeyboardHarness/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index f80ff0a53a..d0f6794a70 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -36,7 +36,7 @@ builder_parse "$@" if builder_has_option --debug; then builder_heading "### Debug config ####" - CONFIG=-"debug" + CONFIG="debug" BUILD_FLAGS="assembleDebug -x lint -x test" TEST_FLAGS="-x assembleDebug lintDebug testDebug" fi From 1e243e8c6f27656b43f447a275c69085ed004fc4 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 27 Feb 2023 15:32:56 +0700 Subject: [PATCH 38/59] refactor(android): Update top level script --- android/build.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/android/build.sh b/android/build.sh index 60c14d1125..0288e76bb5 100755 --- a/android/build.sh +++ b/android/build.sh @@ -35,6 +35,7 @@ builder_describe \ builder_parse "$@" +CONFIG="release" DEBUG_FLAG="" CI_FLAG="" SENTRY_FLAG="" @@ -44,9 +45,19 @@ if builder_has_option --ci; then fi if builder_has_option --debug; then + CONFIG="debug" DEBUG_FLAG="--debug" fi +builder_describe_outputs \ + build:engine KMEA/app/build/outputs/aar/$CONFIG/keyman-engine.aar \ + build:app KMAPro/kMAPro/build/outputs/$CONFIG/keyman-${VERSION}.apk \ + build:sample1 Samples/KMSample1/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ + build:sample2 Samples/KMSample2/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ + build:keyboardharness Tests/KeyboardHarness/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ + build:fv ../oem/firstvoices/android/app/build/outputs/apk/$CONFIG/firstvoices-${VERSION}.apk + + if builder_has_option --upload-sentry; then SENTRY_FLAG="--upload-sentry" fi @@ -83,13 +94,6 @@ if builder_start_action clean; then builder_finish_action success clean fi -# Building Keyman Engine for Android -if builder_start_action build:engine; then - cd "$KEYMAN_ROOT/android/KMEA" - ./build.sh build:engine $CI_FLAG $DEBUG_FLAG - builder_finish_action success build:engine -fi - # Building Keyman for Android if builder_start_action build:app; then cd "$KEYMAN_ROOT/android/KMAPro" @@ -134,8 +138,9 @@ if builder_start_action publish:app; then builder_finish_action success publish:app fi +# Publish FirstVoices for Android to Play Store if builder_start_action publish:fv; then - echo "publishing OEM FirstVoices app" + echo "publishing OEM FirstVoices Android app" cd "$KEYMAN_ROOT/android" ./build-publish.sh -no-daemon -fv From 9c7f9124a8e905df1a67ac60cbb746a2edf57fd8 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 07:43:48 +0700 Subject: [PATCH 39/59] fix(android): KMPro output --- android/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.sh b/android/build.sh index 0288e76bb5..d7bdb1fe4a 100755 --- a/android/build.sh +++ b/android/build.sh @@ -51,7 +51,7 @@ fi builder_describe_outputs \ build:engine KMEA/app/build/outputs/aar/$CONFIG/keyman-engine.aar \ - build:app KMAPro/kMAPro/build/outputs/$CONFIG/keyman-${VERSION}.apk \ + build:app KMAPro/kMAPro/build/outputs/apk/$CONFIG/keyman-${VERSION}.apk \ build:sample1 Samples/KMSample1/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ build:sample2 Samples/KMSample2/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ build:keyboardharness Tests/KeyboardHarness/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ From f70044029c0aaeff0cfa4121cf94fb24843aae53 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 08:41:55 +0700 Subject: [PATCH 40/59] fix(android): Configure path --- android/KMAPro/build.sh | 2 +- android/Samples/KMSample1/build.sh | 2 +- android/Samples/KMSample2/build.sh | 2 +- android/Tests/KeyboardHarness/build.sh | 2 +- oem/firstvoices/android/build.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 2b95a81e12..679035b3e4 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -100,7 +100,7 @@ fi if builder_start_action configure; then # Copy Keyman Engine for Android - cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar" + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar" KEYBOARD_PACKAGE_ID="sil_euro_latin" KEYBOARDS_TARGET="$KEYMAN_ROOT/android/KMAPro/kMAPro/src/main/assets/${KEYBOARD_PACKAGE_ID}.kmp" diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index c2c6935f37..02c0d5930c 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -79,7 +79,7 @@ fi if builder_start_action configure; then # Copy Keyman Engine for Android - cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample1/app/libs/keyman-engine.aar" + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIGURE}/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample1/app/libs/keyman-engine.aar" builder_finish_action success configure fi diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index 4636eabfba..e5c12f4083 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -79,7 +79,7 @@ fi if builder_start_action configure; then # Copy Keyman Engine for Android - cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample2/app/libs/keyman-engine.aar" + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample2/app/libs/keyman-engine.aar" builder_finish_action success configure fi diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index d0f6794a70..ff7fa83c59 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -85,7 +85,7 @@ fi if builder_start_action configure; then # Copy Keyman Engine for Android - cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/libs/keyman-engine.aar" + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/libs/keyman-engine.aar" builder_finish_action success configure fi diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 8c51ecdc56..88c2914e76 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -90,7 +90,7 @@ fi if builder_start_action configure; then # Copy Keyman Engine for Android - cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine.aar" "$KEYMAN_ROOT/oem/firstvoices/android/app/libs/keyman-engine.aar" + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/oem/firstvoices/android/app/libs/keyman-engine.aar" KEYBOARDS_CSV="$KEYMAN_ROOT/oem/firstvoices/keyboards.csv" KEYBOARDS_CSV_TARGET="$KEYMAN_ROOT/oem/firstvoices/android/app/src/main/assets/keyboards.csv" From 50c745933eb310e15bb91fed598efc3c8bf34f90 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 09:44:27 +0700 Subject: [PATCH 41/59] fix(android/app): Try to fix configure step --- android/KMAPro/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 679035b3e4..08da00b85f 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -99,6 +99,8 @@ if builder_start_action clean; then fi if builder_start_action configure; then + cd "$KEYMAN_ROOT/android/KMAPro/" + # Copy Keyman Engine for Android cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar" From e8edd5badbd7d13761917aa77cd134b11fa3435b Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 10:01:00 +0700 Subject: [PATCH 42/59] fix(android/app): Debug URL_ DOWNLOAD_FILE --- resources/build/build-download-resources.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/build/build-download-resources.sh b/resources/build/build-download-resources.sh index 07cfbfc697..cfe14f6a33 100755 --- a/resources/build/build-download-resources.sh +++ b/resources/build/build-download-resources.sh @@ -32,6 +32,7 @@ function downloadKeyboardPackage() { echo "Downloading ${ID}.kmp from downloads.keyman.com" local URL_DOWNLOAD_FILE=`curl -s "$URL_API_KEYBOARD_VERSION/${ID}" | "$JQ" -r .kmp` + echo "URL_DOWNLOAD_FILE: ${URL_DOWNLOAD_FILE}; jq version: $(jq --version)" curl -f -s "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { builder_die "Downloading $KEYBOARDS_TARGET failed with error $?" } From b0678c8a3193eeca45d31c798c49e96fc88f15cc Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 13:36:52 +0700 Subject: [PATCH 43/59] fix(android): More troubleshooting on downloading keyboard --- resources/build/build-download-resources.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/build/build-download-resources.sh b/resources/build/build-download-resources.sh index cfe14f6a33..a01b2d4552 100755 --- a/resources/build/build-download-resources.sh +++ b/resources/build/build-download-resources.sh @@ -32,7 +32,8 @@ function downloadKeyboardPackage() { echo "Downloading ${ID}.kmp from downloads.keyman.com" local URL_DOWNLOAD_FILE=`curl -s "$URL_API_KEYBOARD_VERSION/${ID}" | "$JQ" -r .kmp` - echo "URL_DOWNLOAD_FILE: ${URL_DOWNLOAD_FILE}; jq version: $(jq --version)" + echo "URL_DOWNLOAD_FILE: ${URL_DOWNLOAD_FILE}" + set -x curl -f -s "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { builder_die "Downloading $KEYBOARDS_TARGET failed with error $?" } From fa22fd794fdf101677f5e835b33807f0e2f0a30f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 13:41:24 +0700 Subject: [PATCH 44/59] fix(common): Don't set curl silent --- resources/build/build-download-resources.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/build/build-download-resources.sh b/resources/build/build-download-resources.sh index a01b2d4552..dcdb55d3d1 100755 --- a/resources/build/build-download-resources.sh +++ b/resources/build/build-download-resources.sh @@ -34,7 +34,7 @@ function downloadKeyboardPackage() { local URL_DOWNLOAD_FILE=`curl -s "$URL_API_KEYBOARD_VERSION/${ID}" | "$JQ" -r .kmp` echo "URL_DOWNLOAD_FILE: ${URL_DOWNLOAD_FILE}" set -x - curl -f -s "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { + curl -f "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { builder_die "Downloading $KEYBOARDS_TARGET failed with error $?" } } From 501ddf4b87f2080a8b2f307f5f9cbfc3ebe34f66 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 14:08:32 +0700 Subject: [PATCH 45/59] fix(android): Check if keyboard dir is writable --- resources/build/build-download-resources.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/build/build-download-resources.sh b/resources/build/build-download-resources.sh index dcdb55d3d1..f511534691 100755 --- a/resources/build/build-download-resources.sh +++ b/resources/build/build-download-resources.sh @@ -34,6 +34,13 @@ function downloadKeyboardPackage() { local URL_DOWNLOAD_FILE=`curl -s "$URL_API_KEYBOARD_VERSION/${ID}" | "$JQ" -r .kmp` echo "URL_DOWNLOAD_FILE: ${URL_DOWNLOAD_FILE}" set -x + + local KEYBOARDS_DIR=$(dirname $KEYBOARDS_TARGET) + + if [ ! -w $KEYBOARDS_DIR ]; then + echo "Unable to write to $KEYBOARRDS_DIR" + fi + curl -f "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { builder_die "Downloading $KEYBOARDS_TARGET failed with error $?" } From c4e28c740edda873386ef5816ddc275d6b9b32ca Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 15:17:45 +0700 Subject: [PATCH 46/59] fix(android): Try splitting curl filename --- resources/build/build-download-resources.sh | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/resources/build/build-download-resources.sh b/resources/build/build-download-resources.sh index f511534691..8cd32df08b 100755 --- a/resources/build/build-download-resources.sh +++ b/resources/build/build-download-resources.sh @@ -32,16 +32,13 @@ function downloadKeyboardPackage() { echo "Downloading ${ID}.kmp from downloads.keyman.com" local URL_DOWNLOAD_FILE=`curl -s "$URL_API_KEYBOARD_VERSION/${ID}" | "$JQ" -r .kmp` - echo "URL_DOWNLOAD_FILE: ${URL_DOWNLOAD_FILE}" - set -x + + # Test curl limitation, split KEYBOARDS_TARGET to DIR and FILENAME + local KEYBOARDS_TARGET_DIR=$(dirname $KEYBOARDS_TARGET) + local KEYBOARDS_TARGET_FILE=$(basename $KEYBOARDS_TARGET) - local KEYBOARDS_DIR=$(dirname $KEYBOARDS_TARGET) - - if [ ! -w $KEYBOARDS_DIR ]; then - echo "Unable to write to $KEYBOARRDS_DIR" - fi - - curl -f "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { + cd "$KEYBOARDS_TARGET_DIR" + curl -f "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET_FILE" || { builder_die "Downloading $KEYBOARDS_TARGET failed with error $?" } } @@ -60,7 +57,14 @@ function downloadModelPackage() { echo "Downloading ${ID}.model.kmp from downloads.keyman.com" local URL_DOWNLOAD_FILE=`curl -s "$URL_API_MODEL_VERSION/${ID}" | "$JQ" -r .kmp` - curl -f -s "$URL_DOWNLOAD_FILE" -o "$MODELS_TARGET" || { + + # Test curl limitation, split MODELS_TARGET to DIR and FILENAME + local MODELS_TARGET_DIR=$(dirname $MODELS_TARGET) + local MODELS_TARGET_FILE=$(basename $MODELS_TARGET) + + cd "$MODELS_TARGET_DIR" + + curl -f -s "$URL_DOWNLOAD_FILE" -o "$MODELS_TARGET_FILE" || { builder_die "Downloading $MODELS_TARGET failed with error $?" } } From 5144e263a0f6b61c8d4c0c1a44df2ba642dc3ba2 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 28 Feb 2023 15:24:50 +0700 Subject: [PATCH 47/59] fix(android): tweak basename --- resources/build/build-download-resources.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/build/build-download-resources.sh b/resources/build/build-download-resources.sh index 8cd32df08b..f289a69c29 100755 --- a/resources/build/build-download-resources.sh +++ b/resources/build/build-download-resources.sh @@ -35,7 +35,7 @@ function downloadKeyboardPackage() { # Test curl limitation, split KEYBOARDS_TARGET to DIR and FILENAME local KEYBOARDS_TARGET_DIR=$(dirname $KEYBOARDS_TARGET) - local KEYBOARDS_TARGET_FILE=$(basename $KEYBOARDS_TARGET) + local KEYBOARDS_TARGET_FILE=$(basename -- $KEYBOARDS_TARGET) cd "$KEYBOARDS_TARGET_DIR" curl -f "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET_FILE" || { @@ -60,7 +60,7 @@ function downloadModelPackage() { # Test curl limitation, split MODELS_TARGET to DIR and FILENAME local MODELS_TARGET_DIR=$(dirname $MODELS_TARGET) - local MODELS_TARGET_FILE=$(basename $MODELS_TARGET) + local MODELS_TARGET_FILE=$(basename -- $MODELS_TARGET) cd "$MODELS_TARGET_DIR" From 449801e3a800ba4f36ce2a95e11278673da2de5c Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Wed, 1 Mar 2023 21:44:59 +0700 Subject: [PATCH 48/59] fix(android/app): Add gitkeep to assets --- android/KMAPro/kMAPro/src/main/assets/.gitkeep | 0 resources/build/build-download-resources.sh | 17 ++--------------- 2 files changed, 2 insertions(+), 15 deletions(-) create mode 100644 android/KMAPro/kMAPro/src/main/assets/.gitkeep diff --git a/android/KMAPro/kMAPro/src/main/assets/.gitkeep b/android/KMAPro/kMAPro/src/main/assets/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/resources/build/build-download-resources.sh b/resources/build/build-download-resources.sh index f289a69c29..ca9b720f14 100755 --- a/resources/build/build-download-resources.sh +++ b/resources/build/build-download-resources.sh @@ -32,13 +32,7 @@ function downloadKeyboardPackage() { echo "Downloading ${ID}.kmp from downloads.keyman.com" local URL_DOWNLOAD_FILE=`curl -s "$URL_API_KEYBOARD_VERSION/${ID}" | "$JQ" -r .kmp` - - # Test curl limitation, split KEYBOARDS_TARGET to DIR and FILENAME - local KEYBOARDS_TARGET_DIR=$(dirname $KEYBOARDS_TARGET) - local KEYBOARDS_TARGET_FILE=$(basename -- $KEYBOARDS_TARGET) - - cd "$KEYBOARDS_TARGET_DIR" - curl -f "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET_FILE" || { + curl -f "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { builder_die "Downloading $KEYBOARDS_TARGET failed with error $?" } } @@ -57,14 +51,7 @@ function downloadModelPackage() { echo "Downloading ${ID}.model.kmp from downloads.keyman.com" local URL_DOWNLOAD_FILE=`curl -s "$URL_API_MODEL_VERSION/${ID}" | "$JQ" -r .kmp` - - # Test curl limitation, split MODELS_TARGET to DIR and FILENAME - local MODELS_TARGET_DIR=$(dirname $MODELS_TARGET) - local MODELS_TARGET_FILE=$(basename -- $MODELS_TARGET) - - cd "$MODELS_TARGET_DIR" - - curl -f -s "$URL_DOWNLOAD_FILE" -o "$MODELS_TARGET_FILE" || { + curl -f -s "$URL_DOWNLOAD_FILE" -o "$MODELS_TARGET" || { builder_die "Downloading $MODELS_TARGET failed with error $?" } } From 44010668bc3ad1ee181d06915b2573b1c4b3eefe Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Wed, 1 Mar 2023 21:46:15 +0700 Subject: [PATCH 49/59] fix(common/resources): Revert build-download-resources --- resources/build/build-download-resources.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/build/build-download-resources.sh b/resources/build/build-download-resources.sh index ca9b720f14..07cfbfc697 100755 --- a/resources/build/build-download-resources.sh +++ b/resources/build/build-download-resources.sh @@ -32,7 +32,7 @@ function downloadKeyboardPackage() { echo "Downloading ${ID}.kmp from downloads.keyman.com" local URL_DOWNLOAD_FILE=`curl -s "$URL_API_KEYBOARD_VERSION/${ID}" | "$JQ" -r .kmp` - curl -f "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { + curl -f -s "$URL_DOWNLOAD_FILE" -o "$KEYBOARDS_TARGET" || { builder_die "Downloading $KEYBOARDS_TARGET failed with error $?" } } From 8e140a34a017b920deff394a10c2274091e43825 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 2 Mar 2023 09:15:35 +0700 Subject: [PATCH 50/59] fix(android/samples): CONFIG typo --- android/Samples/KMSample1/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 02c0d5930c..436a7675cb 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -79,7 +79,7 @@ fi if builder_start_action configure; then # Copy Keyman Engine for Android - cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIGURE}/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample1/app/libs/keyman-engine.aar" + cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample1/app/libs/keyman-engine.aar" builder_finish_action success configure fi From 5265058be1b84e33fde8d49e4c4cd955bc10bde6 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Thu, 2 Mar 2023 11:18:56 +0700 Subject: [PATCH 51/59] refactor(android): Fix test actions --- android/build.sh | 21 +++++++++++++++++++++ oem/firstvoices/android/build.sh | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/android/build.sh b/android/build.sh index d7bdb1fe4a..041f721a43 100755 --- a/android/build.sh +++ b/android/build.sh @@ -23,6 +23,7 @@ builder_describe \ "Build Keyman Engine for Android, Keyman for Android, and FirstVoices Android app." \ clean \ build \ + test \ "publish Publishes the APKs to the Play Store." \ ":engine=KMEA Keyman Engine for Android" \ ":app=KMAPro Keyman for Android" \ @@ -129,6 +130,26 @@ if builder_start_action build:fv; then builder_finish_action success build:fv fi +#### Tests ##### +if builder_start_action test:engine; then + cd "$KEYMAN_ROOT/android/KMEA" + ./build.sh test $CI_FLAG $DEBUG_FLAG + builder_finish_action success test:engine +fi + +if builder_start_action test:app; then + cd "$KEYMAN_ROOT/android/KMAPro" + ./build.sh test $CI_FLAG $DEBUG_FLAG + builder_finish_action success test:app +fi + +if builder_start_action test:fv; then + cd "$KEYMAN_ROOT/oem/firstvoices/android" + ./build.sh test $CI_FLAG $DEBUG_FLAG + builder_finish_action success test:fv +fi + + # Publish Keyman for Android to Play Store if builder_start_action publish:app; then echo "publishing Keyman for Android" diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 88c2914e76..b8c3ac52fe 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -115,5 +115,5 @@ if builder_start_action test; then echo "TEST_FLAGS: $TEST_FLAGS" ./gradlew $DAEMON_FLAG $TEST_FLAGS - builder_finish_action_success test + builder_finish_action success test fi From 6ab7068e0c524fee0161cc92d61fe86a8334638a Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 3 Mar 2023 07:57:42 +0700 Subject: [PATCH 52/59] Apply suggestions from code review Co-authored-by: Marc Durdin --- android/KMAPro/build.sh | 18 +++----------- android/KMEA/build.sh | 34 +++++++++----------------- android/README.md | 8 +++--- android/Samples/KMSample1/build.sh | 14 +---------- android/Samples/KMSample2/build.sh | 18 ++------------ android/Tests/KeyboardHarness/build.sh | 14 +---------- android/build.sh | 23 ++++++++--------- oem/firstvoices/android/build.sh | 18 +++----------- 8 files changed, 36 insertions(+), 111 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 08da00b85f..ca15240465 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -47,20 +47,16 @@ fi builder_describe_outputs \ configure kMAPro/libs/keyman-engine.aar \ - build:app kMAPro/build/outputs/apk/$CONFIG/keyman-${VERSION}.apk + build kMAPro/build/outputs/apk/$CONFIG/keyman-${VERSION}.apk #### Build -function _convert_markdown_to_html() { +function convert_markdown_to_html() { echo "Converting markdown to html for offline help" cd "$KEYMAN_ROOT/android" ./build-help.sh htm } -# -# Prevents 'clear' on exit of mingw64 bash shell -# -SHLVL=0 # Parse args @@ -85,21 +81,15 @@ function makeLocalSentryRelease() { # Check about cleaning artifact paths and upload directories if builder_start_action clean; then - cd "$KEYMAN_ROOT/android/KMAPro/" - if [ -d "$KEYMAN_ROOT/android/KMAPro/kMAPro/build/outputs" ]; then - rm -rf "$KEYMAN_ROOT/android/KMAPro/kMAPro/build/outputs" - fi + rm -rf "$KEYMAN_ROOT/android/KMAPro/kMAPro/build/outputs" - if [ -d "$KEYMAN_ROOT/android/upload" ]; then - rm -rf "$KEYMAN_ROOT/android/upload" - fi + rm -rf "$KEYMAN_ROOT/android/upload" builder_finish_action success clean fi if builder_start_action configure; then - cd "$KEYMAN_ROOT/android/KMAPro/" # Copy Keyman Engine for Android cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar" diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 0179ee0801..9f1818a919 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -29,7 +29,7 @@ TEST_FLAGS="-x aR lintRelease testRelease" # Gradle test w/o build JUNIT_RESULTS="##teamcity[importData type='junit' path='keyman\android\KMEA\app\build\test-results\testReleaseUnitTest\']" builder_describe "Builds Keyman Engine for Android." \ - "@../../web" \ + "@/web" \ "clean" \ "configure" \ "build" \ @@ -53,10 +53,6 @@ builder_describe_outputs \ #### Build -# -# Prevents 'clear' on exit of mingw64 bash shell -# -SHLVL=0 # Parse args @@ -69,15 +65,9 @@ fi # Check about cleaning arifact paths and upload directories if builder_start_action clean:engine; then - cd "$KEYMAN_ROOT/android/KMEA/" - if [ -d "$KEYMAN_ROOT/android/KMEA/app/build/outputs" ]; then - rm -rf "$KEYMAN_ROOT/android/KMEA/app/build/outputs" - fi - - if [ -d "$KEYMAN_ROOT/android/upload" ]; then - rm -rf "$KEYMAN_ROOT/android/upload" - fi + rm -rf "$KEYMAN_ROOT/android/KMEA/app/build/outputs" + rm -rf "$KEYMAN_ROOT/android/upload" builder_finish_action success clean:engine fi @@ -86,17 +76,17 @@ if builder_start_action configure; then # Copy KeymanWeb artifacts echo "Copying Keyman Web artifacts" - cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/ajax-loader.gif $ENGINE_ASSETS/ajax-loader.gif - cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/keyman.js $ENGINE_ASSETS/keymanandroid.js - cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/keyman.js.map $ENGINE_ASSETS/keyman.js.map - cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/kmwosk.css $ENGINE_ASSETS/kmwosk.css - cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/globe-hint.css $ENGINE_ASSETS/globe-hint.css - cp $KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/keymanweb-osk.ttf $ENGINE_ASSETS/keymanweb-osk.ttf + cp "$KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/ajax-loader.gif" "$ENGINE_ASSETS/ajax-loader.gif" + cp "$KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/keyman.js" "$ENGINE_ASSETS/keymanandroid.js" + cp "$KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/keyman.js.map" "$ENGINE_ASSETS/keyman.js.map" + cp "$KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/kmwosk.css" "$ENGINE_ASSETS/kmwosk.css" + cp "$KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/globe-hint.css" "$ENGINE_ASSETS/globe-hint.css" + cp "$KEYMAN_WEB_ROOT/build/app/embed/$CONFIG/osk/keymanweb-osk.ttf" "$ENGINE_ASSETS/keymanweb-osk.ttf" - cp $KEYMAN_ROOT/common/web/sentry-manager/build/index.js $ENGINE_ASSETS/keyman-sentry.js + cp "$KEYMAN_ROOT/common/web/sentry-manager/build/index.js" "$ENGINE_ASSETS/keyman-sentry.js" echo "Copying es6-shim polyfill" - cp $KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js $ENGINE_ASSETS/es6-shim.min.js + cp "$KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js" "$ENGINE_ASSETS/es6-shim.min.js" builder_finish_action success configure fi @@ -105,7 +95,6 @@ fi if builder_start_action build:engine; then - cd "$KEYMAN_ANDROID_ROOT/KMEA" echo "BUILD_FLAGS $BUILD_FLAGS" # Build without test @@ -115,7 +104,6 @@ if builder_start_action build:engine; then fi if builder_start_action test:engine; then - cd "$KEYMAN_ANDROID_ROOT/KMEA" if builder_has_option --ci; then # Report JUnit test results to CI diff --git a/android/README.md b/android/README.md index c090df51d9..a75c769e56 100644 --- a/android/README.md +++ b/android/README.md @@ -21,7 +21,7 @@ Keyman for Android uses [Sentry](https://sentry.io) for crash reporting at a ser ### Compiling From Command Line 1. Launch a command prompt and cd to the directory **keyman/android** -2. Run the top level build script `./build.sh build:engine build:app --debug` which will: +2. Run the top level build script `./build.sh configure build --debug` which will: * Compile KMEA (and its KMW dependency) * Download default keyboard and dictionary resources as needed * Compile KMAPro @@ -80,7 +80,7 @@ Both sample apps include a default Tamil keyboard and sample dictionary. Building these projects follow the same steps as KMAPro: 1. cd to the desired KMSample directory -2. `./build.sh build:engine build:app` +2. `./build.sh` 3. Open Android Studio to run the app ### Tests: KeyboardHarness @@ -93,14 +93,14 @@ Building these projects follow the same steps as KMAPro: * Build the keyboardharness.kmp keyboard package 3. Add the keyboard in *android/Tests/KeyboardHarness/app/src/main/java/com/keyman/android/tests/keyboardHarness/MainActivity.java* 4. cd to android/Tests/KeyboardHarness/ -5. `./build.sh build:engine build:app` +5. `./build.sh` 6. Open Android Studio to run the app -------------------------------------------------------------- ## How to Build Keyman Engine for Android 1. Open a terminal or Git Bash prompt and go to the Android project folder (e.g. `cd ~/keyman/android/`) -2. Run `./build.sh build:engine --debug` +2. Run `./build.sh --debug` Keyman Engine for Android library (**keyman-engine.aar**) is now ready to be imported in any project. diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 436a7675cb..1dab078171 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -48,10 +48,6 @@ builder_describe_outputs \ configure app/libs/keyman-engine.aar \ build:app app/build/outputs/apk/$CONFIG/$ARTIFACT -# -# Prevents 'clear' on exit of mingw64 bash shell -# -SHLVL=0 # Parse args @@ -64,15 +60,8 @@ fi # Check about cleaning artifact paths and upload directories if builder_start_action clean; then - cd "$KEYMAN_ROOT/android/Samples/KMSample1/" - if [ -d "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" ]; then - rm -rf "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" - fi - - if [ -d "$KEYMAN_ROOT/android/upload" ]; then - rm -rf "$KEYMAN_ROOT/android/upload" - fi + rm -rf "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" builder_finish_action success clean fi @@ -86,7 +75,6 @@ fi # Building KMSample1 if builder_start_action build:app; then - cd "$KEYMAN_ROOT/android/Samples/KMSample1" ./gradlew clean $SAMPLE_FLAGS diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index e5c12f4083..01e4ac59d6 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -29,7 +29,7 @@ builder_describe "Build KMSample2 app for Android." \ "clean" \ "configure" \ "build" \ - ":app KMSample1" \ + ":app KMSample2" \ "--ci Don't start the Gradle daemon. Use for CI" # parse before describe_outputs to check debug flags @@ -48,10 +48,6 @@ builder_describe_outputs \ configure app/libs/keyman-engine.aar \ build:app app/build/outputs/apk/$CONFIG/$ARTIFACT -# -# Prevents 'clear' on exit of mingw64 bash shell -# -SHLVL=0 # Parse args @@ -64,16 +60,7 @@ fi # Check about cleaning artifact paths and upload directories if builder_start_action clean; then - cd "$KEYMAN_ROOT/android/Samples/KMSample2/" - - if [ -d "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" ]; then - rm -rf "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" - fi - - if [ -d "$KEYMAN_ROOT/android/upload" ]; then - rm -rf "$KEYMAN_ROOT/android/upload" - fi - + rm -rf "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" builder_finish_action success clean fi @@ -86,7 +73,6 @@ fi # Building KMSample2 if builder_start_action build:app; then - cd "$KEYMAN_ROOT/android/Samples/KMSample2" ./gradlew clean $SAMPLE_FLAGS diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index ff7fa83c59..e94d2a587e 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -68,18 +68,7 @@ fi # Check about cleaning artifact paths and upload directories if builder_start_action clean; then - cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" - - if [ -d "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/build/outputs" ]; then - echo "Cleaning KeyboardHarness build outputs directory" - rm -rf "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/build/outputs" - fi - - if [ -d "$KEYMAN_ROOT/android/upload" ]; then - echo "Cleaning upload directory" - rm -rf "$KEYMAN_ROOT/android/upload" - fi - + rm -rf "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/build/outputs" builder_finish_action success clean fi @@ -92,7 +81,6 @@ fi # Building KeyboardHarness if builder_start_action build:app; then - cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" echo "BUILD_FLAGS: $BUILD_FLAGS" ./gradlew clean $BUILD_FLAGS diff --git a/android/build.sh b/android/build.sh index 041f721a43..eae5263936 100755 --- a/android/build.sh +++ b/android/build.sh @@ -22,13 +22,14 @@ cd "$THIS_SCRIPT_PATH" builder_describe \ "Build Keyman Engine for Android, Keyman for Android, and FirstVoices Android app." \ clean \ + configure \ build \ test \ "publish Publishes the APKs to the Play Store." \ ":engine=KMEA Keyman Engine for Android" \ ":app=KMAPro Keyman for Android" \ - ":sample1=Samples/KMSample1 Sample apps: KMSample1" \ - ":sample2=Samples/KMSample2 Sample app: KMSample2" \ + ":sample1=Samples/KMSample1 Sample app: KMSample1" \ + ":sample2=Samples/KMSample2 Sample app: KMSample2" \ ":keyboardharness=Tests/KeyboardHarness Test app: KeyboardHarness" \ ":fv=../oem/firstvoices/android OEM FirstVoices for Android app" \ "--ci Don't start the Gradle daemon. Use for CI" \ @@ -36,18 +37,18 @@ builder_describe \ builder_parse "$@" -CONFIG="release" -DEBUG_FLAG="" -CI_FLAG="" -SENTRY_FLAG="" +CONFIG=release +DEBUG_FLAG= +CI_FLAG= +SENTRY_FLAG= if builder_has_option --ci; then - CI_FLAG="--ci" + CI_FLAG=--ci fi if builder_has_option --debug; then - CONFIG="debug" - DEBUG_FLAG="--debug" + CONFIG=debug + DEBUG_FLAG=--debug fi builder_describe_outputs \ @@ -63,10 +64,6 @@ if builder_has_option --upload-sentry; then SENTRY_FLAG="--upload-sentry" fi -# -# Prevents 'clear' on exit of mingw64 bash shell -# -SHLVL=0 # Clean build artifacts: keyman-engine.aar libaries, output and upload directories function _clean() { diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index b8c3ac52fe..cb41dd8680 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -27,12 +27,12 @@ TEST_FLAGS="-x assembleRelease lintRelease testRelease" # Gradle test w/o build DAEMON_FLAG= builder_describe "Builds FirstVoices for Android app." \ - "@../../../android/KMEA" \ + "@/android/KMEA" \ "clean" \ "configure" \ "build" \ "test Runs lint and tests." \ - "--ci Don't start the GRadle daemon. For CI" \ + "--ci Don't start the Gradle daemon. For CI" \ "--upload-sentry Upload to sentry" # parse before describe_outputs to check debug flags @@ -53,10 +53,6 @@ builder_describe_outputs \ #### Build -# -# Prevents 'clear' on exit of mingw64 bash shell -# -SHLVL=0 # Parse args @@ -75,15 +71,7 @@ function makeLocalSentryRelease() { # Check about cleaning artifact paths and upload directories if builder_start_action clean; then - cd "$KEYMAN_ROOT/oem/firstvoices/android/" - - if [ -d "$KEYMAN_ROOT/oem/firstvoices/android/app/build/outputs" ]; then - rm -rf "$KEYMAN_ROOT/oem/firstvoices/android/app/build/outputs" - fi - - if [ -d "$KEYMAN_ROOT/android/upload" ]; then - rm -rf "$KEYMAN_ROOT/android/upload" - fi + rm -rf "$KEYMAN_ROOT/oem/firstvoices/android/app/build/outputs" builder_finish_action success clean fi From 749a734e4778ccfd286921f869f844b93dbd5091 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 3 Mar 2023 10:56:11 +0700 Subject: [PATCH 53/59] fix(android/app): Address more review comments * restore directory after `convert_markdown_to_html` --- android/KMAPro/build.sh | 7 +++---- android/build-help.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index ca15240465..1a495029b3 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -53,8 +53,9 @@ builder_describe_outputs \ function convert_markdown_to_html() { echo "Converting markdown to html for offline help" - cd "$KEYMAN_ROOT/android" + pushd "$KEYMAN_ROOT/android" ./build-help.sh htm + popd } @@ -108,9 +109,7 @@ fi if builder_start_action build; then # Convert markdown to html for offline help - _convert_markdown_to_html - - cd "$KEYMAN_ROOT/android/KMAPro" + convert_markdown_to_html echo "BUILD_FLAGS $BUILD_FLAGS" ./gradlew $DAEMON_FLAG clean $BUILD_FLAGS diff --git a/android/build-help.sh b/android/build-help.sh index d6185d4873..8e062ec413 100755 --- a/android/build-help.sh +++ b/android/build-help.sh @@ -69,7 +69,7 @@ displayInfo "" \ # Compile all .md to .html # -cd $KEYMAN_ROOT/android/help +cd "$KEYMAN_ROOT/android/help" MDLUA="$KEYMAN_ROOT/resources/build/html-link.lua" CSS="../../resources/build/offline-help-style-spec.txt" From 5be02f49a129d5c241f8e688cdf703b7982be96f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 3 Mar 2023 11:13:07 +0700 Subject: [PATCH 54/59] fix(oem/fv/android): Build output --- oem/firstvoices/android/build.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index cb41dd8680..3a754b60a5 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -45,16 +45,14 @@ if builder_has_option --debug; then TEST_FLAGS="-x assembleDebug lintDebug testDebug" fi -ARTIFACT="app-$CONFIG.apk" +ARTIFACT="firstvoices-$VERSION.apk" builder_describe_outputs \ configure app/libs/keyman-engine.aar \ - build:app app/build/outputs/apk/$CONFIG/firstvoices${ARTIFACT} + build app/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build - - # Parse args if builder_has_option --ci; then From 55349e32cfc23a10498e895eafafda3c1e025626 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 3 Mar 2023 13:21:16 +0700 Subject: [PATCH 55/59] fix(android): Have top level builder handle cleaning up upload --- android/KMAPro/build.sh | 6 +----- android/KMEA/build.sh | 5 +---- android/Samples/KMSample1/build.sh | 4 +--- android/Samples/KMSample2/build.sh | 2 +- android/Tests/KeyboardHarness/build.sh | 2 +- android/build.sh | 6 +++++- oem/firstvoices/android/build.sh | 3 +-- 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 1a495029b3..17efa71e63 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -80,13 +80,9 @@ function makeLocalSentryRelease() { #### Build action definitions #### -# Check about cleaning artifact paths and upload directories +# Check about cleaning artifact paths if builder_start_action clean; then - rm -rf "$KEYMAN_ROOT/android/KMAPro/kMAPro/build/outputs" - - rm -rf "$KEYMAN_ROOT/android/upload" - builder_finish_action success clean fi diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 9f1818a919..5db931ad8c 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -63,12 +63,9 @@ fi #### Build action definitions #### -# Check about cleaning arifact paths and upload directories +# Check about cleaning arifact paths if builder_start_action clean:engine; then - rm -rf "$KEYMAN_ROOT/android/KMEA/app/build/outputs" - rm -rf "$KEYMAN_ROOT/android/upload" - builder_finish_action success clean:engine fi diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 1dab078171..e3afc53171 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -58,11 +58,9 @@ fi #### Build action definitions #### -# Check about cleaning artifact paths and upload directories +# Check about cleaning artifact paths if builder_start_action clean; then - rm -rf "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" - builder_finish_action success clean fi diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index 01e4ac59d6..878bbb86db 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -58,7 +58,7 @@ fi #### Build action definitions #### -# Check about cleaning artifact paths and upload directories +# Check about cleaning artifact paths if builder_start_action clean; then rm -rf "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" builder_finish_action success clean diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index e94d2a587e..236fc86ec1 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -66,7 +66,7 @@ fi #### Build action definitions #### -# Check about cleaning artifact paths and upload directories +# Check about cleaning artifact paths if builder_start_action clean; then rm -rf "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/build/outputs" builder_finish_action success clean diff --git a/android/build.sh b/android/build.sh index eae5263936..c7a231a80c 100755 --- a/android/build.sh +++ b/android/build.sh @@ -88,7 +88,11 @@ function _clean() { # Check about cleaning artifact paths if builder_start_action clean; then - _clean + _clean # TODO: This gets removed with builder_run_child_actions + + # This script also responsible for cleaning up /android/upload + echo "Cleanup upload" + rm -rf "$KEYMAN_ROOT/android/upload" builder_finish_action success clean fi diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 3a754b60a5..4e1ac285c5 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -67,10 +67,9 @@ function makeLocalSentryRelease() { #### Build action definitions #### -# Check about cleaning artifact paths and upload directories +# Check about cleaning artifact paths if builder_start_action clean; then rm -rf "$KEYMAN_ROOT/oem/firstvoices/android/app/build/outputs" - builder_finish_action success clean fi From 3103c483fd1f551446517cf7a207d4ade7595e20 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 6 Mar 2023 10:24:28 +0700 Subject: [PATCH 56/59] fix(android): Have top level builder --- android/build.sh | 117 ++++------------------------------------------- 1 file changed, 8 insertions(+), 109 deletions(-) diff --git a/android/build.sh b/android/build.sh index c7a231a80c..f14860f8ef 100755 --- a/android/build.sh +++ b/android/build.sh @@ -31,9 +31,7 @@ builder_describe \ ":sample1=Samples/KMSample1 Sample app: KMSample1" \ ":sample2=Samples/KMSample2 Sample app: KMSample2" \ ":keyboardharness=Tests/KeyboardHarness Test app: KeyboardHarness" \ - ":fv=../oem/firstvoices/android OEM FirstVoices for Android app" \ - "--ci Don't start the Gradle daemon. Use for CI" \ - "--upload-sentry Uploads debug symbols, etc, to Sentry" + ":fv=../oem/firstvoices/android OEM FirstVoices for Android app" builder_parse "$@" @@ -51,120 +49,21 @@ if builder_has_option --debug; then DEBUG_FLAG=--debug fi -builder_describe_outputs \ - build:engine KMEA/app/build/outputs/aar/$CONFIG/keyman-engine.aar \ - build:app KMAPro/kMAPro/build/outputs/apk/$CONFIG/keyman-${VERSION}.apk \ - build:sample1 Samples/KMSample1/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ - build:sample2 Samples/KMSample2/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ - build:keyboardharness Tests/KeyboardHarness/app/build/outputs/apk/${CONFIG}/app-${CONFIG}.apk \ - build:fv ../oem/firstvoices/android/app/build/outputs/apk/$CONFIG/firstvoices-${VERSION}.apk - +builder_run_child_actions clean configure build test publish if builder_has_option --upload-sentry; then SENTRY_FLAG="--upload-sentry" fi +# TODO: +# builder_declare_inheritable_parameters \ +# "--ci Don't start the Gradle daemon. Use for CI" \ +# "--upload-sentry Uploads debug symbols, etc, to Sentry" -# Clean build artifacts: keyman-engine.aar libaries, output and upload directories -function _clean() { - cd "$KEYMAN_ROOT/android/KMEA" - ./build.sh clean - - cd "$KEYMAN_ROOT/android/KMAPro" - ./build.sh clean - - cd "$KEYMAN_ROOT/android/Samples/KMSample1" - ./build.sh clean - - cd "$KEYMAN_ROOT/android/Samples/KMSample2" - ./build.sh clean - - cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" - ./build.sh clean - - cd "$KEYMAN_ROOT/oem/firstvoices/android" - ./build.sh clean -} - -# Check about cleaning artifact paths +# This script also responsible for cleaning up /android/upload if builder_start_action clean; then - _clean # TODO: This gets removed with builder_run_child_actions - # This script also responsible for cleaning up /android/upload - echo "Cleanup upload" + builder_heading "Cleanup /android/upload" rm -rf "$KEYMAN_ROOT/android/upload" builder_finish_action success clean fi - -# Building Keyman for Android -if builder_start_action build:app; then - cd "$KEYMAN_ROOT/android/KMAPro" - ./build.sh build $CI_FLAG $DEBUG_FLAG $SENTRY_FLAG - builder_finish_action success build:app -fi - -# Building KMSample1 app -if builder_start_action build:sample1; then - cd "$KEYMAN_ROOT/android/Samples/KMSample1" - ./build.sh build $CI_FLAG $DEBUG_FLAG - builder_finish_action success build:sample1 -fi - -# Building KMSample2 app -if builder_start_action build:sample2; then - cd "$KEYMAN_ROOT/android/Samples/KMSample2" - ./build.sh build $CI_FLAG $DEBUG_FLAG - builder_finish_action success build:sample2 -fi - -# Building KeyboardHarness app -if builder_start_action build:keyboardharness; then - cd "$KEYMAN_ROOT/android/Tests/KeyboardHarness" - ./build.sh build $CI_FLAG $DEBUG_FLAG - builder_finish_action success build:keyboardharness -fi - -# Building OEM app -if builder_start_action build:fv; then - cd "$KEYMAN_ROOT/oem/firstvoices/android" - ./build.sh build $CI_FLAG $DEBUG_FLAG - builder_finish_action success build:fv -fi - -#### Tests ##### -if builder_start_action test:engine; then - cd "$KEYMAN_ROOT/android/KMEA" - ./build.sh test $CI_FLAG $DEBUG_FLAG - builder_finish_action success test:engine -fi - -if builder_start_action test:app; then - cd "$KEYMAN_ROOT/android/KMAPro" - ./build.sh test $CI_FLAG $DEBUG_FLAG - builder_finish_action success test:app -fi - -if builder_start_action test:fv; then - cd "$KEYMAN_ROOT/oem/firstvoices/android" - ./build.sh test $CI_FLAG $DEBUG_FLAG - builder_finish_action success test:fv -fi - - -# Publish Keyman for Android to Play Store -if builder_start_action publish:app; then - echo "publishing Keyman for Android" - - cd "$KEYMAN_ROOT/android" - ./build-publish.sh -no-daemon -kmapro - builder_finish_action success publish:app -fi - -# Publish FirstVoices for Android to Play Store -if builder_start_action publish:fv; then - echo "publishing OEM FirstVoices Android app" - - cd "$KEYMAN_ROOT/android" - ./build-publish.sh -no-daemon -fv - builder_finish_action success publish:fv -fi From 78adb337a1f1d5bc8341c1259d3860e60edb2472 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Wed, 8 Mar 2023 09:57:36 +0700 Subject: [PATCH 57/59] refactor(android): Use builder_is_debug_build --- android/KMAPro/build.sh | 2 +- android/KMEA/build.sh | 2 +- android/Samples/KMSample1/build.sh | 4 ++-- android/Samples/KMSample2/build.sh | 4 ++-- android/Tests/KeyboardHarness/build.sh | 4 ++-- android/build.sh | 4 +--- oem/firstvoices/android/build.sh | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 17efa71e63..8c2109f548 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -38,7 +38,7 @@ builder_describe "Builds Keyman for Android app." \ # parse before describe_outputs to check debug flags builder_parse "$@" -if builder_has_option --debug; then +if builder_is_debug_build; then builder_heading "### Debug config ####" CONFIG="debug" BUILD_FLAGS="assembleDebug -x lint -x test" diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index 5db931ad8c..ed9744c0fb 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -40,7 +40,7 @@ builder_describe "Builds Keyman Engine for Android." \ # parse before describe_outputs to check debug flags builder_parse "$@" -if builder_has_option --debug; then +if builder_is_debug_build; then builder_heading "### Debug config ####" CONFIG="debug" BUILD_FLAGS="assembleDebug -x lint -x test" diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index e3afc53171..36125d0cbf 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -30,12 +30,12 @@ builder_describe "Build KMSample1 app for Android." \ "configure" \ "build" \ ":app KMSample1" \ - "--ci Don't start the Gradle daemon. Use for CI" + "--ci Don't start the Gradle daemon. Use for CI" # parse before describe_outputs to check debug flags builder_parse "$@" -if builder_has_option --debug; then +if builder_is_debug_build; then builder_heading "### Debug config ####" CONFIG="debug" SAMPLE_FLAGS="assembleDebug" diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index 878bbb86db..abde8cdf84 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -30,12 +30,12 @@ builder_describe "Build KMSample2 app for Android." \ "configure" \ "build" \ ":app KMSample2" \ - "--ci Don't start the Gradle daemon. Use for CI" + "--ci Don't start the Gradle daemon. Use for CI" # parse before describe_outputs to check debug flags builder_parse "$@" -if builder_has_option --debug; then +if builder_is_debug_build; then builder_heading "### Debug config ####" CONFIG="debug" SAMPLE_FLAGS="assembleDebug" diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index 236fc86ec1..1d97fbba31 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -29,12 +29,12 @@ builder_describe "Build KeyboardHarness test app for Android." \ "configure" \ "build" \ ":app KeyboardHarness" \ - "--ci Don't start the Gradle daemon. Use for CI" + "--ci Don't start the Gradle daemon. Use for CI" # parse before describe outputs to check debug flags builder_parse "$@" -if builder_has_option --debug; then +if builder_is_debug_build; then builder_heading "### Debug config ####" CONFIG="debug" BUILD_FLAGS="assembleDebug -x lint -x test" diff --git a/android/build.sh b/android/build.sh index f14860f8ef..e4245a20c1 100755 --- a/android/build.sh +++ b/android/build.sh @@ -36,7 +36,6 @@ builder_describe \ builder_parse "$@" CONFIG=release -DEBUG_FLAG= CI_FLAG= SENTRY_FLAG= @@ -44,9 +43,8 @@ if builder_has_option --ci; then CI_FLAG=--ci fi -if builder_has_option --debug; then +if builder_is_debug_build; then CONFIG=debug - DEBUG_FLAG=--debug fi builder_run_child_actions clean configure build test publish diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 4e1ac285c5..2d7bf31f3e 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -38,7 +38,7 @@ builder_describe "Builds FirstVoices for Android app." \ # parse before describe_outputs to check debug flags builder_parse "$@" -if builder_has_option --debug; then +if builder_is_debug_build; then builder_heading "### Debug config ####" CONFIG="debug" BUILD_FLAGS="assembleDebug -x lint -x test" From ec5f2d8f7e9945aa64e5da765b2568ef8e6f12c9 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 10 Mar 2023 13:18:33 +0700 Subject: [PATCH 58/59] refactor(android): Add inheritable options --- android/build.sh | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/android/build.sh b/android/build.sh index e4245a20c1..eae19089e5 100755 --- a/android/build.sh +++ b/android/build.sh @@ -26,6 +26,8 @@ builder_describe \ build \ test \ "publish Publishes the APKs to the Play Store." \ + --ci+ \ + --upload-sentry+ \ ":engine=KMEA Keyman Engine for Android" \ ":app=KMAPro Keyman for Android" \ ":sample1=Samples/KMSample1 Sample app: KMSample1" \ @@ -35,33 +37,13 @@ builder_describe \ builder_parse "$@" -CONFIG=release -CI_FLAG= -SENTRY_FLAG= - -if builder_has_option --ci; then - CI_FLAG=--ci -fi - -if builder_is_debug_build; then - CONFIG=debug -fi - -builder_run_child_actions clean configure build test publish - -if builder_has_option --upload-sentry; then - SENTRY_FLAG="--upload-sentry" -fi - -# TODO: -# builder_declare_inheritable_parameters \ -# "--ci Don't start the Gradle daemon. Use for CI" \ -# "--upload-sentry Uploads debug symbols, etc, to Sentry" - # This script also responsible for cleaning up /android/upload -if builder_start_action clean; then +builder_run_child_actions clean +if builder_start_action clean; then builder_heading "Cleanup /android/upload" rm -rf "$KEYMAN_ROOT/android/upload" builder_finish_action success clean fi + +builder_run_child_actions configure build test publish From 1a8d047ba1326fc60405082493a6ac4b4a3ed1be Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Mon, 13 Mar 2023 11:13:14 +0700 Subject: [PATCH 59/59] Apply suggestions from code review Co-authored-by: Marc Durdin --- android/KMAPro/build.sh | 6 +++--- android/KMEA/build.sh | 8 ++++---- android/Samples/KMSample1/build.sh | 14 +++++++------- android/Samples/KMSample2/build.sh | 14 +++++++------- android/Tests/KeyboardHarness/build.sh | 18 +++++++++--------- oem/firstvoices/android/build.sh | 4 ++-- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/android/KMAPro/build.sh b/android/KMAPro/build.sh index 21d4d0582e..46a4676e2f 100755 --- a/android/KMAPro/build.sh +++ b/android/KMAPro/build.sh @@ -27,7 +27,7 @@ TEST_FLAGS="-x assembleRelease lintRelease testRelease" # Gradle test w/o build DAEMON_FLAG= builder_describe "Builds Keyman for Android app." \ - "@../KMEA" \ + "@/android/KMEA" \ "clean" \ "configure" \ "build" \ @@ -46,8 +46,8 @@ if builder_is_debug_build; then fi builder_describe_outputs \ - configure kMAPro/libs/keyman-engine.aar \ - build kMAPro/build/outputs/apk/$CONFIG/keyman-${VERSION}.apk + configure /android/KMAPro/kMAPro/libs/keyman-engine.aar \ + build /android/KMAPro/kMAPro/build/outputs/apk/$CONFIG/keyman-${VERSION}.apk #### Build diff --git a/android/KMEA/build.sh b/android/KMEA/build.sh index ed9744c0fb..ecfba488bc 100755 --- a/android/KMEA/build.sh +++ b/android/KMEA/build.sh @@ -49,7 +49,7 @@ if builder_is_debug_build; then fi builder_describe_outputs \ - build:engine app/build/outputs/aar/${CONFIG}/keyman-engine.aar + build:engine /android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar #### Build @@ -63,13 +63,13 @@ fi #### Build action definitions #### -# Check about cleaning arifact paths +# Check about cleaning artifact paths if builder_start_action clean:engine; then rm -rf "$KEYMAN_ROOT/android/KMEA/app/build/outputs" builder_finish_action success clean:engine fi -if builder_start_action configure; then +if builder_start_action configure:engine; then # Copy KeymanWeb artifacts echo "Copying Keyman Web artifacts" @@ -85,7 +85,7 @@ if builder_start_action configure; then echo "Copying es6-shim polyfill" cp "$KEYMAN_ROOT/node_modules/es6-shim/es6-shim.min.js" "$ENGINE_ASSETS/es6-shim.min.js" - builder_finish_action success configure + builder_finish_action success configure:engine fi # Destinations that will need the keymanweb artifacts diff --git a/android/Samples/KMSample1/build.sh b/android/Samples/KMSample1/build.sh index 36125d0cbf..3edcb44e01 100755 --- a/android/Samples/KMSample1/build.sh +++ b/android/Samples/KMSample1/build.sh @@ -25,7 +25,7 @@ CONFIG="release" SAMPLE_FLAGS="build" builder_describe "Build KMSample1 app for Android." \ - "@../../KMEA" \ + "@/android/KMEA" \ "clean" \ "configure" \ "build" \ @@ -45,8 +45,8 @@ ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ - configure app/libs/keyman-engine.aar \ - build:app app/build/outputs/apk/$CONFIG/$ARTIFACT + configure /android/Samples/KMSample1/app/libs/keyman-engine.aar \ + build:app /android/Samples/KMSample1/app/build/outputs/apk/$CONFIG/$ARTIFACT @@ -59,16 +59,16 @@ fi #### Build action definitions #### # Check about cleaning artifact paths -if builder_start_action clean; then +if builder_start_action clean:app; then rm -rf "$KEYMAN_ROOT/android/Samples/KMSample1/app/build/outputs" - builder_finish_action success clean + builder_finish_action success clean:app fi -if builder_start_action configure; then +if builder_start_action configure:app; then # Copy Keyman Engine for Android cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample1/app/libs/keyman-engine.aar" - builder_finish_action success configure + builder_finish_action success configure:app fi # Building KMSample1 diff --git a/android/Samples/KMSample2/build.sh b/android/Samples/KMSample2/build.sh index abde8cdf84..608076ee57 100755 --- a/android/Samples/KMSample2/build.sh +++ b/android/Samples/KMSample2/build.sh @@ -25,7 +25,7 @@ CONFIG="release" SAMPLE_FLAGS="build" builder_describe "Build KMSample2 app for Android." \ - "@../../KMEA" \ + "@/android/KMEA" \ "clean" \ "configure" \ "build" \ @@ -45,8 +45,8 @@ ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ - configure app/libs/keyman-engine.aar \ - build:app app/build/outputs/apk/$CONFIG/$ARTIFACT + configure /android/Samples/KMSample2/app/libs/keyman-engine.aar \ + build:app /android/Samples/KMSample2/app/build/outputs/apk/$CONFIG/$ARTIFACT @@ -59,16 +59,16 @@ fi #### Build action definitions #### # Check about cleaning artifact paths -if builder_start_action clean; then +if builder_start_action clean:app; then rm -rf "$KEYMAN_ROOT/android/Samples/KMSample2/app/build/outputs" - builder_finish_action success clean + builder_finish_action success clean:app fi -if builder_start_action configure; then +if builder_start_action configure:app; then # Copy Keyman Engine for Android cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/Samples/KMSample2/app/libs/keyman-engine.aar" - builder_finish_action success configure + builder_finish_action success configure:app fi # Building KMSample2 diff --git a/android/Tests/KeyboardHarness/build.sh b/android/Tests/KeyboardHarness/build.sh index 1d97fbba31..5051b1f8b4 100755 --- a/android/Tests/KeyboardHarness/build.sh +++ b/android/Tests/KeyboardHarness/build.sh @@ -24,7 +24,7 @@ BUILD_FLAGS="aR -x lint -x test" # Gradle build w/o test TEST_FLAGS="-x aR lintRelease testRelease" # Gradle test w/o build builder_describe "Build KeyboardHarness test app for Android." \ - "@../../KMEA" \ + "@/android/KMEA" \ "clean" \ "configure" \ "build" \ @@ -44,8 +44,8 @@ fi ARTIFACT="app-$CONFIG.apk" builder_describe_outputs \ - configure app/libs/keyman-engine.aar \ - build:app app/build/outputs/apk/$CONFIG/${ARTIFACT} + configure /android/Tests/KeyboardHarness/app/libs/keyman-engine.aar \ + build:app /android/Tests/KeyboardHarness/app/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build @@ -67,16 +67,16 @@ fi #### Build action definitions #### # Check about cleaning artifact paths -if builder_start_action clean; then +if builder_start_action clean:app; then rm -rf "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/build/outputs" - builder_finish_action success clean + builder_finish_action success clean:app fi -if builder_start_action configure; then +if builder_start_action configure:app; then # Copy Keyman Engine for Android cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/Tests/KeyboardHarness/app/libs/keyman-engine.aar" - builder_finish_action success configure + builder_finish_action success configure:app fi # Building KeyboardHarness @@ -87,8 +87,8 @@ if builder_start_action build:app; then builder_finish_action success build:app fi -if builder_start_action test; then +if builder_start_action test:app; then echo "TEST_FLAGS $TEST_FLAGS" - builder_finish_action succes test + builder_finish_action success test:app fi diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 2d7bf31f3e..e118afa875 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -48,8 +48,8 @@ fi ARTIFACT="firstvoices-$VERSION.apk" builder_describe_outputs \ - configure app/libs/keyman-engine.aar \ - build app/build/outputs/apk/$CONFIG/${ARTIFACT} + configure /oem/firstvoices/android/app/libs/keyman-engine.aar \ + build /oem/firstvoices/android/app/build/outputs/apk/$CONFIG/${ARTIFACT} #### Build