diff --git a/oem/firstvoices/android/.gitignore b/oem/firstvoices/android/.gitignore index 1e31631dcb..0722107965 100644 --- a/oem/firstvoices/android/.gitignore +++ b/oem/firstvoices/android/.gitignore @@ -21,3 +21,9 @@ # Files generated as part of the build app/src/main/assets/packages app/src/main/assets/keyboards.csv + +# Legacy Eclipse IDE files +.classpath +.project +.cproject +.settings/ diff --git a/oem/firstvoices/android/build.sh b/oem/firstvoices/android/build.sh index 81fc379026..180967ce19 100755 --- a/oem/firstvoices/android/build.sh +++ b/oem/firstvoices/android/build.sh @@ -1,14 +1,71 @@ #!/bin/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 +display_usage ( ) { + echo "build.sh [-no-daemon] [-debug] [-no-update] [-lib-build|-no-lib-build] [-copy-keyboards] [-clean-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 " -copy-keyboards: Only copy the keyboards; don't rebuild them" + echo " -clean-keyboards: Clean the keyboards from this repo" + exit 1 +} + export TARGET=FirstVoices export KEYBOARDS_TARGET=app/src/main/assets/packages export KEYBOARDS_CSV_TARGET=app/src/main/assets/keyboards.csv +export KEYBOARDS_ROOT=../../../../keyboards -# TODO: support passing -copy-keyboards, -debug, -clean etc in to build_keyboards -./build_keyboards.sh +PARAM_COPY_KEYBOARDS= +PARAM_CLEAN_KEYBOARDS= +PARAM_DEBUG= +PARAM_NO_DAEMON= +PARAM_NO_UPDATE= +PARAM_LIB_BUILD= +PARAM_NO_LIB_BUILD= + +while [[ $# -gt 0 ]] ; do + key="$1" + case $key in + -copy-keyboards) + PARAM_COPY_KEYBOARDS=-copy-keyboards + ;; + -h|-?) + display_usage + ;; + -clean-keyboards) + PARAMS_CLEAN_KEYBOARDS=-clean-keyboards + ;; + -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 + +../common/build_keyboards.sh $PARAM_COPY_KEYBOARDS $PARAM_CLEAN_KEYBOARDS $PARAM_DEBUG # TODO: in the future build_common.sh should probably be shared with all oem products? -./build_common.sh "$@" +./build_common.sh $PARAM_DEBUG $PARAM_NO_DAEMON $PARAM_NO_UPDATE $PARAM_LIB_BUILD $PARAM_NO_LIB_BUILD diff --git a/oem/firstvoices/android/build_common.sh b/oem/firstvoices/android/build_common.sh index e3b67549e5..530966f2c5 100755 --- a/oem/firstvoices/android/build_common.sh +++ b/oem/firstvoices/android/build_common.sh @@ -1,15 +1,25 @@ #!/bin/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.sh [-no-daemon] [-debug]" - echo + 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 } @@ -49,7 +59,7 @@ while [[ $# -gt 0 ]] ; do -lib-build) FORCE_KMEA_BUILD=true ;; - -lib-nobuild) + -lib-nobuild|-no-lib-build) ALLOW_KMEA_BUILD=false ;; -h|-?) diff --git a/oem/firstvoices/android/build_keyboards.sh b/oem/firstvoices/common/build_keyboards.sh old mode 100755 new mode 100644 similarity index 94% rename from oem/firstvoices/android/build_keyboards.sh rename to oem/firstvoices/common/build_keyboards.sh index 6cbef5e646..47afba865b --- a/oem/firstvoices/android/build_keyboards.sh +++ b/oem/firstvoices/common/build_keyboards.sh @@ -15,7 +15,8 @@ set -u # 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' -KEYBOARDS_ROOT=../../../../keyboards + + function die { echo "FATAL: $1" @@ -92,7 +93,7 @@ if [ $DO_BUILD = true ] || [ $DO_COPY = true ]; then if [ $DO_COPY = true ]; then echo "Copying $id ($name) to $KEYBOARDS_TARGET" mkdir -p "$SCRIPT_ROOT/$KEYBOARDS_TARGET/$id" - unzip release/$shortname/$id/build/$id.kmp $id.js kmp.json -d "$SCRIPT_ROOT/$KEYBOARDS_TARGET/$id/" + unzip -o release/$shortname/$id/build/$id.kmp $id.js kmp.json -d "$SCRIPT_ROOT/$KEYBOARDS_TARGET/$id/" # cp release/$shortname/$id/build/$id.keyboard_info "$SCRIPT_ROOT/$KEYBOARDS_TARGET/$id.keyboard_info" fi # die "done" @@ -101,3 +102,5 @@ if [ $DO_BUILD = true ] || [ $DO_COPY = true ]; then popd fi + +echo "Keyboards built successfully." \ No newline at end of file