Skip to content

Commit

Permalink
Add post.js to include missing Emscripten APIs (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 authored Jan 16, 2025
1 parent 0747fb9 commit a643ea4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ if(EMSCRIPTEN)
xeus_wasm_link_options(xcpp "web,worker")
# TODO: Remove the exported runtime methods
# after the next xeus release.
target_link_options(xcpp PUBLIC
-sEXPORTED_RUNTIME_METHODS=FS,PATH,ERRNO_CODES
# add sysroot location here
--preload-file ${SYSROOT_PATH}/include@/include
target_link_options(xcpp
PUBLIC "SHELL: -s EXPORTED_RUNTIME_METHODS='[\"FS\",\"PATH\",\"LDSO\",\"loadDynamicLibrary\",\"ERRNO_CODES\"]'"
PUBLIC "SHELL: --preload-file ${SYSROOT_PATH}/include@/include"
PUBLIC "SHELL: --post-js ${CMAKE_CURRENT_SOURCE_DIR}/wasm_patches/post.js"
)
# TODO: Emscripten supports preloading files just once before it generates
# the xcpp.data file (containing the binary representation of the file(s) we
Expand Down
12 changes: 12 additions & 0 deletions wasm_patches/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if (!('wasmTable' in Module)) {
Module.wasmTable = wasmTable
}

Module.FS = FS
Module.PATH = PATH
Module.LDSO = LDSO
Module.getDylinkMetadata = getDylinkMetadata
Module.loadDynamicLibrary = loadDynamicLibrary

Module.UTF8ToString = UTF8ToString;
Module.ERRNO_CODES = ERRNO_CODES;

0 comments on commit a643ea4

Please sign in to comment.