File tree Expand file tree Collapse file tree 5 files changed +27
-15
lines changed Expand file tree Collapse file tree 5 files changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ function(configure_native_kernel kernel)
148148endfunction ()
149149
150150function (configure_wasm_kernel kernel)
151-   set (XEUS_CPP_RESOURCE_DIR "/lib/clang/${CPPINTEROP_LLVM_VERSION_MAJOR} " )
151+   set (XEUS_CPP_RESOURCE_DIR "/lib/clang/${CPPINTEROP_LLVM_VERSION_MAJOR} "  PARENT_SCOPE )
152152
153153  configure_file  (
154154    "${CMAKE_CURRENT_SOURCE_DIR}${kernel} wasm_kernel.json.in" 
@@ -437,7 +437,7 @@ if(EMSCRIPTEN)
437437    xeus_wasm_link_options(xcpp "web,worker" )
438438    target_link_options (xcpp
439439        PUBLIC  "SHELL: --preload-file ${SYSROOT_PATH} /include@/include" 
440-         #  PUBLIC "SHELL: --preload-file ${CMAKE_INSTALL_PREFIX}${XEUS_CPP_RESOURCE_DIR}/include @${XEUS_CPP_RESOURCE_DIR}" 
440+         #PUBLIC "SHELL: --preload-file ${CMAKE_INSTALL_PREFIX}${XEUS_CPP_RESOURCE_DIR}@${XEUS_CPP_RESOURCE_DIR}" 
441441        PUBLIC  "SHELL: --preload-file ${XEUS_CPP_DATA_DIR} @/share/xeus-cpp" 
442442        PUBLIC  "SHELL: --preload-file ${XEUS_CPP_CONF_DIR} @/etc/xeus-cpp" 
443443        PUBLIC  "SHELL: --post-js ${CMAKE_CURRENT_SOURCE_DIR} /wasm_patches/post.js" 
Original file line number Diff line number Diff line change @@ -19,8 +19,7 @@ namespace xcpp
1919    {
2020    public: 
2121
22-         wasm_interpreter ();
23-         wasm_interpreter (int  argc, char ** argv);
22+         wasm_interpreter (int  argc = 0 , char ** argv = nullptr );
2423        virtual  ~wasm_interpreter () = default ;
2524
2625    };
Original file line number Diff line number Diff line change 1515
1616#include  " xeus-cpp/xinterpreter_wasm.hpp" 
1717
18+ template  <class  interpreter_type >
19+ static  interpreter_type* builder_with_args (emscripten::val js_args)
20+ {
21+     static  std::vector<std::string> args = emscripten::vecFromJSArray<std::string>(js_args);
22+     static  std::vector<const  char *> argv_vec;
23+ 
24+     for  (const  auto & s : args)
25+     {
26+         argv_vec.push_back (s.c_str ());
27+     }
28+ 
29+     int  argc = static_cast <int >(argv_vec.size ());
30+     char ** argv = const_cast <char **>(argv_vec.data ());
31+ 
32+     return  new  interpreter_type (argc, argv);
33+ }
34+ 
1835EMSCRIPTEN_BINDINGS (my_module)
1936{
2037    xeus::export_core ();
2138    using  interpreter_type = xcpp::wasm_interpreter;
22-     xeus::export_kernel<interpreter_type>(" xkernel" 
39+     xeus::export_kernel<interpreter_type, &builder_with_args<interpreter_type> >(" xkernel" 
2340}
Original file line number Diff line number Diff line change @@ -31,10 +31,12 @@ void* createInterpreter(const Args &ExtraArgs = {}) {
3131  if  (std::find_if (ExtraArgs.begin (), ExtraArgs.end (), [](const  std::string& s) {
3232    return  s == " -resource-dir" end ()) {
3333    std::string resource_dir = Cpp::DetectResourceDir ();
34-     if  (resource_dir.empty ())
35-       std::cerr << " Failed to detect the resource-dir\n " 
36-     ClangArgs.push_back (" -resource-dir" 
37-     ClangArgs.push_back (resource_dir.c_str ());
34+     if  (!resource_dir.empty ()) {
35+         ClangArgs.push_back (" -resource-dir" 
36+         ClangArgs.push_back (resource_dir.c_str ());
37+     } else  {
38+         std::cerr << " Failed to detect the resource-dir\n " 
39+     }
3840  }
3941  std::vector<std::string> CxxSystemIncludes;
4042  Cpp::DetectSystemCompilerIncludePaths (CxxSystemIncludes);
Original file line number Diff line number Diff line change 1515
1616namespace  xcpp 
1717{
18- 
19-     wasm_interpreter::wasm_interpreter ()
20-         : interpreter(0 , nullptr )
21-     {
22-     }
23- 
2418    wasm_interpreter::wasm_interpreter (int  argc, char ** argv)
2519        : interpreter(argc, argv)
2620    {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments