From 68fcd27bf79f2cf3a58753ed5823ece02e9db074 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Tue, 14 May 2024 10:58:50 +0700 Subject: [PATCH] chore(oem/fv/ios): Remove build_keyboards.sh script --- oem/firstvoices/common/build_keyboards.sh | 140 ---------------------- oem/firstvoices/ios/build.sh | 19 ++- 2 files changed, 14 insertions(+), 145 deletions(-) delete mode 100755 oem/firstvoices/common/build_keyboards.sh diff --git a/oem/firstvoices/common/build_keyboards.sh b/oem/firstvoices/common/build_keyboards.sh deleted file mode 100755 index 4cac20ca56..0000000000 --- a/oem/firstvoices/common/build_keyboards.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env bash - -# Build the keyboards referred to in ../keyboards.csv and copy them + metadata -# to the FirstVoices/Keyboards folder - -# 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' -# Alternatively, the keyboards can be downloaded from downloads.keyman.com -# -# keyboards.csv has columns Shortname,ID,Name,Region,OldVersion - -# 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 - -## START STANDARD BUILD SCRIPT INCLUDE -# adjust relative paths as necessary -THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" -. "${THIS_SCRIPT%/*}/../../../resources/build/build-utils.sh" -## END STANDARD BUILD SCRIPT INCLUDE - -. "$KEYMAN_ROOT/resources/build/jq.inc.sh" - -# 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="$KEYMAN_ROOT/../keyboards" - -function display_usage { - echo "Usage: build_keyboards.sh [-download-keyboards] [-copy-keyboards] [-clean-keyboards] [-debug] [-h|-?]" - echo "Builds all keyboards used by the app and copies them into the" - echo "target path." - echo " -download-keyboards: Download fv_all.kmp from downloads.keyman.com" - echo " -copy-keyboards: Only copy the keyboards; don't rebuild them" - echo " -clean-keyboards: Clean the keyboards from this repo" - echo " -debug: Build debug versions of the keyboards" - exit 1 -} - -DO_CLEAN=true -DO_COPY=true -DO_BUILD=true -DO_DOWNLOAD=false - -while [[ $# -gt 0 ]] ; do - key="$1" - case $key in - -download-keyboards) - DO_DOWNLOAD=true - DO_COPY=false - DO_BUILD=false - ;; - -copy-keyboards) - DO_BUILD=false - ;; - -h|-\?) - display_usage - ;; - -clean-keyboards) - DO_COPY=false - DO_BUILD=false - ;; - -debug) - BUILD_FLAGS="-debug" - ;; - esac - shift -done - -# Check that $KEYBOARDS_TARGET is valid -if [[ -z "$KEYBOARDS_TARGET" ]]; then - builder_die "KEYBOARDS_TARGET cannot be empty" -fi - -# Clean existing Keyboards folder -# Can't remove entire folder because Android has other assets/ - -if [ $DO_CLEAN = true ]; then - echo "Cleaning target path $KEYBOARDS_TARGET" - rm -f "$KEYBOARDS_TARGET/*.kmp" - rm -f "$KEYBOARDS_TARGET/*.keyboard_info" - echo "Removing file $KEYBOARDS_CSV_TARGET" - rm -f $KEYBOARDS_CSV_TARGET -fi - -mkdir -p $KEYBOARDS_TARGET - -# Build keyboards and copy into KEYBOARDS_TARGET - -if [ $DO_BUILD = true ] || [ $DO_COPY = true ]; then - echo "Building and/or copying keyboards" - - if [ $DO_COPY = true ]; then - cp ../keyboards.csv "$KEYBOARDS_CSV_TARGET" - fi - - SCRIPT_ROOT=`pwd` - pushd $KEYBOARDS_ROOT - - { - # Skip header line - read - - # Read CSV and build each referenced keyboard - while IFS=, read -r shortname id name region old_keyboard; do - if [ $DO_BUILD = true ]; then - echo "Building $id ($name)" # $shortname/$id -> $name" - WINEDEBUG=fixme-nls,fixme-thread "./build.sh" release/$shortname/$id || builder_die "Unable to build keyboard $shortname/$id" - fi - if [ $DO_COPY = true ]; then - echo "Copying $id ($name) to $KEYBOARDS_TARGET" - mkdir -p "$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 - done - } < "$SCRIPT_ROOT/../keyboards.csv" - - popd -fi - -if [ $DO_DOWNLOAD = true ]; then - echo "Downloading keyboards from downloads.keyman.com" - - cp ../keyboards.csv "$KEYBOARDS_CSV_TARGET" - - SCRIPT_ROOT=`pwd` - URL_DOWNLOAD=https://downloads.keyman.com - URL_API_VERSION=${URL_DOWNLOAD}/api/keyboard/ - - id="fv_all" - echo "Downloading $id" - URL_DOWNLOAD_FILE=`curl -s "$URL_API_VERSION/$id" | "$JQ" -r .kmp` - curl -s "$URL_DOWNLOAD_FILE" > "$SCRIPT_ROOT/$KEYBOARDS_TARGET/$id.kmp" -fi - -echo "Keyboards built successfully." diff --git a/oem/firstvoices/ios/build.sh b/oem/firstvoices/ios/build.sh index cab7c4b4c9..2075753bd4 100755 --- a/oem/firstvoices/ios/build.sh +++ b/oem/firstvoices/ios/build.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# Build FirstVoices for iOS app ## START STANDARD BUILD SCRIPT INCLUDE # adjust relative paths as necessary @@ -8,6 +9,9 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" # Include our resource functions; they're pretty useful! . "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" +. "$KEYMAN_ROOT/resources/build/build-download-resources.sh" + +# ################################ Main script ################################ # Please note that this build script (understandably) assumes that it is running on Mac OS X. verify_on_mac @@ -53,10 +57,15 @@ function carthage_die() { } function do_configure() { - export KEYBOARDS_TARGET="$TARGET/Keyboards" - export KEYBOARDS_CSV_TARGET="$TARGET/Keyboards/keyboards.csv" - # TODO: support passing -copy-keyboards, -debug, -clean etc in to build_keyboards - ../common/build_keyboards.sh -download-keyboards + KEYBOARDS_CSV="$KEYMAN_ROOT/oem/firstvoices/keyboards.csv" + KEYBOARDS_CSV_TARGET="$KEYMAN_ROOT/oem/firstvoices/ios/FirstVoices/Keyboards/keyboards.csv" + + KEYBOARD_PACKAGE_ID="fv_all" + KEYBOARDS_TARGET="$KEYMAN_ROOT/oem/firstvoices/ios/FirstVoices/Keyboards/${KEYBOARD_PACKAGE_ID}.kmp" + + mkdir -p "$KEYMAN_ROOT/oem/firstvoices/ios/FirstVoices/Keyboards" + cp "$KEYBOARDS_CSV" "$KEYBOARDS_CSV_TARGET" + downloadKeyboardPackage "$KEYBOARD_PACKAGE_ID" "KEYBOARDS_TARGET" echo echo "Load dependencies with Carthage" @@ -134,4 +143,4 @@ function do_build() { builder_run_action clean do_clean builder_run_action configure do_configure -builder_run_action build do_build \ No newline at end of file +builder_run_action build do_build