Skip to content

Commit 8cd6753

Browse files
authored
Add wasm build instructions to README.md (#102)
1 parent 54d588d commit 8cd6753

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
`xeus-cpp` is a Jupyter kernel for cpp based on the native implementation of the
1515
Jupyter protocol [xeus](https://github.com/jupyter-xeus/xeus).
1616

17-
## Installation within a mamba envirnoment (non wasm build instructions)
17+
## Installation within a mamba environment (non wasm build instructions)
1818

1919
To ensure that the installation works, it is preferable to install `xeus-cpp` in a
2020
fresh environment. It is also needed to use a
@@ -60,6 +60,55 @@ cd ..
6060
make install
6161
```
6262

63+
## Installation within a mamba environment (wasm build instructions)
64+
65+
First clone the repository, and move into that directory
66+
```bash
67+
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
68+
cd ./xeus-cpp
69+
```
70+
71+
Now you'll want to create a clean mamba environment containing the tools you'll need to do a wasm build. This can be done by executing
72+
the following
73+
```bash
74+
micromamba create -n "xeus-cpp-wasm-build" -y environment-wasm-build.yml
75+
```
76+
77+
You'll now want to make sure you're using emsdk version "3.1.45" and activate it. You can get this by executing the following
78+
```bash
79+
emsdk install 3.1.45
80+
emsdk activate 3.1.45
81+
source $CONDA_EMSDK_DIR/emsdk_env.sh
82+
```
83+
84+
You are now in a position to build the xeus-cpp kernel. You build it by executing the following
85+
```bash
86+
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
87+
mkdir build
88+
pushd build
89+
export EMPACK_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
90+
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
91+
export CMAKE_PREFIX_PATH=$PREFIX
92+
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
93+
94+
emcmake cmake \
95+
-DCMAKE_BUILD_TYPE=Release \
96+
-DCMAKE_PREFIX_PATH=$PREFIX \
97+
-DCMAKE_INSTALL_PREFIX=$PREFIX \
98+
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
99+
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
100+
..
101+
EMCC_CFLAGS='-sERROR_ON_UNDEFINED_SYMBOLS=0' emmake make install
102+
```
103+
104+
To test building Jupyter Lite with this kernel without creating a website you can execute the following
105+
```bash
106+
micromamba create -n xeus-lite-host jupyterlite-core
107+
micromamba activate xeus-lite-host
108+
python -m pip install jupyterlite-xeus
109+
jupyter lite build --XeusAddon.prefix=$PREFIX
110+
```
111+
63112
## Trying it online
64113

65114
To try out xeus-cpp interactively in your web browser, just click on the binder link:

0 commit comments

Comments
 (0)