Scaffold vpinball-wasm: Emscripten port of Visual Pinball
CI / Build wasm engine (push) Failing after 3m30s
CI / Publish to npm registry (push) Skipped

Build scripts, CMake/source patches, npm packaging, and a Gitea CI
workflow to compile the real Visual Pinball engine (SDL3 + WebGL2 +
libwinevbs for real VBScript) to WebAssembly.

The patches are validated end-to-end: the patched engine boots in a
real browser, loads a real .vpx table, compiles its real GLSL shaders,
computes environment map radiance, initializes physics, and starts the
VBScript engine, before hanging on the one deliberately-deferred piece
of work (game loop rewrite around emscripten_set_main_loop), documented
in the README's roadmap.
This commit is contained in:
2026-08-22 14:30:14 +02:00
commit 0a63835689
18 changed files with 1151 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
# Configures and builds vpinball itself for the new GL-emscripten CMake
# target, producing dist/vpinball.{js,wasm}.
#
# Requires: scripts/setup.sh and scripts/build-deps.sh have already run.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "$ROOT_DIR/scripts/versions.sh"
VPINBALL_DIR="$ROOT_DIR/vendor/vpinball"
DEPS_DIR="$ROOT_DIR/build/deps-wasm32"
BUILD_DIR="$ROOT_DIR/build/vpinball-wasm"
DIST_DIR="$ROOT_DIR/dist"
BUILD_TYPE="Release"
if [ "${1:-}" = "--debug" ]; then
BUILD_TYPE="Debug"
fi
if [ ! -d "$VPINBALL_DIR" ]; then
echo "ERROR: vendor/vpinball missing. Run scripts/setup.sh first." >&2
exit 1
fi
if [ ! -d "$DEPS_DIR/lib" ] || [ -z "$(ls -A "$DEPS_DIR/lib" 2>/dev/null)" ]; then
echo "ERROR: build/deps-wasm32 missing/empty. Run scripts/build-deps.sh first." >&2
exit 1
fi
if ! command -v emcc >/dev/null 2>&1; then
echo "ERROR: emcc not on PATH. Run: source $ROOT_DIR/emsdk/emsdk_env.sh" >&2
exit 1
fi
NUM_PROCS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)"
EMSCRIPTEN_LINK_FLAGS=(
-sUSE_WEBGL2=1
-sFULL_ES3=1
-sMIN_WEBGL_VERSION=2
-sMAX_WEBGL_VERSION=2
-sALLOW_MEMORY_GROWTH=1
-sMODULARIZE=1
-sEXPORT_NAME=VPinballModule
-sENVIRONMENT=web
-sEXPORTED_RUNTIME_METHODS=FS,ccall,cwrap
-sFORCE_FILESYSTEM=1
)
if [ "$BUILD_TYPE" = "Debug" ]; then
EMSCRIPTEN_LINK_FLAGS+=(-sASSERTIONS=1 -sEXIT_RUNTIME=1)
fi
emcmake cmake \
-S "$VPINBALL_DIR" \
-B "$BUILD_DIR" \
-DRENDERER=GL \
-DPLATFORM=emscripten \
-DARCH=wasm32 \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DVPINBALL_WASM_DEPS_DIR="$DEPS_DIR" \
-DCMAKE_EXE_LINKER_FLAGS="${EMSCRIPTEN_LINK_FLAGS[*]}"
cmake --build "$BUILD_DIR" -- -j"$NUM_PROCS"
mkdir -p "$DIST_DIR"
cp "$BUILD_DIR"/vpinball.js "$DIST_DIR/" 2>/dev/null || true
cp "$BUILD_DIR"/vpinball.wasm "$DIST_DIR/" 2>/dev/null || true
cp "$BUILD_DIR"/vpinball.data "$DIST_DIR/" 2>/dev/null || true
mkdir -p "$ROOT_DIR/package/assets"
cp "$VPINBALL_DIR/tests/assets/test000-default-table.vpx" "$ROOT_DIR/package/assets/default.vpx" 2>/dev/null || true
echo ""
echo "== build.sh complete =="
ls -la "$DIST_DIR"