From b512234dff2aadb840391b48ad817ada66a4c3bf Mon Sep 17 00:00:00 2001 From: Richard Geldreich Date: Sat, 18 Jul 2026 19:33:48 -0400 Subject: [PATCH 1/2] webgl: build.sh --clean runs 'make clean' before wiping the CMake cache For a more thorough clean, --clean now runs `make clean` (removing the build outputs and object files via the existing build system) before deleting CMakeCache.txt/CMakeFiles and reconfiguring. Co-Authored-By: Claude Opus 4.8 --- webgl/build.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webgl/build.sh b/webgl/build.sh index 79eefbf..8e56543 100755 --- a/webgl/build.sh +++ b/webgl/build.sh @@ -57,7 +57,13 @@ build_one() { info "Building $name -> $1/build (make -j$JOBS)" mkdir -p "$dir" if [ "$CLEAN" -eq 1 ]; then - info " cleaning CMake cache" + # make clean first (removes build outputs + objects via the existing build system), + # then wipe the CMake cache/state so the next configure starts fresh (and picks up any -D changes). + if [ -f "$dir/Makefile" ]; then + info " make clean" + ( cd "$dir" && make clean ) || info " (make clean failed; wiping cache anyway)" + fi + info " removing CMake cache + build state" rm -rf "$dir/CMakeCache.txt" "$dir/CMakeFiles" fi ( cd "$dir" && emcmake cmake ../ "${CMAKE_ARGS[@]}" && make -j"$JOBS" ) From 018cc67cd06da18587b7a0b8114b3039978bdf71 Mon Sep 17 00:00:00 2001 From: Richard Geldreich Date: Sat, 18 Jul 2026 19:37:52 -0400 Subject: [PATCH 2/2] webgl: add --slow option to build.sh for a serial build --slow uses `make -j1` (one file at a time, the classic manual `make`) instead of the default `make -j$(nproc)`. Useful for readable output or constrained machines; parallel remains the default. Co-Authored-By: Claude Opus 4.8 --- webgl/build.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/webgl/build.sh b/webgl/build.sh index 8e56543..d3b38ff 100755 --- a/webgl/build.sh +++ b/webgl/build.sh @@ -8,7 +8,8 @@ # ./build.sh # build both (transcoder, then encoder) # ./build.sh transcoder # build only the transcoder # ./build.sh encoder # build only the encoder -# ./build.sh --clean # wipe each build dir's CMake cache first +# ./build.sh --clean # make clean + wipe CMake cache first (full rebuild) +# ./build.sh --slow # serial build (plain make, one file at a time) # ./build.sh encoder -DKTX2_ZSTANDARD=OFF -DCMAKE_BUILD_TYPE=Debug # # Any -D... argument is forwarded to cmake. Runnable from any directory. @@ -25,14 +26,16 @@ die() { printf '%serror:%s %s\n' "$B$R" "$N" "$*" >&2; exit 1; } # ---- parse args ---- CLEAN=0 +SLOW=0 TARGETS=() CMAKE_ARGS=() for a in "$@"; do case "$a" in -c|--clean) CLEAN=1 ;; + --slow) SLOW=1 ;; transcoder|encoder) TARGETS+=("$a") ;; -D*) CMAKE_ARGS+=("$a") ;; - -h|--help) sed -n '3,14p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; + -h|--help) sed -n '3,15p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; *) die "unknown argument: '$a' (try --help)" ;; esac done @@ -49,12 +52,14 @@ command -v emcmake >/dev/null 2>&1 || die "emcmake not found. Activate emsdk fir command -v cmake >/dev/null 2>&1 || die "cmake not found." JOBS="$(nproc 2>/dev/null || echo 4)" +# --slow => serial (one file at a time, the classic `make`); otherwise all cores. +if [ "$SLOW" -eq 1 ]; then MAKEJ=(-j1); JOBDESC="serial (make -j1)"; else MAKEJ=(-j"$JOBS"); JOBDESC="make -j$JOBS"; fi # ---- build one project ---- build_one() { local name="$1" dir="$WEBGL_DIR/$1/build" [ -f "$WEBGL_DIR/$1/CMakeLists.txt" ] || die "no CMakeLists.txt in webgl/$1" - info "Building $name -> $1/build (make -j$JOBS)" + info "Building $name -> $1/build ($JOBDESC)" mkdir -p "$dir" if [ "$CLEAN" -eq 1 ]; then # make clean first (removes build outputs + objects via the existing build system), @@ -66,7 +71,7 @@ build_one() { info " removing CMake cache + build state" rm -rf "$dir/CMakeCache.txt" "$dir/CMakeFiles" fi - ( cd "$dir" && emcmake cmake ../ "${CMAKE_ARGS[@]}" && make -j"$JOBS" ) + ( cd "$dir" && emcmake cmake ../ "${CMAKE_ARGS[@]}" && make "${MAKEJ[@]}" ) } # ---- go ----