@@ -84,7 +84,7 @@ if(EMSCRIPTEN)
8484    set (XEUS_CPP_USE_SHARED_XEUS_CPP OFF )
8585    set (XEUS_CPP_BUILD_TESTS OFF )
8686    # ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0) 
87-     set (EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES}  -s \" EXTRA_EXPORTED_RUNTIME_METHODS =[ENV']\" " )
87+     set (EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES}  -s \" EXPORTED_RUNTIME_METHODS =[ENV']\" " )
8888endif ()
8989
9090# Dependencies 
@@ -152,8 +152,22 @@ function(configure_kernel kernel)
152152endfunction ()
153153
154154message ("Configure kernels: ..." )
155- configure_kernel("/share/jupyter/kernels/xcpp17/" )
156- configure_kernel("/share/jupyter/kernels/xcpp20/" )
155+ if (NOT  EMSCRIPTEN)
156+     configure_kernel("/share/jupyter/kernels/xcpp17/" )
157+     configure_kernel("/share/jupyter/kernels/xcpp20/" )
158+ else ()
159+     # TODO: Currently jupyterlite-xeus and xeus-lite do not provide 
160+     # methods to fetch information from the arguments present in the 
161+     # generated emscripten kernel. 
162+     # The following needs to be done here : 
163+     # 1) We need to configure the kernel properly 
164+     #    Check issue https://github.com/compiler-research/xeus-cpp/issues/185. 
165+     # 2) Once the above is done we need to add support in jupyterlite-xeus & xeus-lite 
166+     #    to be able to deal with arguments present in kernel.json 
167+     # 3) Finally we should fetch the C++ version from the kernel.json file and 
168+     #    be able to pass it to our wasm interpreter rather than forcing a version. 
169+     configure_kernel("/share/jupyter/kernels/xcpp20/" )
170+ endif ()
157171
158172# Source files 
159173# ============ 
@@ -401,8 +415,22 @@ if(EMSCRIPTEN)
401415    xeus_cpp_set_kernel_options(xcpp)
402416    xeus_wasm_compile_options(xcpp)
403417    xeus_wasm_link_options(xcpp "web,worker" )
418+     target_link_options (xcpp PUBLIC 
419+         -sEXPORTED_RUNTIME_METHODS=FS,PATH ,ERRNO_CODES
420+         # add sysroot location here 
421+         --preload-file ${SYSROOT_PATH} /include @/include 
422+     )
423+     # TODO: Emscripten supports preloading files just once before it generates 
424+     # the xcpp.data file (containing the binary representation of the file(s) we 
425+     # want to include in our application). 
426+     # Hence although we are adding supporting for Standard Headers, Libraries etc 
427+     # through emscripten's sysroot for now, we need to do the following: 
428+     # 1) Enable CppInterOp to provide us with a resource dir. 
429+     # 2) If the above cannot be done, we can use the resource dir provided 
430+     #    by llvm on emscripten-forge but would involve adding a dependency. 
431+     # 3) Shift the resource dir and the sysroot to a common location. 
432+     # 4) Preload everything required together. 
404433endif ()
405- 
406434# Tests 
407435# ===== 
408436
0 commit comments