spiegel-keyman/web/common.inc.sh
2023-03-14 12:45:35 +07:00

33 lines
No EOL
898 B
Bash

#!/usr/bin/env bash
#
# Compiles all build products corresponding to the specified target.
# This should be called from the working directory of a child project's
# build script.
#
# ### Parameters
#
# * 1: `product` the product's source path under src/
#
# ### Example
#
# ```bash
# compile engine/main
# ```
compile ( ) {
if [ $# -lt 1 ]; then
builder_die "Scripting error: insufficient argument count!"
fi
local COMPILE_TARGET="$1"
tsc -b "${KEYMAN_ROOT}/web/src/$COMPILE_TARGET" -v
# COMPILE_TARGET entries are all prefixed with `engine`, so remove that.
if [ -f "./build-bundler.js" ]; then
node "./build-bundler.js"
# So... tsc does declaration-bundling on its own pretty well, at least for local development.
tsc --emitDeclarationOnly --outFile "${KEYMAN_ROOT}/web/build/$COMPILE_TARGET/lib/index.d.ts" -p "${KEYMAN_ROOT}/web/src/$COMPILE_TARGET"
fi
}