Fix Asyncify and improve build process

Build system improvements:
- Add wasm-opt stub for Docker build to bypass asyncify in container
- Add apply-asyncify.sh script for host-side asyncify transformation
- Update build-pcbnew.sh to install wasm-opt stub and add EXPORTED_RUNTIME_METHODS
- Add --with-zlib=sys to wxWidgets configure for proper zlib linking
- Improve update-baseline-screenshots.sh to only copy new/significantly changed files

wxWidgets submodule update:
- Fix EM_JS to EM_ASYNC_JS for proper Asyncify registration

Test updates:
- Add new baseline screenshots for bitmapbuttons, dnd, gridrenderers, printpreview, specialized tests
- Add kicad-pcbnew initial screenshot
- Fix wxgrid-controls.png and wxgrid-dedicated-page.png (were showing errors)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2025-12-14 11:59:50 +01:00
commit 6771e7de74
44 changed files with 167 additions and 32 deletions

View file

@ -11,11 +11,6 @@ set -e
cd "$(dirname "$0")/.."
# Get wasm-opt (downloads Binaryen v121 if not cached)
echo "Checking wasm-opt..."
WASM_OPT=$(./scripts/common/get-wasm-opt.sh)
echo "Using: ${WASM_OPT}"
# Start container if not running
docker compose -f docker/docker-compose.yml up -d
@ -29,21 +24,8 @@ docker compose -f docker/docker-compose.yml exec kicad-wasm-builder \
bash -c "mkdir -p /workspace/output && cp /workspace/build-wasm/kicad-pcbnew/pcbnew/pcbnew.{js,wasm,wasm.map,worker.js} /workspace/output/ 2>/dev/null || cp /workspace/build-wasm/kicad-pcbnew/pcbnew/pcbnew.{js,wasm} /workspace/output/"
# Apply asyncify transformation on host
# This is done on the host because wasm-opt --asyncify needs 50GB+ RAM for KiCad,
# which exceeds typical Docker memory limits
echo ""
echo "Applying asyncify transformation on host..."
echo "This may take several minutes and use significant RAM..."
# Asyncify import patterns (functions that trigger async suspension)
# - env.invoke_* : Exception handling trampolines
# - env.__asyncjs__* : EM_ASYNC_JS functions
ASYNCIFY_IMPORTS="env.invoke_*,env.__asyncjs__*"
"${WASM_OPT}" --asyncify \
--pass-arg=asyncify-imports@${ASYNCIFY_IMPORTS} \
--pass-arg=asyncify-propagate-addlist \
output/pcbnew.wasm -o output/pcbnew.wasm
# This is done on the host because wasm-opt --asyncify needs significant RAM
./scripts/common/apply-asyncify.sh output/pcbnew.wasm output/pcbnew.wasm
echo ""
echo "Build complete. Output files in ./output/"