Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(tests): the module road is the loading host's, so wasm does not walk it

yhh043dfb25cd24
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index ae52b9963..72ff431c7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -66,22 +66,33 @@ add_test(NAME test_aot_host COMMAND test_aot_host)
# The same compiled system as a LOADABLE module, which is the shape a native
# host takes. Built from the same two sources the harness links directly, so a
# difference between the two roads is the loading and nothing else.
-add_library(aot_move_system MODULE
- aot/generated/move_system.c
- aot/generated/move_system_decl.c
-)
-target_include_directories(aot_move_system PRIVATE
- ${CMAKE_SOURCE_DIR}/src/esengine/aot
- ${CMAKE_SOURCE_DIR}/tests/aot/generated
-)
-set_target_properties(aot_move_system PROPERTIES PREFIX "")
-add_dependencies(test_aot_host aot_move_system)
-# The path rather than a convention: where a MODULE lands differs by generator
-# and by platform, and a harness guessing it reports "cannot load" for a file
-# that was built perfectly.
-target_compile_definitions(test_aot_host PRIVATE
- ES_AOT_MODULE_PATH="$<TARGET_FILE:aot_move_system>"
-)
+#
+# Native only, and that is the design rather than a limitation: loading is the
+# road a host with dlopen takes, and the wasm road links the module into the
+# engine's own memory and reads a manifest beside it (AotModule.hpp says so at
+# the top). Emscripten turns a MODULE into a static archive, which no loader
+# opens -- so leaving this on made every wasm run fail "the platform could not
+# load it" for a file that was built exactly as asked. The harness gates its
+# loading cases on the define, so dropping it here drops them with it;
+# check-cpp-tests builds this target natively and is where they run.
+if(NOT EMSCRIPTEN)
+ add_library(aot_move_system MODULE
+ aot/generated/move_system.c
+ aot/generated/move_system_decl.c
+ )
+ target_include_directories(aot_move_system PRIVATE
+ ${CMAKE_SOURCE_DIR}/src/esengine/aot
+ ${CMAKE_SOURCE_DIR}/tests/aot/generated
+ )
+ set_target_properties(aot_move_system PROPERTIES PREFIX "")
+ add_dependencies(test_aot_host aot_move_system)
+ # The path rather than a convention: where a MODULE lands differs by generator
+ # and by platform, and a harness guessing it reports "cannot load" for a file
+ # that was built perfectly.
+ target_compile_definitions(test_aot_host PRIVATE
+ ES_AOT_MODULE_PATH="$<TARGET_FILE:aot_move_system>"
+ )
+endif()
# SparseSet tests
add_executable(test_sparse_set