Miguel de Benito Delgado 468b7aa46e 🐛 Fix render-wasm wrapper skipping compilation and copying
./build and pnpm run build:wasm produced no artifacts, dropped extra
Cargo arguments, and watch compiled outside the lock without copying.

Build now runs cargo build and copy_target_artifacts under the
existing lock. Cargo arguments survive as an array, and watch re-entry
no longer duplicates profile flags.
Destinations accept environment overrides so callers can stage
artifacts outside the public paths.

AI-assisted-by: deepseek-flash
2026-10-30 20:08:28 +01:00

48 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Usage: ./build [frontend|export] [extra cargo params...]
#
# With no target, builds both. Set BUILD_MODE=release (or NODE_ENV=production)
# for an optimized build. See `_build_env` for what each target changes.
_SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
_RENDER_TARGET=${1:-}
case "$_RENDER_TARGET" in
frontend|export) ;;
"")
# Each target needs its own `_build_env`, so re-enter per target.
for _target in frontend export; do
"$_SCRIPT_DIR/build" "$_target" "$@" || exit $?
done
exit 0
;;
*)
echo "ERROR: unknown render target '$_RENDER_TARGET' (expected 'frontend' or 'export')" >&2
exit 1
;;
esac
set -e -o pipefail
EMSDK_QUIET=1 . /opt/emsdk/emsdk_env.sh
pushd "$_SCRIPT_DIR" > /dev/null
export RENDER_TARGET="$_RENDER_TARGET"
. ./_build_env "$_RENDER_TARGET" "${@:2}"
. ./_build_lock
acquire_build_lock
set -x
setup
build
copy_target_artifacts
build
copy_target_artifacts
popd > /dev/null