Files
Ymir/core/cmake/Emscripten.cmake
vinihcrosaandClaude Opus 4.8 8a21003c37 feat(wasm): add @ymir/wasm package with Node-target Emscripten build
Package the physics engine as an internal @ymir/wasm workspace package
that runs in Node (worker_threads). Parametrize the Emscripten build
(YMIR_WASM_ENVIRONMENT=node, output dir override) so the same C++ core
builds for the server. Expose SimulationEngine interface +
createSimulationEngine() loader mirroring YmirBindings.cpp.

Task: task_01. Tests: 8 passing against the real WASM engine, 100% coverage.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-03 19:58:08 -03:00

32 lines
962 B
CMake

# Emscripten-specific build configuration
# Only included when CMAKE_SYSTEM_NAME == "Emscripten"
if(NOT EMSCRIPTEN)
message(FATAL_ERROR "Emscripten.cmake included but EMSCRIPTEN is not set")
endif()
# Target environment for the generated module. Default "worker" (web build).
# Set -DYMIR_WASM_ENVIRONMENT=node for the server-side (Node worker_thread) build.
if(NOT DEFINED YMIR_WASM_ENVIRONMENT)
set(YMIR_WASM_ENVIRONMENT "worker")
endif()
# Emscripten link flags for the WASM module
set(YMIR_EMSCRIPTEN_LINK_FLAGS
"-sEXPORT_ES6=1"
"-sMODULARIZE=1"
"-sEXPORT_NAME=createYmirModule"
"-sENVIRONMENT=${YMIR_WASM_ENVIRONMENT}"
"-sINITIAL_MEMORY=67108864" # 64 MiB
"-sALLOW_MEMORY_GROWTH=1"
"-sEXPORTED_RUNTIME_METHODS=ccall,cwrap"
"--bind" # Embind
"-sNO_FILESYSTEM=1"
"-O3"
)
# Disable warnings that don't apply to WASM target
add_compile_options(
-Wno-unused-command-line-argument
)