Skip to content

Commit a643ea4

Browse files
authored
Add post.js to include missing Emscripten APIs (#220)
1 parent 0747fb9 commit a643ea4

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,10 @@ if(EMSCRIPTEN)
414414
xeus_wasm_link_options(xcpp "web,worker")
415415
# TODO: Remove the exported runtime methods
416416
# after the next xeus release.
417-
target_link_options(xcpp PUBLIC
418-
-sEXPORTED_RUNTIME_METHODS=FS,PATH,ERRNO_CODES
419-
# add sysroot location here
420-
--preload-file ${SYSROOT_PATH}/include@/include
417+
target_link_options(xcpp
418+
PUBLIC "SHELL: -s EXPORTED_RUNTIME_METHODS='[\"FS\",\"PATH\",\"LDSO\",\"loadDynamicLibrary\",\"ERRNO_CODES\"]'"
419+
PUBLIC "SHELL: --preload-file ${SYSROOT_PATH}/include@/include"
420+
PUBLIC "SHELL: --post-js ${CMAKE_CURRENT_SOURCE_DIR}/wasm_patches/post.js"
421421
)
422422
# TODO: Emscripten supports preloading files just once before it generates
423423
# the xcpp.data file (containing the binary representation of the file(s) we

wasm_patches/post.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if (!('wasmTable' in Module)) {
2+
Module.wasmTable = wasmTable
3+
}
4+
5+
Module.FS = FS
6+
Module.PATH = PATH
7+
Module.LDSO = LDSO
8+
Module.getDylinkMetadata = getDylinkMetadata
9+
Module.loadDynamicLibrary = loadDynamicLibrary
10+
11+
Module.UTF8ToString = UTF8ToString;
12+
Module.ERRNO_CODES = ERRNO_CODES;

0 commit comments

Comments
 (0)