diff --git a/.github/workflows/deploy-github-page.yml b/.github/workflows/deploy-github-page.yml index ed063653..1bfca783 100644 --- a/.github/workflows/deploy-github-page.yml +++ b/.github/workflows/deploy-github-page.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ee31bfb..fd0ebf8c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 - name: Setup tmate session if: ${{ failure() && runner.debug }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 57066a80..0a9248a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) @@ -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 @@ -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 diff --git a/README.md b/README.md index bb143784..c987a379 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/share/jupyter/kernels/xcpp20/wasm_kernel.json.in b/share/jupyter/kernels/xcpp20/wasm_kernel.json.in new file mode 100644 index 00000000..697e46a9 --- /dev/null +++ b/share/jupyter/kernels/xcpp20/wasm_kernel.json.in @@ -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" + } + } +}