diff --git a/oem/firstvoices/ios/build.sh b/oem/firstvoices/ios/build.sh index 433c8e2e88..70d9a9179e 100755 --- a/oem/firstvoices/ios/build.sh +++ b/oem/firstvoices/ios/build.sh @@ -3,7 +3,7 @@ set -e # TODO: support passing -copy-keyboards, -debug, -clean etc in to build_keyboards -./build_keyboards.sh +./build_keyboards.sh -download-keyboards TARGET=FirstVoices # TODO: in the future build_common.sh should probably be shared with all oem products? diff --git a/oem/firstvoices/ios/build_keyboards.sh b/oem/firstvoices/ios/build_keyboards.sh index 995a3fc672..8d31a3999b 100755 --- a/oem/firstvoices/ios/build_keyboards.sh +++ b/oem/firstvoices/ios/build_keyboards.sh @@ -26,9 +26,10 @@ function die { } function display_usage { - echo "Usage: build_keyboards.sh [-copy-keyboards] [-clean-keyboards] [-debug] [-h|-?]" + 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 keyboards 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" @@ -38,10 +39,16 @@ function display_usage { 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 ;; @@ -102,3 +109,27 @@ if [ $DO_BUILD = true ] || [ $DO_COPY = true ]; then popd fi + +if [ $DO_DOWNLOAD = true ]; then + echo "Downloading keyboards from downloads.keyman.com" + + cp ../keyboards.csv "$TARGET/keyboards.csv" + + SCRIPT_ROOT=`pwd` + URL_DOWNLOAD=https://downloads.keyman.com + URL_API_VERSION=${URL_DOWNLOAD}/api/keyboard/ + + { + # Skip header line + read + + # Read CSV and build each referenced keyboard + while IFS=, read -r shortname id name region old_keyboard; do + echo "Downloading $id ($name)" + # Get latest version + URL_DOWNLOAD_FILE=`curl -s "$URL_API_VERSION/$id" | jq -r .js` + curl -s "$URL_DOWNLOAD_FILE" > "$SCRIPT_ROOT/$TARGET/files/$id.js" + curl -s "${URL_DOWNLOAD_FILE%.*}.keyboard_info" > "$SCRIPT_ROOT/$TARGET/files/$id.keyboard_info" + done + } < "$SCRIPT_ROOT/../keyboards.csv" +fi