Skip to content

Commit ce35626

Browse files
committed
Address reviews
1 parent 83f6d17 commit ce35626

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,7 @@ function(configure_kernel kernel)
152152
endfunction()
153153

154154
message("Configure kernels: ...")
155-
if(NOT EMSCRIPTEN)
156-
configure_kernel("/share/jupyter/kernels/xcpp17/")
157-
configure_kernel("/share/jupyter/kernels/xcpp20/")
158-
else()
155+
if(EMSCRIPTEN)
159156
# TODO: Currently jupyterlite-xeus and xeus-lite do not provide
160157
# methods to fetch information from the arguments present in the
161158
# generated emscripten kernel.
@@ -167,6 +164,9 @@ else()
167164
# 3) Finally we should fetch the C++ version from the kernel.json file and
168165
# be able to pass it to our wasm interpreter rather than forcing a version.
169166
configure_kernel("/share/jupyter/kernels/xcpp20/")
167+
else()
168+
configure_kernel("/share/jupyter/kernels/xcpp17/")
169+
configure_kernel("/share/jupyter/kernels/xcpp20/")
170170
endif()
171171

172172
# Source files
@@ -415,6 +415,8 @@ if(EMSCRIPTEN)
415415
xeus_cpp_set_kernel_options(xcpp)
416416
xeus_wasm_compile_options(xcpp)
417417
xeus_wasm_link_options(xcpp "web,worker")
418+
# TODO: Remove the exported runtime methods
419+
# after the next xeus release.
418420
target_link_options(xcpp PUBLIC
419421
-sEXPORTED_RUNTIME_METHODS=FS,PATH,ERRNO_CODES
420422
# add sysroot location here
@@ -423,7 +425,7 @@ if(EMSCRIPTEN)
423425
# TODO: Emscripten supports preloading files just once before it generates
424426
# the xcpp.data file (containing the binary representation of the file(s) we
425427
# want to include in our application).
426-
# Hence although we are adding supporting for Standard Headers, Libraries etc
428+
# Hence although we are adding support for Standard Headers, Libraries etc
427429
# through emscripten's sysroot for now, we need to do the following:
428430
# 1) Enable CppInterOp to provide us with a resource dir.
429431
# 2) If the above cannot be done, we can use the resource dir provided

include/xeus-cpp/xinterpreter_wasm.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ namespace xcpp
2222
wasm_interpreter();
2323
virtual ~wasm_interpreter() = default;
2424

25-
private:
26-
27-
static std::vector<const char*> create_args();
2825
};
2926
}
3027

src/xinterpreter.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717

1818
#include "xinput.hpp"
1919
#include "xinspect.hpp"
20-
#ifndef EMSCRIPTEN
2120
#include "xmagics/os.hpp"
2221
#include "xmagics/xassist.hpp"
23-
#endif
2422
#include "xparser.hpp"
2523
#include "xsystem.hpp"
2624

2725
using Args = std::vector<const char*>;
2826

2927
void* createInterpreter(const Args &ExtraArgs = {}) {
3028
Args ClangArgs = {/*"-xc++"*/"-v"}; // ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"};
31-
#ifndef EMSCRIPTEN
29+
#ifdef EMSCRIPTEN
30+
ClangArgs.push_back("-std=c++20");
31+
#else
3232
if (std::find_if(ExtraArgs.begin(), ExtraArgs.end(), [](const std::string& s) {
3333
return s == "-resource-dir";}) == ExtraArgs.end()) {
3434
std::string resource_dir = Cpp::DetectResourceDir();
@@ -99,8 +99,7 @@ __get_cxx_version ()
9999
auto cxx_version = Cpp::Evaluate(code);
100100
return std::to_string(cxx_version);
101101
#else
102-
constexpr int cxx_version = 20;
103-
return std::to_string(cxx_version);
102+
return "20";
104103
#endif
105104
}
106105

@@ -115,9 +114,11 @@ __get_cxx_version ()
115114
createInterpreter(Args(argv ? argv + 1 : argv, argv + argc));
116115
m_version = get_stdopt();
117116
redirect_output();
117+
#ifndef EMSCRIPTEN
118118
init_includes();
119119
init_preamble();
120120
init_magic();
121+
#endif
121122
}
122123

123124
interpreter::~interpreter()
@@ -362,9 +363,7 @@ __get_cxx_version ()
362363

363364
void interpreter::init_includes()
364365
{
365-
#ifndef EMSCRIPTEN
366366
Cpp::AddIncludePath((xeus::prefix_path() + "/include/").c_str());
367-
#endif
368367
}
369368

370369
void interpreter::init_preamble()
@@ -383,9 +382,7 @@ __get_cxx_version ()
383382
// preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("timeit",
384383
// timeit(&m_interpreter));
385384
// preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("python", pythonexec());
386-
#ifndef EMSCRIPTEN
387385
preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("xassist", xassist());
388386
preamble_manager["magics"].get_cast<xmagics_manager>().register_magic("file", writefile());
389-
#endif
390387
}
391388
}

src/xinterpreter_wasm.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ namespace xcpp
1717
{
1818

1919
wasm_interpreter::wasm_interpreter()
20-
: interpreter(create_args().size(), create_args().data())
20+
: interpreter(0, nullptr)
2121
{
2222
}
23-
24-
std::vector<const char*> wasm_interpreter::create_args()
25-
{
26-
static std::vector<const char*> Args = {"-Xclang", "-std=c++20"};
27-
return Args;
28-
}
2923
}

0 commit comments

Comments
 (0)