Skip to content

Specify needed shared libs in wasm kernel spec #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/deploy-github-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ jobs:
- name: Jupyter Lite integration
shell: bash -l {0}
run: |
micromamba create -n xeus-lite-host jupyterlite-core
micromamba create -n xeus-lite-host jupyterlite-core jupyter_server
micromamba activate xeus-lite-host
python -m pip install jupyterlite-xeus jupyter_server notebook
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }} --contents notebooks/xeus-cpp-lite-demo.ipynb --output-dir dist
cp $PREFIX/bin/xcpp.data dist/extensions/@jupyterlite/xeus/static
cp $PREFIX/lib/libclangCppInterOp.so dist/extensions/@jupyterlite/xeus/static
python -m pip install jupyterlite-xeus
jupyter lite build \
--XeusAddon.prefix=${{ env.PREFIX }} \
--contents README.md \
--contents notebooks/xeus-cpp-lite-demo.ipynb \
--output-dir dist

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ jobs:
micromamba activate xeus-lite-host
python -m pip install jupyterlite-xeus
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }}
cp $PREFIX/bin/xcpp.data _output/extensions/@jupyterlite/xeus/static
cp $PREFIX/lib/libclangCppInterOp.so _output/extensions/@jupyterlite/xeus/static
Comment on lines -279 to -280

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see this being removed :D


- name: Setup tmate session
if: ${{ failure() && runner.debug }}
Expand Down
28 changes: 24 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH)
set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/")
endif ()

function(configure_kernel kernel)
function(configure_native_kernel kernel)
set(XEUS_CPP_PATH "$ENV{PATH}")
set(XEUS_CPP_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}")
set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/${CPPINTEROP_LLVM_VERSION_MAJOR})
Expand Down Expand Up @@ -148,6 +148,26 @@ function(configure_kernel kernel)
COPYONLY)
endfunction()

function(configure_wasm_kernel kernel)

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}wasm_kernel.json.in"
"${CMAKE_CURRENT_BINARY_DIR}${kernel}kernel.json")

configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-32x32.png"
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
COPYONLY)
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-64x64.png"
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
COPYONLY)
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}logo-svg.svg"
"${CMAKE_CURRENT_BINARY_DIR}${kernel}"
COPYONLY)
endfunction()

message("Configure kernels: ...")
if(EMSCRIPTEN)
# TODO: Currently jupyterlite-xeus and xeus-lite do not provide
Expand All @@ -160,10 +180,10 @@ if(EMSCRIPTEN)
# to be able to deal with arguments present in kernel.json
# 3) Finally we should fetch the C++ version from the kernel.json file and
# be able to pass it to our wasm interpreter rather than forcing a version.
configure_kernel("/share/jupyter/kernels/xcpp20/")
configure_wasm_kernel("/share/jupyter/kernels/xcpp20/")
else()
configure_kernel("/share/jupyter/kernels/xcpp17/")
configure_kernel("/share/jupyter/kernels/xcpp20/")
configure_native_kernel("/share/jupyter/kernels/xcpp17/")
configure_native_kernel("/share/jupyter/kernels/xcpp20/")
endif()

# Source files
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@ python -m pip install jupyterlite-xeus
jupyter lite build --XeusAddon.prefix=$PREFIX
```

We now need to shift necessary files like `xcpp.data` which contains the binary representation of the file(s)
we want to include in our application. As of now this would contain all important files like Standard Headers,
Libraries etc coming out of emscripten's sysroot. Assuming we are still inside build we should do the following
```bash
cp $PREFIX/bin/xcpp.data _output/extensions/@jupyterlite/xeus/static
cp $PREFIX/lib/libclangCppInterOp.so _output/extensions/@jupyterlite/xeus/static
```

Once the Jupyter Lite site has built you can test the website locally by executing
```bash
jupyter lite serve --XeusAddon.prefix=$PREFIX
Expand Down
16 changes: 16 additions & 0 deletions share/jupyter/kernels/xcpp20/wasm_kernel.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"display_name": "C++20",
"argv": [
"@XEUS_CPP_KERNELSPEC_PATH@xcpp",
"-f",
"{connection_file}",
"-std=c++20"
],
"language": "cpp",
"metadata": {
"debugger": false,
"shared": {
"libclangCppInterOp.so": "lib/libclangCppInterOp.so"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏽

}
}
}