diff --git a/scripts/build_wasm_docker.sh b/scripts/build_wasm_docker.sh index 9e80ed0540..9047cb0158 100755 --- a/scripts/build_wasm_docker.sh +++ b/scripts/build_wasm_docker.sh @@ -7,16 +7,45 @@ # Exit if any command fails. set -e -atexit () { +function atexit () { if [ -z $dockerrunning ]; then docker stop emscripten > /dev/null docker rm emscripten > /dev/null fi } -# Set parameters from command-line arguments, if any. -for i in $@; do - eval $i +function usage() { + echo "Usage: $0 [Option] [PARAMETER=value] [target...]" + echo "" + echo "Build KTX-Software using Emscripten docker package." + echo "Defaults to building everything (Release config) if no targets specified." + echo "Options:" + echo " --help, -h Print this usage message." + echo " --verbose ,-v Cause the underlying make to run in verbose mode." + exit $1 +} + +# cd repo root so script will work whereever the current directory +path_to_repo_root=.. +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/$path_to_repo_root" + +for arg in $@; do + case $arg in + --help | -h) + usage 0 + ;; + --verbose | -v) + verbose_make="-- VERBOSE=1" + shift + ;; + *\=*) + # Set parameter from command-line arguments + eval $arg + shift ;; + *) + targets="$targets --target $arg" + shift ;; + esac done # Set defaults @@ -33,7 +62,7 @@ WERROR=${WERROR:-OFF} BUILD_DIR=${BUILD_DIR:-build/web-$CONFIGURATION} -trap atexit EXIT +trap atexit EXIT SIGINT # Check if emscripten container is already running as CI will already have started it. if [ "$(docker container inspect -f '{{.State.Status}}' emscripten 2> /dev/null)" != "running" ] @@ -75,10 +104,8 @@ mkdir -p $BUILD_DIR # support multiple configurations. echo "Configure and Build KTX-Software (Web $CONFIGURATION)" -# Uncomment and set to desired targets if you don't want to build everything. +# Uncomment for debugging some generator expressions. #targets="--target debug_isgnufe1 --target debug_gnufe_ffpcontract" -# Uncomment to have make run in verbose mode. -#verbose_make="-- VERBOSE=1" docker exec -it emscripten sh -c "emcmake cmake -B$BUILD_DIR . \ -D CMAKE_BUILD_TYPE=$CONFIGURATION \