Merge pull request #3184 from MatiasManevi:single-thread-npm

PiperOrigin-RevId: 886334046
Change-Id: If054286ac11f2b0e13e770922c049e334d136ab1
This commit is contained in:
Copybara-Service
2026-03-19 13:05:52 -07:00
4 changed files with 86 additions and 6 deletions
+9 -2
View File
@@ -31,11 +31,11 @@ if(NOT MUJOCO_WASM_FILES)
message(FATAL_ERROR "No source files found in codegen/generated/")
endif()
option(MUJOCO_WASM_THREADS "Build with multi-threading support" ON)
# Set Emscripten linker flags
set(EMCC_LINKER_FLAGS
"--bind"
"-pthread"
"-s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency"
"-s ASSERTIONS=1"
"-s ALLOW_MEMORY_GROWTH=1"
"-s EXPORT_ES6=1"
@@ -48,6 +48,13 @@ set(EMCC_LINKER_FLAGS
"-g"
"--emit-tsd mujoco.d.ts"
)
if(MUJOCO_WASM_THREADS)
list(APPEND EMCC_LINKER_FLAGS
"-pthread"
"-s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency"
)
add_definitions(-DMUJOCO_WASM_THREADS)
endif()
string (REPLACE ";" " " EMCC_LINKER_FLAGS_STR "${EMCC_LINKER_FLAGS}")
add_executable(mujoco_wasm ${MUJOCO_WASM_FILES})