spiegel-keyman/ios/engine/build.sh
Eberhard Beilharz 07e62e9fe2
chore(android): upload webview source map during android and ios build
Previously we uploaded the webview source map during a web build. This
can lead to problems because that is not the actual artifact used for
Android and iOS.

This change therefore moves uploading the webview source map to Sentry
to the android and ios builds.

Build-bot: skip build:web,android,ios
Test-bot: skip
2026-08-27 18:57:18 +02:00

152 lines
5 KiB
Bash
Executable file

#!/usr/bin/env bash
## START STANDARD BUILD SCRIPT INCLUDE
# adjust relative paths as necessary
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
. "${THIS_SCRIPT%/*}/../../resources/build/builder-full.inc.sh"
## END STANDARD BUILD SCRIPT INCLUDE
. "$KEYMAN_ROOT/resources/build/utils.inc.sh"
. "$KEYMAN_ROOT/resources/build/mac/mac.inc.sh"
. "$KEYMAN_ROOT/resources/build/build-download-resources.sh"
. "${KEYMAN_ROOT}/resources/build/ci/sentry-control.inc.sh"
builder_describe "Builds Keyman Engine for use on iOS devices - iPhone and iPad." \
"@/web/src/app/webview build" \
"@/common/web/sentry-manager build" \
"clean" \
"configure" \
"build" \
"publish-symbols Publishes symbols to Sentry." \
"--sim-artifact Also outputs a simulator-friendly test artifact corresponding to the build"
builder_parse "$@"
mac_verify_on_mac
CONFIG="Release"
if builder_is_debug_build; then
CONFIG="Debug"
fi
builder_describe_outputs \
configure /ios/Carthage/Build \
build /ios/build/Build/Products/Release/KeymanEngine.xcframework
# Base definitions (must be before do_clean call)
DERIVED_DATA="$KEYMAN_ROOT/ios/build"
BUILD_PATH="$DERIVED_DATA/Build/Products"
# Extended path definitions
BUNDLE_PATH="${THIS_SCRIPT_PATH}/KMEI/KeymanEngine/resources/Keyman.bundle/Contents/Resources"
# Needed before `configure` action
DEFAULT_KBD_ID="sil_euro_latin"
DEFAULT_LM_ID="nrc.en.mtnt"
# Engine library build path
KEYMAN_XCFRAMEWORK="$BUILD_PATH/$CONFIG/KeymanEngine.xcframework"
XCODEFLAGS="-quiet -configuration $CONFIG"
XCODEFLAGS_EXT="$XCODEFLAGS -derivedDataPath \"$DERIVED_DATA\" -workspace ../keymanios.xcworkspace"
CODE_SIGN=
if builder_is_debug_build || ( builder_is_ci_build && ! builder_is_ci_build_level_release ); then
CODE_SIGN="CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO ${DEV_TEAM:-} CODE_SIGN_ENTITLEMENTS= CODE_SIGNING_ALLOWED=NO"
fi
### START OF THE BUILD ###
function do_clean () {
# Possible TODO: can we clean the engine target without also cleaning the app target?
rm -rf "$BUILD_PATH"
rm -rf Carthage
}
function carthage_die() {
local msg="$1"
# Don't leave a trace of the failed folder; we'd have to rebuild stuff anyway.
# This way, a later re-run doesn't think `configure` succeeded when it did not.
rm -rf Carthage
builder_die "$1"
}
function do_carthage() {
# Carthage setup must be handled from the directory with the Cartfile / Cartfile.resolved, it seems.
pushd .. > /dev/null
carthage checkout || carthage_die "Carthage dependency checkout failed"
# --no-use-binaries: due to https://github.com/Carthage/Carthage/issues/3134,
# which affects the sentry-cocoa dependency.
carthage build --use-xcframeworks --no-use-binaries --platform iOS || carthage_die "Carthage dependency loading failed"
popd > /dev/null
}
function do_packages() {
mkdir -p "$BUNDLE_PATH"
downloadKeyboardPackage "$DEFAULT_KBD_ID" "$BUNDLE_PATH/$DEFAULT_KBD_ID.kmp"
downloadModelPackage "$DEFAULT_LM_ID" "$BUNDLE_PATH/$DEFAULT_LM_ID.model.kmp"
}
function do_configure ( ) {
do_packages
do_carthage
}
# Manages KeymanEngine.bundle, which is included inside the :engine target.
function update_bundle ( ) {
mkdir -p "$BUNDLE_PATH"
KMW_PRODUCT="$KEYMAN_ROOT/web/build/app/webview/$CONFIG"
KMW_RESOURCES="$KEYMAN_ROOT/web/build/app/resources"
# Copy relevant KeymanWeb resources; this list is also in Storage.swift
cp "$KMW_RESOURCES/osk/globe-hint.css" "$BUNDLE_PATH/globe-hint.css"
cp "$KMW_RESOURCES/osk/kmwosk.css" "$BUNDLE_PATH/kmwosk.css"
cp "$KMW_RESOURCES/osk/keymanweb-osk.ttf" "$BUNDLE_PATH/keymanweb-osk.ttf"
cp "$KMW_PRODUCT/keymanweb-webview.js" "$BUNDLE_PATH/keymanweb-webview.js"
cp "$KEYMAN_ROOT/common/web/sentry-manager/build/lib/index.js" "$BUNDLE_PATH/keyman-sentry.js"
}
# First things first - update our dependencies.
function build_engine() {
update_bundle
echo
echo "Build products will be set with the following version metadata:"
echo " * KEYMAN_VERSION=$KEYMAN_VERSION"
echo " * KEYMAN_VERSION_WITH_TAG=$KEYMAN_VERSION_WITH_TAG"
echo " * KEYMAN_VERSION_ENVIRONMENT=$KEYMAN_VERSION_ENVIRONMENT"
echo " * UPLOAD_SENTRY=$UPLOAD_SENTRY"
echo
echo "Building KMEI..."
rm -rf "$BUILD_PATH/$CONFIG-universal"
mac_xcodebuild $XCODEFLAGS_EXT \
$CODE_SIGN \
-scheme KME-universal \
KEYMAN_VERSION=$KEYMAN_VERSION \
KEYMAN_VERSION_WITH_TAG=$KEYMAN_VERSION_WITH_TAG \
KEYMAN_VERSION_ENVIRONMENT=$KEYMAN_VERSION_ENVIRONMENT \
UPLOAD_SENTRY=$UPLOAD_SENTRY
if ! [[ -d "${KEYMAN_XCFRAMEWORK}" ]]; then
builder_die "Build failed: directory '${KEYMAN_XCFRAMEWORK}' missing"
fi
}
do_publish_symbols() {
if builder_is_ci_build && builder_is_ci_build_level_release; then
sentry_upload_web "${KEYMAN_ROOT}/web/build/app/webview/release/"
fi
}
builder_run_action clean do_clean
builder_run_action configure do_configure
builder_run_action build build_engine
builder_run_action publish-symbols do_publish_symbols