Skip to content

Commit 1904838

Browse files
authored
Specify needed shared libs in wasm kernel spec (#221)
* Specify needed shared libs in wasm kernel spec
1 parent a643ea4 commit 1904838

File tree

5 files changed

+47
-19
lines changed

5 files changed

+47
-19
lines changed

.github/workflows/deploy-github-page.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ jobs:
7171
- name: Jupyter Lite integration
7272
shell: bash -l {0}
7373
run: |
74-
micromamba create -n xeus-lite-host jupyterlite-core
74+
micromamba create -n xeus-lite-host jupyterlite-core jupyter_server
7575
micromamba activate xeus-lite-host
76-
python -m pip install jupyterlite-xeus jupyter_server notebook
77-
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }} --contents notebooks/xeus-cpp-lite-demo.ipynb --output-dir dist
78-
cp $PREFIX/bin/xcpp.data dist/extensions/@jupyterlite/xeus/static
79-
cp $PREFIX/lib/libclangCppInterOp.so dist/extensions/@jupyterlite/xeus/static
76+
python -m pip install jupyterlite-xeus
77+
jupyter lite build \
78+
--XeusAddon.prefix=${{ env.PREFIX }} \
79+
--contents README.md \
80+
--contents notebooks/xeus-cpp-lite-demo.ipynb \
81+
--output-dir dist
8082
8183
- name: Upload artifact
8284
uses: actions/upload-pages-artifact@v3

.github/workflows/main.yml

-2
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ jobs:
276276
micromamba activate xeus-lite-host
277277
python -m pip install jupyterlite-xeus
278278
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }}
279-
cp $PREFIX/bin/xcpp.data _output/extensions/@jupyterlite/xeus/static
280-
cp $PREFIX/lib/libclangCppInterOp.so _output/extensions/@jupyterlite/xeus/static
281279
282280
- name: Setup tmate session
283281
if: ${{ failure() && runner.debug }}

CMakeLists.txt

+24-4
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH)
116116
set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/")
117117
endif ()
118118

119-
function(configure_kernel kernel)
119+
function(configure_native_kernel kernel)
120120
set(XEUS_CPP_PATH "$ENV{PATH}")
121121
set(XEUS_CPP_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}")
122122
set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/${CPPINTEROP_LLVM_VERSION_MAJOR})
@@ -148,6 +148,26 @@ function(configure_kernel kernel)
148148
COPYONLY)
149149
endfunction()
150150

151+
function(configure_wasm_kernel kernel)
152+
153+
configure_file (
154+
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}wasm_kernel.json.in"
155+
"${CMAKE_CURRENT_BINARY_DIR}${kernel}kernel.json")
156+
157+
configure_file (
158+
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-32x32.png"
159+
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
160+
COPYONLY)
161+
configure_file (
162+
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-64x64.png"
163+
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
164+
COPYONLY)
165+
configure_file (
166+
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-svg.svg"
167+
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
168+
COPYONLY)
169+
endfunction()
170+
151171
message("Configure kernels: ...")
152172
if(EMSCRIPTEN)
153173
# TODO: Currently jupyterlite-xeus and xeus-lite do not provide
@@ -160,10 +180,10 @@ if(EMSCRIPTEN)
160180
# to be able to deal with arguments present in kernel.json
161181
# 3) Finally we should fetch the C++ version from the kernel.json file and
162182
# be able to pass it to our wasm interpreter rather than forcing a version.
163-
configure_kernel("/share/jupyter/kernels/xcpp20/")
183+
configure_wasm_kernel("/share/jupyter/kernels/xcpp20/")
164184
else()
165-
configure_kernel("/share/jupyter/kernels/xcpp17/")
166-
configure_kernel("/share/jupyter/kernels/xcpp20/")
185+
configure_native_kernel("/share/jupyter/kernels/xcpp17/")
186+
configure_native_kernel("/share/jupyter/kernels/xcpp20/")
167187
endif()
168188

169189
# Source files

README.md

-8
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ python -m pip install jupyterlite-xeus
105105
jupyter lite build --XeusAddon.prefix=$PREFIX
106106
```
107107

108-
We now need to shift necessary files like `xcpp.data` which contains the binary representation of the file(s)
109-
we want to include in our application. As of now this would contain all important files like Standard Headers,
110-
Libraries etc coming out of emscripten's sysroot. Assuming we are still inside build we should do the following
111-
```bash
112-
cp $PREFIX/bin/xcpp.data _output/extensions/@jupyterlite/xeus/static
113-
cp $PREFIX/lib/libclangCppInterOp.so _output/extensions/@jupyterlite/xeus/static
114-
```
115-
116108
Once the Jupyter Lite site has built you can test the website locally by executing
117109
```bash
118110
jupyter lite serve --XeusAddon.prefix=$PREFIX
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"display_name": "C++20",
3+
"argv": [
4+
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
5+
"-f",
6+
"{connection_file}",
7+
"-std=c++20"
8+
],
9+
"language": "cpp",
10+
"metadata": {
11+
"debugger": false,
12+
"shared": {
13+
"libclangCppInterOp.so": "lib/libclangCppInterOp.so"
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)