Skip to content

Commit 72ac4b4

Browse files
committed
Specify needed shared libs in wasm kernel spec
1 parent 308d50b commit 72ac4b4

File tree

5 files changed

+50
-16
lines changed

5 files changed

+50
-16
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ jobs:
7575
micromamba activate xeus-lite-host
7676
python -m pip install jupyterlite-xeus jupyter_server notebook
7777
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
8078
8179
- name: Upload artifact
8280
uses: actions/upload-pages-artifact@v3

.github/workflows/main.yml

Lines changed: 0 additions & 2 deletions
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

Lines changed: 28 additions & 4 deletions
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,30 @@ function(configure_kernel kernel)
148148
COPYONLY)
149149
endfunction()
150150

151+
function(configure_wasm_kernel kernel)
152+
set(XEUS_CPP_PATH "$ENV{PATH}")
153+
set(XEUS_CPP_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}")
154+
set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/${CPPINTEROP_LLVM_VERSION_MAJOR})
155+
set(XEUS_CPP_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
156+
157+
configure_file (
158+
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}wasm_kernel.json.in"
159+
"${CMAKE_CURRENT_BINARY_DIR}${kernel}kernel.json")
160+
161+
configure_file (
162+
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-32x32.png"
163+
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
164+
COPYONLY)
165+
configure_file (
166+
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-64x64.png"
167+
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
168+
COPYONLY)
169+
configure_file (
170+
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-svg.svg"
171+
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
172+
COPYONLY)
173+
endfunction()
174+
151175
message("Configure kernels: ...")
152176
if(EMSCRIPTEN)
153177
# TODO: Currently jupyterlite-xeus and xeus-lite do not provide
@@ -160,10 +184,10 @@ if(EMSCRIPTEN)
160184
# to be able to deal with arguments present in kernel.json
161185
# 3) Finally we should fetch the C++ version from the kernel.json file and
162186
# be able to pass it to our wasm interpreter rather than forcing a version.
163-
configure_kernel("/share/jupyter/kernels/xcpp20/")
187+
configure_wasm_kernel("/share/jupyter/kernels/xcpp20/")
164188
else()
165-
configure_kernel("/share/jupyter/kernels/xcpp17/")
166-
configure_kernel("/share/jupyter/kernels/xcpp20/")
189+
configure_native_kernel("/share/jupyter/kernels/xcpp17/")
190+
configure_native_kernel("/share/jupyter/kernels/xcpp20/")
167191
endif()
168192

169193
# Source files

README.md

Lines changed: 0 additions & 8 deletions
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
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"display_name": "C++20",
3+
"env": {
4+
"PATH":"@XEUS_CPP_PATH@",
5+
"LD_LIBRARY_PATH":"@XEUS_CPP_LD_LIBRARY_PATH@"
6+
},
7+
"argv": [
8+
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
9+
"-f",
10+
"{connection_file}",
11+
"-resource-dir", "@XEUS_CPP_RESOURCE_DIR@",
12+
"-I", "@XEUS_CPP_INCLUDE_DIR@",
13+
"-std=c++20"
14+
],
15+
"language": "cpp",
16+
"metadata": {
17+
"debugger": false,
18+
"shared": {
19+
"libclangCppInterOp.so": "lib/libclangCppInterOp.so"
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)