Skip to content

Commit

Permalink
Cleanup additions to script.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCallow committed Aug 30, 2024
1 parent e49b2e7 commit 70513dc
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions scripts/build_wasm_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" ]
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 70513dc

Please sign in to comment.