maint(web): cleanup web/**/build.sh for consistency and build performance

* Simplify the build dependency / child tree
* Split building and testing tooling so we don't rebuild components
* Fixup expected outputs to avoid repeated builds of components
* Remove unused dependency references
* Move test.sh targets into build.sh, so that testing doesn't lose
  dependency tracking and cause unnecessary rebuilds. (Note that I have
  not yet deleted test.sh.)
* Make predictive-text a direct child of engine, so that we don't build
  it twice (or even more times)

Test-bot: skip
This commit is contained in:
Marc Durdin 2025-11-07 09:36:19 +01:00
parent 86a903dcf5
commit 8eb7e6b0d4
26 changed files with 159 additions and 122 deletions

View file

@ -16,7 +16,7 @@ builder_describe "Check markdown internal links" \
"build"
builder_describe_outputs \
configure "${THIS_SCRIPT_PATH}/node_modules" \
configure /node_modules \
build build/index.js
builder_parse "$@"

View file

@ -16,7 +16,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
builder_set_child_base src
builder_describe "Builds engine modules for Keyman Engine for Web (KMW)." \
\
"@/common/tools/es-bundling" \
"@/common/tools/es-bundling build" \
"@/resources/tools/check-markdown test:help" \
\
"clean" \
@ -24,21 +24,23 @@ builder_describe "Builds engine modules for Keyman Engine for Web (KMW)." \
"build" \
"start Starts the test server" \
"test" \
"coverage Create an HTML page with code coverage" \
":app/browser The form of Keyman Engine for Web for use on websites" \
":app/webview A puppetable version of KMW designed for use in a host app's WebView" \
":app/ui Builds KMW's desktop form-factor keyboard-selection UI modules" \
"coverage Create an HTML page with code coverage report" \
\
":app/browser KeymanWeb build for use on websites" \
":app/webview KeymanWeb build for embedding in Keyman for Android and Keyman for iOS" \
":app/ui KeymanWeb desktop form-factor keyboard-selection UI modules" \
":common/web-utils Shared utils" \
":engine Keyman Engine for Web" \
":engine/predictive-text Builds KMW's predictive text module" \
":help Online documentation" \
":samples Builds all needed resources for the KMW sample-page set" \
":tools Builds engine-related development resources" \
":samples Resources for the KMW sample-page set" \
":tools/building Build tools" \
":tools/testing Test tools" \
":test-pages=src/test/manual Builds resources needed for the KMW manual testing pages" \
":_all (Meta build target used when targets are not specified)"
# Possible TODO?
# "upload-symbols Uploads build product to Sentry for error report symbolification. Only defined for $DOC_BUILD_EMBED_WEB" \
":_all (Meta build target used when targets are not specified)" \
\
"--test-dom-only For test, run only DOM-oriented unit tests (reduced footprint, nothing browser-specific)" \
"--test-integrated-only For test, run only KMW's integration test suite" \
"--test-inspect For test, run browser-based unit tests in an inspectable mode"
builder_parse "$@"
@ -49,15 +51,15 @@ fi
builder_describe_outputs \
configure "/node_modules" \
build "/web/build/test/dom/cases/attachment/outputTargetForElement.tests.html" \
build "/web/build/test/dom/cases/attachment/textStoreForElement.tests.html" \
build:app/browser "/web/build/app/browser/lib/index.mjs" \
build:app/webview "/web/build/app/webview/${config}/keymanweb-webview.js" \
build:app/ui "/web/build/app/ui/${config}/kmwuitoggle.js" \
build:common/web-utils "/web/build/common/web-utils/lib/index.mjs" \
build:engine "/web/build/engine/lib/index.mjs" \
build:engine/predictive-text "/web/src/engine/predictive-text/worker-main/build/lib/web/index.mjs" \
build:samples "/web/src/samples/simplest/keymanweb.js" \
build:tools "/web/build/tools/building/sourcemap-root/index.js" \
build:tools/building "/web/build/tools/building/sourcemap-root/index.js" \
build:tools/testing "/web/build/tools/testing/test-utils/lib/index.d.ts" \
build:test-pages "/web/build/test-resources/sentry-manager.js"
#### Build action definitions ####
@ -90,7 +92,7 @@ precompile() {
done
}
build_action() {
build_tests_action() {
builder_echo "Building auto tests..."
# The currently-bundled declaration file for gesture-processor generates
@ -140,12 +142,12 @@ coverage_action() {
rm -rf build/coverage/tmp
}
builder_run_child_actions build:tools
builder_run_child_actions build:tools/building
builder_run_child_actions build:common/web-utils
builder_run_child_actions build:engine
builder_run_child_actions build:engine/predictive-text
# builder_run_child_actions build:engine/predictive-text
# Uses all but engine/element-wrappers and engine/attachment
builder_run_child_actions build:app/webview
@ -163,11 +165,38 @@ builder_run_child_actions build:samples
builder_run_child_actions build:test-pages
# Build tests
builder_run_action build:_all build_action
builder_run_child_actions build:tools/testing
builder_run_action build:_all build_tests_action
# Run tests
builder_run_child_actions test
builder_run_action test:_all ./test.sh
function do_browser_tests() {
# Browser-based tests: common configs & kill-switches
# Select the right CONFIG file.
local WTR_CONFIG=
if builder_is_ci_build; then
WTR_CONFIG=.CI
fi
# Prepare the flags for the karma command.
local WTR_INSPECT=
if builder_has_option --test-inspect; then
WTR_INSPECT="--manual"
fi
pushd "${KEYMAN_ROOT}"
if builder_has_option --test-dom-only || ! builder_has_option --test-integrated-only; then
web-test-runner --config "web/src/test/auto/dom/web-test-runner${WTR_CONFIG}.config.mjs" ${WTR_INSPECT}
fi
if builder_has_option --test-integrated-only || ! builder_has_option --test-dom-only; then
web-test-runner --config "web/src/test/auto/integrated/web-test-runner${WTR_CONFIG}.config.mjs" ${WTR_INSPECT}
fi
popd
}
builder_run_action test:_all do_browser_tests
function do_test_help() {
check-markdown "$KEYMAN_ROOT/web/docs/engine"

View file

@ -14,9 +14,9 @@ SUBPROJECT_NAME=app/browser
# ################################ Main script ################################
builder_describe "Builds the Keyman Engine for Web's website-integrating version for use in non-puppeted browsers." \
"@/common/tools/es-bundling" \
"@/web/src/engine build" \
"@/web/src/tools/building/sourcemap-root" \
"@/common/tools/es-bundling build" \
"@/web/src/engine build" \
"@/web/src/tools/building/sourcemap-root build" \
"clean" \
"configure" \
"build" \

View file

@ -14,8 +14,8 @@ SUBPROJECT_NAME=app/ui
# ################################ Main script ################################
builder_describe "Builds the Keyman Engine for Web's desktop form-factor keyboard selection modules." \
"@/web/src/app/browser build" \
"@/web/src/tools/building/sourcemap-root" \
"@/web/src/app/browser build" \
"@/web/src/tools/building/sourcemap-root build" \
"clean" \
"configure" \
"build" \

View file

@ -14,9 +14,9 @@ SUBPROJECT_NAME=app/webview
# ################################ Main script ################################
builder_describe "Builds the Keyman Engine for Web's puppetable version designed for use within WebViews." \
"@/common/tools/es-bundling" \
"@/web/src/engine build" \
"@/web/src/tools/building/sourcemap-root" \
"@/common/tools/es-bundling build" \
"@/web/src/engine build" \
"@/web/src/tools/building/sourcemap-root build" \
"clean" \
"configure" \
"build" \

View file

@ -19,9 +19,9 @@ BUILD_DIR="/web/build/common/web-utils"
builder_describe \
"Compiles the web-oriented utility function module." \
"@/common/tools/es-bundling" \
"@/common/web/keyman-version" \
"@/common/web/types" \
"@/common/tools/es-bundling build" \
"@/common/web/keyman-version build" \
"@/common/web/types build" \
clean configure build test
builder_describe_outputs \

View file

@ -15,14 +15,14 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
# ################################ Main script ################################
builder_describe "Builds Keyman Engine for Web (KMW)" \
"@/core:wasm" \
"@/common/tools/es-bundling" \
"@/web/src/engine/predictive-text" \
"@/web/src/common/web-utils" \
"@/core:wasm build" \
"@/common/tools/es-bundling build" \
"@/web/src/common/web-utils build" \
"clean" \
"configure" \
"build" \
"test"
"test" \
":predictive-text"
# Possible TODO?
# "upload-symbols Uploads build product to Sentry for error report symbolification. Only defined for $DOC_BUILD_EMBED_WEB" \
@ -67,7 +67,11 @@ do_build () {
node src/osk/validate-gesture-specs.js
}
builder_run_action configure node_select_version_and_npm_ci
builder_run_action clean rm -rf "$KEYMAN_ROOT/web/build/engine"
builder_run_child_actions clean
builder_run_action configure node_select_version_and_npm_ci
builder_run_child_actions configure
builder_run_child_actions build
builder_run_action build do_build
builder_run_action test test-headless-typescript engine
builder_run_child_actions test

View file

@ -20,8 +20,7 @@ builder_describe "Builds predictive-text components used within Keyman Engine fo
":templates Builds the model templates utilized by compiled lexical models" \
":wordbreakers Builds the wordbreakers provided for lexical model use" \
":worker-main Builds the predictive-text worker interface module" \
":worker-thread Builds the predictive-text worker" \
":_all (Meta build target used when targets are not specified)"
":worker-thread Builds the predictive-text worker"
# Possible TODO?
# "upload-symbols Uploads build product to Sentry for error report symbolification. Only defined for $DOC_BUILD_EMBED_WEB" \
@ -30,10 +29,10 @@ builder_parse "$@"
builder_describe_outputs \
configure "/node_modules" \
build:templates "/web/src/engine/predictive-text/build/obj/index.js" \
build:wordbreakers "/web/src/engine/wordbreakers/build/main/obj/index.js" \
build:worker-main "/web/src/engine/worker-main/build/obj/lmlayer.js" \
build:worker-thread "/web/src/engine/worker-thread/build/obj/worker-main.wrapped.js"
build:templates "/web/src/engine/predictive-text/templates/build/obj/index.js" \
build:wordbreakers "/web/src/engine/predictive-text/wordbreakers/build/main/obj/index.js" \
build:worker-main "/web/src/engine/predictive-text/worker-main/build/lib/index.mjs" \
build:worker-thread "/web/src/engine/predictive-text/worker-thread/build/lib/worker-main.wrapped.js"
#### Build action definitions ####

View file

@ -17,8 +17,8 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
SUBPROJECT_NAME=engine/predictive-text/templates
builder_describe "Builds the predictive-text model template implementation module" \
"@/web/src/common/web-utils" \
"@../wordbreakers" \
"@/web/src/common/web-utils build" \
"@../wordbreakers build" \
"clean" \
"configure" \
"build" \
@ -38,7 +38,7 @@ function do_build() {
tsc --emitDeclarationOnly --outFile ./build/lib/index.d.ts
}
builder_run_action configure node_select_version_and_npm_ci
builder_run_action clean rm -rf build/
builder_run_action configure node_select_version_and_npm_ci
builder_run_action build do_build
builder_run_action test test-headless-typescript $SUBPROJECT_NAME

View file

@ -19,7 +19,7 @@ SUBPROJECT_NAME=engine/predictive-text/wordbreakers
# Note: the raw text files used for data.inc.ts are found within
# /resources/standards-data/unicode-character-database.
builder_describe "Builds the predictive-text wordbreaker implementation module" \
"@/common/web/types" \
"@/common/web/types build" \
"clean" \
"configure" \
"build" \
@ -64,7 +64,7 @@ function do_test() {
fi
}
builder_run_action configure do_configure
builder_run_action clean rm -rf build/
builder_run_action configure do_configure
builder_run_action build do_build
builder_run_action test test-headless-typescript $SUBPROJECT_NAME

View file

@ -7,9 +7,6 @@
"module": "node16",
"moduleResolution": "node16"
},
"references": [
{ "path": "../../../../../../../common/web/types" }
],
"include": [
"./**/*"
],

View file

@ -17,10 +17,10 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
################################ Main script ################################
builder_describe "Builds the lm-layer module" \
"@/common/tools/es-bundling" \
"@/common/web/keyman-version" \
"@/common/web/types" \
"@/web/src/engine/predictive-text/worker-thread" \
"@/common/tools/es-bundling build" \
"@/common/web/keyman-version build" \
"@/common/web/types build" \
"@/web/src/engine/predictive-text/worker-thread build" \
"clean" \
"configure" \
"build" \
@ -56,7 +56,7 @@ function do_test() {
./unit_tests/test.sh test:headless test:browser
}
builder_run_action configure do_configure
builder_run_action clean rm -rf build/
builder_run_action configure do_configure
builder_run_action build do_build
builder_run_action test do_test

View file

@ -24,11 +24,11 @@ SUBPROJECT_NAME=engine/predictive-text/worker-thread
builder_describe \
"Compiles the Language Modeling Layer for common use in predictive text and autocorrective applications." \
"@/common/tools/es-bundling" \
"@/common/web/keyman-version" \
"@/web/src/tools/building/sourcemap-root" \
"@../wordbreakers" \
"@../templates" \
"@/common/tools/es-bundling build" \
"@/common/web/keyman-version build" \
"@/web/src/tools/building/sourcemap-root build" \
"@../wordbreakers build" \
"@../templates build" \
configure clean build test \
"--inspect Runs browser-based tests in a locally-inspectable mode"

View file

@ -1,28 +1,19 @@
#!/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"
# ################################ Main script ################################
builder_describe "Builds the Keyman Engine for Web's sample page setups." \
"@/common/web/sentry-manager build" \
"@/web/src/app/browser build" \
"@/web/src/app/ui build" \
"@/web/src/tools build" \
"configure Does nothing for this project" \
"clean" \
"build" \
"test Does nothing for this project"
# Possible TODO?s
# "upload-symbols Uploads build product to Sentry for error report symbolification. Only defined for $DOC_BUILD_EMBED_WEB" \
builder_parse "$@"
DEST="web/build/test-resources"
@ -30,26 +21,15 @@ DEST="web/build/test-resources"
builder_describe_outputs \
build "/$DEST/sentry-manager.js"
#### Resource paths ####
SENTRY_MANAGER_SRC="$KEYMAN_ROOT/common/web/sentry-manager/build/lib/index.js"
SENTRY_MANAGER_MAP="$KEYMAN_ROOT/common/web/sentry-manager/build/lib/index.js.map"
#### Build action definitions ####
# GESTURE_PROCESSOR_BUILD="$KEYMAN_ROOT/web/src/engine/osk/gesture-processor/build/lib/."
# GESTURE_PROCESSOR_TARGET="$KEYMAN_ROOT/web/build/engine/gesture-processor/lib/"
function do_copy() {
mkdir -p "$KEYMAN_ROOT/$DEST"
# The next two lines are needed for the sentry-integration manual test page.
cp "$SENTRY_MANAGER_SRC" "$KEYMAN_ROOT/$DEST/sentry-manager.js"
cp "$SENTRY_MANAGER_MAP" "$KEYMAN_ROOT/$DEST/sentry-manager.js.map"
# mkdir -p "$GESTURE_PROCESSOR_TARGET"
# cp -a "$GESTURE_PROCESSOR_BUILD" "$GESTURE_PROCESSOR_TARGET"
cp "$KEYMAN_ROOT/common/web/sentry-manager/build/lib/index.js" "$KEYMAN_ROOT/$DEST/sentry-manager.js"
cp "$KEYMAN_ROOT/common/web/sentry-manager/build/lib/index.js.map" "$KEYMAN_ROOT/$DEST/sentry-manager.js.map"
}
builder_run_action clean rm -rf "$KEYMAN_ROOT/$DEST"
builder_run_action build do_copy
builder_run_action clean rm -rf "$KEYMAN_ROOT/$DEST"
builder_run_action build do_copy

View file

@ -12,27 +12,15 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
################################ Main script ################################
builder_describe "Builds the Keyman Engine for Web's development & unit-testing tools" \
"@/common/web/keyman-version" \
"@/web/src/engine" \
builder_describe "KeymanWeb development & unit-testing tools" \
"configure" \
"clean" \
"build" \
"test" \
":bulk_rendering=testing/bulk_rendering Builds the bulk-rendering tool used to validate changes to OSK display code" \
":recorder=testing/recorder Builds the KMW recorder tool used for development of unit-test resources" \
":sourcemap-root=building/sourcemap-root Builds the sourcemap-cleaning tool used during minification of app/ builds" \
":test-utils=testing/test-utils Builds the test-utils module" \
":gesture-processor=testing/gesture-processor Gesture processor test utilities"
":building" \
":testing"
builder_parse "$@"
builder_run_child_actions clean
# Some of the web/src/test section uses this script as a dependency. We can skip
# the configure sections in such a case.
if ! builder_is_dep_build && ! builder_is_child_build; then
builder_run_child_actions configure
fi
builder_run_child_actions configure
builder_run_child_actions build

20
web/src/tools/building/build.sh Executable file
View file

@ -0,0 +1,20 @@
#!/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
################################ Main script ################################
builder_describe "Keyman Engine for Web development tools" \
"configure" \
"clean" \
"build" \
":sourcemap-root Sourcemap-cleaning tool used during minification of app/ builds"
builder_parse "$@"
builder_run_child_actions clean
builder_run_child_actions configure
builder_run_child_actions build

View file

@ -14,7 +14,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
################################ Main script ################################
builder_describe "Builds the sourcemap-sanitizing script used for Keyman Engine for Web builds" \
"@/common/tools/sourcemap-path-remapper" \
"@/common/tools/sourcemap-path-remapper build" \
"clean" \
"configure" \
"build" \

28
web/src/tools/testing/build.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
#
# Compile KeymanWeb's dev & test tool modules
#
## 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"
################################ Main script ################################
builder_describe "Keyman Engine for Web unit-testing and manual test tools" \
"configure" \
"clean" \
"build" \
":bulk_rendering Bulk-rendering tool used to validate changes to OSK display code" \
":recorder KMW recorder tool used for development of unit-test resources" \
":test-utils Builds the test-utils module" \
":gesture-processor Gesture processor test utilities"
builder_parse "$@"
builder_run_child_actions clean
builder_run_child_actions configure
builder_run_child_actions build

View file

@ -16,10 +16,9 @@ SUBPROJECT_NAME=tools/testing/bulk_rendering
################################ Main script ################################
builder_describe "Builds a 'bulk renderer' that loads all the cloud keyboards from api.keyman.com and renders each of them to a document." \
"@/common/tools/es-bundling" \
"@/common/tools/es-bundling build" \
"@/web/src/common/web-utils build" \
"@/web/src/app/browser build" \
"@/web/src/app/ui build" \
"@/web/src/app/browser build" \
"clean" \
"configure runs 'npm ci' on root folder" \
"build (default) builds bulk_renderer to web/build/$SUBPROJECT_NAME/"

View file

@ -12,6 +12,7 @@
],
"references": [
{ "path": "../../../common/web-utils" },
{ "path": "../../../app/browser" },
{ "path": "../../../engine" }
]

View file

@ -16,7 +16,7 @@ BUILD_DIR=/web/build/tools/testing/gesture-processor
################################ Main script ################################
builder_describe "Testing-oriented tools for the Gesture Processor module of web-based Keyman OSKs" \
"@/common/tools/es-bundling" \
"@/common/tools/es-bundling build" \
"clean" \
"build" \
":fixture The HTML-element fixture and CSS fixture used for both user-testing and unit-testing" \
@ -27,8 +27,8 @@ builder_parse "$@"
builder_describe_outputs \
configure /node_modules \
build:fixture "${BUILD_DIR}/host-fixture.html" \
build:recorder "${BUILD_DIR}/recorder/build/recorder.mjs" \
build:fixture "${BUILD_DIR}/unit-test-resources/host-fixture.html" \
build:recorder "/web/tools/testing/gesture-processor/recorder/build/recorder.mjs" \
build:test-module "${BUILD_DIR}/unit-test-resources/lib/index.mjs"
# TODO: build if out-of-date if test is specified

View file

@ -18,7 +18,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
builder_describe \
"Compiles the web-oriented utility function module." \
"@/common/web/keyman-version" \
"@/common/web/keyman-version build" \
configure \
clean \
build

View file

@ -18,10 +18,6 @@
"url": "https://github.com/keymanapp/keyman/issues"
},
"homepage": "https://github.com/keymanapp/keyman#readme",
"dependencies": {
"@keymanapp/common-types": "*",
"@keymanapp/keyman-version": "*"
},
"devDependencies": {
"typescript": "^5.4.5"
}

View file

@ -13,9 +13,7 @@
],
"references": [
{ "path": "../../../../../common/web/keyman-version" },
{ "path": "../../../common/web-utils/" },
{ "path": "../../../engine/predictive-text/types" },
{ "path": "../../../engine" },
],
}

View file

@ -16,10 +16,10 @@ SUBPROJECT_NAME=tools/testing/recorder
################################ Main script ################################
builder_describe "Builds the Keyman Engine for Web's test-sequence recording tool" \
"@/common/tools/es-bundling" \
"@/common/web/keyman-version" \
"@/web/src/engine" \
"@../recorder-core" \
"@/common/tools/es-bundling build" \
"@/common/web/keyman-version build" \
"@/web/src/engine build" \
"@../recorder-core build" \
"clean" \
"configure" \
"build"

View file

@ -9,9 +9,7 @@
"include": [ "*.ts" ],
"references": [
{ "path": "../../../../../common/web/keyman-version" },
{ "path": "../../../common/web-utils" },
{ "path": "../../../engine/predictive-text/types" },
{ "path": "../../../app/browser" },
{ "path": "../recorder-core" },
{ "path": "../../../engine" },