From ead03044583cc5bb8eef33e7afd32f7bca447bd9 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Thu, 18 Jan 2024 10:46:32 +0100 Subject: [PATCH 1/6] unify --- CMakeLists.txt | 36 ++++++++++++++++++++---------------- src/xinterpreter.cpp | 1 + 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ded8abf..375b7cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,9 +48,8 @@ option(XEUS_NELSON_BUILD_EXECUTABLE "Build the xnelson executable" ON) option(XEUS_NELSON_USE_SHARED_XEUS "Link xnelson with the xeus shared library (instead of the static library)" ON) option(XEUS_NELSON_USE_SHARED_XEUS_NELSON "Link xnelson with the xeus-nelson shared library (instead of the static library)" ON) -option(XEUS_NELSON_EMSCRIPTEN_WASM_BUILD "Build for wasm with emscripten" OFF) -if (XEUS_NELSON_EMSCRIPTEN_WASM_BUILD) +if (EMSCRIPTEN) message(STATUS "Building with emscripten") set(XEUS_NELSON_BUILD_STATIC ON) set(XEUS_NELSON_BUILD_SHARED OFF) @@ -84,7 +83,7 @@ if (MSVC) endif () if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") - if (NOT XEUS_NELSON_EMSCRIPTEN_WASM_BUILD) + if (NOT EMSCRIPTEN) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter -Wextra -Wreorder") endif () @@ -171,7 +170,7 @@ macro(xnelson_set_kernel_options target_name) target_link_libraries(${target_name} PRIVATE xeus-nelson-static) endif() - if (NOT XEUS_NELSON_EMSCRIPTEN_WASM_BUILD) + if (NOT EMSCRIPTEN) find_package(Threads) target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endif () @@ -226,7 +225,7 @@ macro(xnelson_create_target target_name linkage output_name) target_link_libraries(${target_name} PRIVATE "-undefined dynamic_lookup") endif () - if (NOT XEUS_NELSON_EMSCRIPTEN_WASM_BUILD) + if (NOT EMSCRIPTEN) find_package(Threads) # TODO: add Threads as a dependence of xeus-static? target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endif () @@ -267,15 +266,18 @@ if (XEUS_NELSON_BUILD_EXECUTABLE) target_link_libraries(xnelson PRIVATE xeus-zmq) endif() -if (XEUS_NELSON_EMSCRIPTEN_WASM_BUILD) +if (EMSCRIPTEN) include(WasmBuildOptions) find_package(xeus-lite REQUIRED) - add_executable(xnelson_wasm src/main_emscripten_kernel.cpp) - target_link_libraries(xnelson_wasm PRIVATE xeus-nelson-static xeus-lite) - target_compile_features(xnelson_wasm PRIVATE cxx_std_17) - xnelson_set_kernel_options(xnelson_wasm) - xeus_wasm_compile_options(xnelson_wasm) - xeus_wasm_link_options(xnelson_wasm "web,worker") + add_executable(xnelson src/main_emscripten_kernel.cpp) + target_link_libraries(xnelson PRIVATE + xeus-lite + #xeus-nelson-static + ) + target_compile_features(xnelson PRIVATE cxx_std_17) + xnelson_set_kernel_options(xnelson) + xeus_wasm_compile_options(xnelson) + xeus_wasm_link_options(xnelson "web,worker") endif () # Installation @@ -302,7 +304,9 @@ endif () if (XEUS_NELSON_BUILD_EXECUTABLE) install(TARGETS xnelson RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() +if (XEUS_NELSON_BUILD_EXECUTABLE OR EMSCRIPTEN) # Configuration and data directories for jupyter and xeus-nelson set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory") @@ -348,12 +352,12 @@ if (XEUS_NELSON_BUILD_SHARED) DESTINATION ${XEUS_NELSON_CMAKECONFIG_INSTALL_DIR}) endif () -if(XEUS_NELSON_EMSCRIPTEN_WASM_BUILD) - install(TARGETS xnelson_wasm +if(EMSCRIPTEN) + install(TARGETS xnelson ARCHIVE DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES - "$/xnelson_wasm.js" - "$/xnelson_wasm.wasm" + "$/xnelson.js" + "$/xnelson.wasm" DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 5543695..21aadd0 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -36,6 +36,7 @@ namespace xeus_nelson } } + interpreter::~interpreter() { Nelson::destroyMainEvaluator(); From 159bb72ca10bb43c60f488f7919dc942763ec62b Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Thu, 18 Jan 2024 10:47:28 +0100 Subject: [PATCH 2/6] unify --- src/xinterpreter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 21aadd0..5543695 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -36,7 +36,6 @@ namespace xeus_nelson } } - interpreter::~interpreter() { Nelson::destroyMainEvaluator(); From 0bce329046a9a3c8448b91bb62ead5196a266fcb Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Thu, 18 Jan 2024 10:56:15 +0100 Subject: [PATCH 3/6] wasmci --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8be36f0..277bc0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -110,7 +110,7 @@ jobs: strategy: fail-fast: false matrix: - emsdk_ver: ["2.0.32", "3.1.2"] + emsdk_ver: ["3.1.45"] steps: - uses: actions/checkout@v2 @@ -133,7 +133,7 @@ jobs: emsdk activate ${{matrix.emsdk_ver}} source $CONDA_EMSDK_DIR/emsdk_env.sh - micromamba create -f environment-wasm-host.yml --platform=emscripten-32 + micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32 mkdir build pushd build From da8594fe0af930002bbc9df67e406fe6c0ff9441 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 19 Jan 2024 10:16:59 +0100 Subject: [PATCH 4/6] trigger From 49ee9115d9a656a8cce83a8833023771a505d34a Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 19 Jan 2024 10:21:27 +0100 Subject: [PATCH 5/6] fpic --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 375b7cb..655616c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ if (EMSCRIPTEN) set(XEUS_NELSON_BUILD_EXECUTABLE OFF) set(XEUS_NELSON_USE_SHARED_XEUS OFF) set(XEUS_NELSON_USE_SHARED_XEUS_NELSON OFF) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif () # Dependencies From 47f62dcabec2c44ff6151d468996142bdd1d36b0 Mon Sep 17 00:00:00 2001 From: DerThorsten Date: Fri, 19 Jan 2024 11:17:34 +0100 Subject: [PATCH 6/6] renamed targert --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfb9287..553480d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,13 +273,13 @@ endif() if (EMSCRIPTEN) include(WasmBuildOptions) find_package(xeus-lite REQUIRED) - add_executable(xnelson_wasm src/main_emscripten_kernel.cpp) - target_link_libraries(xnelson_wasm PRIVATE xeus-lite) - target_compile_features(xnelson_wasm PRIVATE cxx_std_17) - target_compile_options(xnelson_wasm PRIVATE -fPIC) - xnelson_set_kernel_options(xnelson_wasm) - xeus_wasm_compile_options(xnelson_wasm) - xeus_wasm_link_options(xnelson_wasm "web,worker") + add_executable(xnelson src/main_emscripten_kernel.cpp) + target_link_libraries(xnelson PRIVATE xeus-lite) + target_compile_features(xnelson PRIVATE cxx_std_17) + target_compile_options(xnelson PRIVATE -fPIC) + xnelson_set_kernel_options(xnelson) + xeus_wasm_compile_options(xnelson) + xeus_wasm_link_options(xnelson "web,worker") endif () # Installation