Skip to content

Commit dc14222

Browse files
authored
Add wasm build instructions to documentation (#196)
* Add wasm build instructions to documentation * Update wasm instructions to match readme.md
1 parent c2103eb commit dc14222

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

docs/source/InstallationAndUsage.rst

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Installation And Usage
22
--------------------
33

4-
Installation from source
4+
Installation from source (non wasm build instructions)
55
========================
66

77
To ensure that the installation works, it is preferable to install `xeus-cpp` in a
@@ -42,6 +42,68 @@ with a custom installation prefix if need be)
4242
-D CMAKE_INSTALL_LIBDIR=lib
4343
make && make install
4444
45+
Installation within a mamba environment (wasm build instructions)
46+
========================
47+
48+
These instructions will assume you have cmake installed on your system. First clone the repository, and move into that directory
49+
.. code-block:: bash
50+
git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git
51+
cd ./xeus-cpp
52+
53+
54+
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
55+
56+
.. code-block:: bash
57+
cd $HOME
58+
git clone https://github.com/emscripten-core/emsdk.git
59+
cd emsdk
60+
./emsdk install 3.1.45
61+
./emsdk activate 3.1.45
62+
source $HOME/emsdk/emsdk_env.sh
63+
64+
65+
You are now in a position to build the xeus-cpp kernel. You build it by executing the following
66+
67+
.. code-block:: bash
68+
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
69+
mkdir build
70+
pushd build
71+
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
72+
export CMAKE_PREFIX_PATH=$PREFIX
73+
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
74+
export SYSROOT_PATH=$HOME/emsdk/upstream/emscripten/cache/sysroot
75+
emcmake cmake \
76+
-DCMAKE_BUILD_TYPE=Release \
77+
-DCMAKE_PREFIX_PATH=$PREFIX \
78+
-DCMAKE_INSTALL_PREFIX=$PREFIX \
79+
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
80+
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
81+
-DSYSROOT_PATH=$SYSROOT_PATH \
82+
..
83+
emmake make install
84+
85+
86+
To build Jupyter Lite with this kernel without creating a website you can execute the following
87+
88+
.. code-block:: bash
89+
micromamba create -n xeus-lite-host jupyterlite-core
90+
micromamba activate xeus-lite-host
91+
python -m pip install jupyterlite-xeus
92+
jupyter lite build --XeusAddon.prefix=$PREFIX
93+
94+
We now need to shift necessary files like `xcpp.data` which contains the binary representation of the file(s)
95+
we want to include in our application. As of now this would contain all important files like Standard Headers,
96+
Libraries etc coming out of emscripten's sysroot. Assuming we are still inside build we should do the following
97+
98+
.. code-block:: bash
99+
cp $PREFIX/bin/xcpp.data _output/extensions/@jupyterlite/xeus/static
100+
cp $PREFIX/lib/libclangCppInterOp.so _output/extensions/@jupyterlite/xeus/static
101+
102+
Once the Jupyter Lite site has built you can test the website locally by executing
103+
104+
.. code-block:: bash
105+
jupyter lite serve --XeusAddon.prefix=$PREFIX
106+
45107
Installing from conda-forge
46108
===========================
47109

@@ -51,4 +113,4 @@ If you have conda installed then you can install xeus-cpp using the follwing com
51113
52114
conda install conda-forge::xeus-cpp
53115
54-
Xeus-cpp is available for Linux, MacOS and Windows.
116+
Xeus-cpp is available for Linux, MacOS and Windows.

0 commit comments

Comments
 (0)