fix(docker): Replace emsdk image with Ubuntu + emsdk from source

The Docker build used emscripten/emsdk:4.0.2-arm64 as base image but
env.sh couldn't find emsdk there, installing a second copy. The build
then applied wasm-opt/finalize stubs to the wrong emsdk (hardcoded
/emsdk/), so the real wasm-emscripten-finalize ran in Docker and got
OOM-killed.

- Use ubuntu:22.04 base with emsdk installed from source at /emsdk/
- Make stub paths dynamic via $EMSDK instead of hardcoded /emsdk/
- Skip local emsdk install in env.sh when $EMSDK is already active

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-03-19 12:44:26 +01:00
commit d557b21eac
3 changed files with 39 additions and 16 deletions

View file

@ -36,18 +36,26 @@ export WX_BUILD="$BUILD_ROOT/wxwidgets-universal"
# Emscripten settings
export EMSDK_QUIET=1
# Local emsdk: auto-install if missing, then source its environment
# The emsdk bundles its own Python, Node, and LLVM — no Homebrew needed
_EMSDK_DIR="$_KICAD_WASM_PROJECT_ROOT/tools/emsdk"
_EMSDK_ENV="$_EMSDK_DIR/emsdk_env.sh"
# Emscripten SDK setup
# If EMSDK is already set (e.g. Docker entrypoint sourced emsdk_env.sh), use it.
# Otherwise auto-install a local copy under tools/emsdk/.
if [ -n "$EMSDK" ] && [ -f "$EMSDK/emsdk_env.sh" ]; then
# emsdk already active (e.g., Docker entrypoint sourced it)
source "$EMSDK/emsdk_env.sh" 2>/dev/null
else
# Local emsdk: auto-install if missing, then source its environment
# The emsdk bundles its own Python, Node, and LLVM — no Homebrew needed
_EMSDK_DIR="$_KICAD_WASM_PROJECT_ROOT/tools/emsdk"
_EMSDK_ENV="$_EMSDK_DIR/emsdk_env.sh"
if [ ! -f "$_EMSDK_ENV" ]; then
echo "Emscripten SDK not found. Installing..."
"$_KICAD_WASM_SCRIPTS_DIR/setup-emsdk.sh"
fi
if [ ! -f "$_EMSDK_ENV" ]; then
echo "Emscripten SDK not found. Installing..."
"$_KICAD_WASM_SCRIPTS_DIR/setup-emsdk.sh"
fi
if [ -f "$_EMSDK_ENV" ]; then
source "$_EMSDK_ENV" 2>/dev/null
if [ -f "$_EMSDK_ENV" ]; then
source "$_EMSDK_ENV" 2>/dev/null
fi
fi
# Common compiler flags