diff --git a/CMakeLists.txt b/CMakeLists.txt index fdb4a63d..1deeaab9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,23 @@ include(CMakeSystemSpecificInformation) set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) +if (EMSCRIPTEN) + set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) + set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1") + set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1") + set(CMAKE_STRIP FALSE) +endif() + add_library(cppyy-backend SHARED clingwrapper/src/clingwrapper.cxx ) +if (EMSCRIPTEN) + target_link_options(cppyy-backend + PUBLIC "SHELL: -s WASM_BIGINT" + ) +endif() + # set_target_properties(cppyy-backend PROPERTIES VERSION ${PROJECT_VERSION}) # set_target_properties(cppyy-backend PROPERTIES PUBLIC_HEADER include/cpp_cppyy.h) diff --git a/clingwrapper/src/clingwrapper.cxx b/clingwrapper/src/clingwrapper.cxx index a66058e3..d6952a71 100644 --- a/clingwrapper/src/clingwrapper.cxx +++ b/clingwrapper/src/clingwrapper.cxx @@ -206,6 +206,7 @@ class ApplicationStarter { g_builtins.insert(name+a); } +#ifndef __EMSCRIPTEN__ // disable fast path if requested if (getenv("CPPYY_DISABLE_FASTPATH")) gEnableFastPath = false; @@ -230,6 +231,7 @@ class ApplicationStarter { Cpp::AddIncludePath((ClingBuildDir + "/include").c_str()); Cpp::AddIncludePath((std::string(CPPINTEROP_DIR) + "/include").c_str()); Cpp::LoadLibrary("libstdc++", /* lookup= */ true); +#endif // load frequently used headers const char* code = diff --git a/python/cppyy_backend/loader.py b/python/cppyy_backend/loader.py index e0f765b6..f3115902 100644 --- a/python/cppyy_backend/loader.py +++ b/python/cppyy_backend/loader.py @@ -19,7 +19,7 @@ if 'win32' in sys.platform: soext = '.dll' -elif 'linux' in sys.platform: +elif 'linux' in sys.platform or 'emscripten' in sys.platform: soext = '.so' else: soext = '.dylib'