Skip to content

Commit 60c35b8

Browse files
committed
Attempt to fix wasm build
1 parent 7c7d42d commit 60c35b8

File tree

6 files changed

+73
-98
lines changed

6 files changed

+73
-98
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
call C:\Users\runneradmin\micromamba-root\condabin\micromamba.bat activate xeus-cpp
9090
mkdir -p bld
9191
cd bld
92-
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DXEUS_BUILD_TESTS=ON -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%"
92+
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DXEUS_BUILD_TESTS=ON -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%"
9393
9494
- name: build
9595
shell: cmd
@@ -106,104 +106,14 @@ jobs:
106106
cd test
107107
pytest . --reruns 5
108108
109-
emscripten_wasm_docker:
110-
runs-on: ubuntu-20.04
111-
112-
strategy:
113-
fail-fast: false
114-
matrix:
115-
container: ["emscripten/emsdk:2.0.34", "emscripten/emsdk:3.1.3", "emscripten/emsdk:latest"]
116-
117-
118-
container: ${{ matrix.container}}
119-
120-
steps:
121-
- uses: actions/checkout@v2
122-
123-
- name: Verify emscripten
124-
run: emcc -v
125-
126-
- name: "install xtl"
127-
run: |
128-
mkdir -p /opt/xtl/build
129-
git clone https://github.com/xtensor-stack/xtl.git /opt/xtl/src
130-
cd /opt/xtl/src
131-
git checkout 0.7.2
132-
cd /opt/xtl/build
133-
emcmake cmake ../src/ -DCMAKE_INSTALL_PREFIX=/custom_sysroot
134-
emmake make -j2 install
135-
136-
- name: "install nlohmann-json"
137-
run: |
138-
mkdir -p /opt/nlohmannjson/build
139-
git clone https://github.com/nlohmann/json.git /opt/nlohmannjson/src
140-
cd /opt/nlohmannjson/src
141-
git checkout v3.9.0
142-
cd /opt/nlohmannjson/build
143-
emcmake cmake ../src/ -DJSON_BuildTests=OFF -DCMAKE_INSTALL_PREFIX=/custom_sysroot
144-
emmake make -j2 install
145-
146-
- name: "install xeus"
147-
run: |
148-
mkdir -p /opt/xeus/build
149-
git clone https://github.com/jupyter-xeus/xeus.git /opt/xeus/src
150-
cd /opt/xeus/build
151-
emcmake cmake ../src \
152-
-DXEUS_EMSCRIPTEN_WASM_BUILD=ON \
153-
-DCMAKE_INSTALL_PREFIX=/custom_sysroot\
154-
-Dxtl_DIR=/custom_sysroot/share/cmake/xtl \
155-
-Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json
156-
157-
emmake make -j2
158-
emmake make -j2 install
159-
160-
- name: "install xeus-lite"
161-
run: |
162-
mkdir -p /opt/xeus-lite/build
163-
git clone https://github.com/jupyter-xeus/xeus-lite.git /opt/xeus-lite/src
164-
cd /opt/xeus-lite/build
165-
emcmake cmake ../src \
166-
-DXEUS_EMSCRIPTEN_WASM_BUILD=ON \
167-
-DCMAKE_INSTALL_PREFIX=/custom_sysroot \
168-
-Dxtl_DIR=/custom_sysroot/share/cmake/xtl \
169-
-Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json \
170-
-Dxeus_DIR=/custom_sysroot/lib/cmake/xeus
171-
emmake make -j2
172-
emmake make -j2 install
173-
174-
- name: cmake configure rendered project
175-
shell: bash -l {0}
176-
run: |
177-
mkdir -p bld
178-
cd bld
179-
emcmake cmake .. \
180-
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
181-
-Dxtl_DIR=/custom_sysroot/share/cmake/xtl \
182-
-Dnlohmann_json_DIR=/custom_sysroot/lib/cmake/nlohmann_json \
183-
-Dxeus_DIR=/custom_sysroot/lib/cmake/xeus \
184-
-Dxeus-lite_DIR=/custom_sysroot/lib/cmake/xeus-lite \
185-
-DCMAKE_INSTALL_PREFIX=/custom_sysroot
186-
187-
- name: build rendered project
188-
shell: bash -l {0}
189-
run: |
190-
cd bld
191-
emmake make -j2
192-
193-
- name: install rendered project
194-
shell: bash -l {0}
195-
run: |
196-
cd bld
197-
make install
198-
199109
emscripten_wasm:
200110

