diff --git a/core/tools/ldml-const-builder/build.sh b/core/tools/ldml-const-builder/build.sh index 8c8bc364b5..dbee106f5a 100755 --- a/core/tools/ldml-const-builder/build.sh +++ b/core/tools/ldml-const-builder/build.sh @@ -9,35 +9,44 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" ## END STANDARD BUILD SCRIPT INCLUDE . "$KEYMAN_ROOT/resources/build/utils.inc.sh" +. "$KEYMAN_ROOT/resources/build/node.inc.sh" CORE_LDML_H_FILE="../../include/ldml/keyman_core_ldml.h" +CORE_LDML_TS_FILE="../../include/ldml/keyman_core_ldml.ts" ################################ Main script ################################ -builder_describe "Build and run the constant builder for LDML" clean build run +builder_describe "Build and run the constant builder for LDML" clean configure build run test + builder_parse "$@" -# TODO: build if out-of-date if test is specified -# TODO: configure if npm has not been run, and build is specified +builder_describe_internal_dependency \ + run:project build:project \ + test:project run:project +builder_describe_outputs \ + configure "/node_modules" \ + build "/core/include/ldml/ldml-const-builder/ldml-const-builder.js" \ + run "/core/include/ldml/ldml-const-builder/run.txt" -if builder_start_action clean; then - rm -rf ../../include/ldml/build/ - # Not removing ${CORE_LDML_H_FILE} as it is checked in - builder_finish_action success clean -fi - -if builder_start_action build; then - # Generate index.ts - npx tsc -b ../../include/ldml/tsconfig.build.json - - builder_finish_action success build -fi - -if builder_start_action run; then +function do_run() { node --enable-source-maps ../../include/ldml/ldml-const-builder/ldml-const-builder.js > ${CORE_LDML_H_FILE} + touch ../../include/ldml/ldml-const-builder/run.txt echo "Updated ${CORE_LDML_H_FILE}" +} - builder_finish_action success run -fi +function do_test() { + if ! git diff --exit-code "${CORE_LDML_H_FILE}"; then + builder_echo error "File ${CORE_LDML_TS_FILE} has changed, but /core/tools/ldml-const-builder has not been run." + builder_echo error "Run ${COLOR_BRIGHT_WHITE}$KEYMAN_ROOT/core/tools/ldml-const-build/build.sh run${COLOR_RESET} and commit changes" + return 1 + fi +} + +# clean: Not removing ${CORE_LDML_H_FILE} as it is checked in +builder_run_action clean rm -rf ../../include/ldml/build/ ../../include/ldml/ldml-const-builder/ ../../include/ldml/coverage/ +builder_run_action configure node_select_version_and_npm_ci +builder_run_action build tsc -b ../../include/ldml/tsconfig.build.json +builder_run_action run do_run +builder_run_action test do_test diff --git a/docs/builder.md b/docs/builder.md index 534d8731ea..7820fcdab6 100644 --- a/docs/builder.md +++ b/docs/builder.md @@ -1049,13 +1049,13 @@ Do not use builder standard options such as `--deps` or `--debug`. ### Parameters -* 1: `script` path to script, relative to root of repo +* 1: `script` path to script, relative to root of repo, with leading slash * 2+: `parameters` action(s), target(s), parameters for the child script to run ### Example ```bash - builder_launch core/build.sh configure,build:wasm --no-tests + builder_launch /core/build.sh configure,build:wasm --no-tests ``` -------------------------------------------------------------------------------- diff --git a/resources/builder.inc.sh b/resources/builder.inc.sh index 0ce80a5c2d..125a8ae333 100755 --- a/resources/builder.inc.sh +++ b/resources/builder.inc.sh @@ -448,13 +448,13 @@ _builder_cleanup_deps() { # # ### Parameters # -# * 1: `script` path to script, relative to root of repo +# * 1: `script` path to script, relative to root of repo, with leading slash # * 2+: `parameters` action(s), target(s), parameters for the child script to run # # ### Example # # ```bash -# builder_launch core/build.sh configure,build:wasm --no-tests +# builder_launch /core/build.sh configure,build:wasm --no-tests # ``` # builder_launch() { diff --git a/resources/teamcity/common/common-test-core.sh b/resources/teamcity/common/common-test-core.sh index 6d061ec4c0..7b838182fa 100755 --- a/resources/teamcity/common/common-test-core.sh +++ b/resources/teamcity/common/common-test-core.sh @@ -34,7 +34,8 @@ else fi function do_all() { - "${KEYMAN_ROOT}/core/build.sh" configure,build,test:${ARCH} + builder_launch /core/tools/ldml-const-builder/build.sh clean,configure,build,run,test + builder_launch /core/build.sh configure,build,test:${ARCH} } builder_run_action all do_all