201111
runs-on: ubuntu-latest
202112

203113
strategy:
204114
fail-fast: false
205115
matrix:
206-
emsdk_ver: ["2.0.34", "3.1.3"]
116+
emsdk_ver: ["3.1.45"]
207117

208118
steps:
209119
- uses: actions/checkout@v2
@@ -224,7 +134,7 @@ jobs:
224134
run: |
225135
emsdk activate ${{matrix.emsdk_ver}}
226136
source $CONDA_EMSDK_DIR/emsdk_env.sh
227-
micromamba create -f environment-wasm-host.yml --platform=emscripten-32
137+
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
228138
229139
mkdir build
230140
pushd build
@@ -241,4 +151,4 @@ jobs:
241151
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
242152
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
243153
..
244-
make -j5
154+
EMCC_CFLAGS='-sERROR_ON_UNDEFINED_SYMBOLS=0' emmake make -j5

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ if(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
295295
include(WasmBuildOptions)
296296
find_package(xeus-lite REQUIRED)
297297
add_executable(xcpp_wasm src/main_emscripten_kernel.cpp )
298-
target_link_libraries(xcpp_wasm PRIVATE xeus-cpp-static xeus-lite)
299-
XEUS_CPP_set_kernel_options(xcpp_wasm)
298+
target_link_libraries(xcpp_wasm PRIVATE xeus-lite)
299+
xeus_cpp_set_kernel_options(xcpp_wasm)
300300
xeus_wasm_compile_options(xcpp_wasm)
301301
xeus_wasm_link_options(xcpp_wasm "web,worker")
302302
endif()

environment-wasm-host.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ dependencies:
77
- xeus-lite
88
- xeus >=3.0.5,<4.0
99
- xtl >=0.7,<0.8
10+
- llvm =16.0.6
11+
- cpp-argparse
12+
- pugixml
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/************************************************************************************
2+
* Copyright (c) 2023, xeus-cpp contributors *
3+
* Copyright (c) 2023, Johan Mabille, Loic Gouarin, Sylvain Corlay, Wolf Vollprecht *
4+
* *
5+
* Distributed under the terms of the BSD 3-Clause License. *
6+
* *
7+
* The full license is in the file LICENSE, distributed with this software. *
8+
************************************************************************************/
9+
10+
11+
#ifndef XEUS_CPP_INTERPRETER_WASM_HPP
12+
#define XEUS_CPP_INTERPRETER_WASM_HPP
13+
14+
#include "xinterpreter.hpp"
15+
#include "xeus_cpp_config.hpp"
16+
17+
namespace xcpp
18+
{
19+
class XEUS_CPP_API wasm_interpreter : public interpreter
20+
{
21+
public:
22+
23+
wasm_interpreter();
24+
virtual ~wasm_interpreter();
25+
26+
private:
27+
28+
void configure_impl() override;
29+
};
30+
}
31+
32+
#endif

src/main_emscripten_kernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
#include <xeus/xembind.hpp>
1515

16-
#include "xeus-cpp/xinterpreter.hpp"
16+
#include "xeus-cpp/xinterpreter_wasm.hpp"
1717

1818
EMSCRIPTEN_BINDINGS(my_module)
1919
{
2020
xeus::export_core();
21-
using interpreter_type = xcpp::interpreter;
21+
using interpreter_type = xcpp::wasm_interpreter;
2222
xeus::export_kernel<interpreter_type>("xkernel");
2323
}

src/xinterpreter_wasm.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/************************************************************************************
2+
* Copyright (c) 2023, xeus-cpp contributors *
3+
* Copyright (c) 2023, Martin Vassilev *
4+
* *
5+
* Distributed under the terms of the BSD 3-Clause License. *
6+
* *
7+
* The full license is in the file LICENSE, distributed with this software. *
8+
************************************************************************************/
9+
10+
#include "xeus/xinterpreter.hpp"
11+
#include "xeus/xsystem.hpp"
12+
13+
#include "xeus-cpp/xinterpreter.hpp"
14+
#include "xeus-cpp/xinterpreter_wasm.hpp"
15+
16+
namespace xcpp
17+
{
18+
19+
wasm_interpreter::wasm_interpreter()
20+
: interpreter(0, nullptr)
21+
22+
wasm_interpreter::~wasm_interpreter()
23+
{
24+
}
25+
26+
void wasm_interpreter::configure_impl()
27+
{
28+
interpreter::configure_impl();
29+
}
30+
}

0 commit comments

Comments
 (0)