Skip to content

Commit ae46678

Browse files
author
kr-2003
committed
Merge branch 'main' into jit-oop-exec
2 parents 10c8c06 + 951e670 commit ae46678

22 files changed

+1086
-161
lines changed

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

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
pushd build
5252
5353
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
54+
echo "BUILD_PREFIX=$BUILD_PREFIX" >> $GITHUB_ENV
5455
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
5556
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
5657
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
@@ -61,19 +62,92 @@ jobs:
6162
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
6263
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
6364
-DSYSROOT_PATH=$SYSROOT_PATH \
65+
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON \
6466
..
6567
emmake make -j ${{ env.ncpus }} install
6668
69+
- name: Test xeus-cpp C++ Emscripten
70+
shell: bash -l {0}
71+
run: |
72+
set -e
73+
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyter_server jupyterlite-xeus
74+
micromamba activate xeus-lite-host
75+
cd build/test
76+
# Fresh install browsers, and run Emscripten tests in them
77+
# This is to match the Emscripten build instructions, where
78+
# we run in a fresh browser, to stop any extra installed
79+
# stuff interferring with the running of the tests
80+
# Explaination of options for emrun
81+
# --browser (name of browser on path)
82+
# --kill_exit makes it so that when emrun finishes,
83+
# that the headless browser we create is killed along with it
84+
# --timeout 60 is such that emrun is killed after 60 seconds if
85+
# still running. emrun should have finished long before then,
86+
# so if it is still running, something went wrong (such as a test
87+
# which crashed the html file). This will cause the ci to fail,
88+
# as a non 0 value of will be returned.
89+
# In the case of Chrome we have the extra --no-sandbox flag, as on
90+
# Ubuntu Chrome will refuse to run otherwise, as it expects to have
91+
# been installed with admin privileges. This flag allows it to run
92+
# in userspace.
93+
os="${{ matrix.os }}"
94+
if [[ "${os}" == "macos"* ]]; then
95+
# Install Firefox
96+
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
97+
hdiutil attach Firefox-latest.dmg
98+
cp -r /Volumes/Firefox/Firefox.app $PWD
99+
hdiutil detach /Volumes/Firefox
100+
cd ./Firefox.app/Contents/MacOS/
101+
export PATH="$PWD:$PATH"
102+
cd –
103+
104+
# Install Google Chrome
105+
wget https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg
106+
pkgutil --expand-full googlechrome.pkg google-chrome
107+
cd ./google-chrome/GoogleChrome.pkg/Payload/Google\ Chrome.app/Contents/MacOS/
108+
export PATH="$PWD:$PATH"
109+
cd –
110+
111+
# Run tests in browsers
112+
echo "Running test_xeus_cpp in Firefox"
113+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --browser-args="--headless" test_xeus_cpp.html
114+
echo "Running test_xeus_cpp in Google Chrome"
115+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="Google Chrome" --kill_exit --browser-args="--headless" test_xeus_cpp.html
116+
else
117+
# Install Google Chrome
118+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
119+
dpkg-deb -x google-chrome-stable_current_amd64.deb $PWD/chrome
120+
cd ./chrome/opt/google/chrome/
121+
export PATH="$PWD:$PATH"
122+
cd -
123+
124+
# Install Firefox
125+
wget https://ftp.mozilla.org/pub/firefox/releases/138.0.1/linux-x86_64/en-GB/firefox-138.0.1.tar.xz
126+
tar -xJf firefox-138.0.1.tar.xz
127+
cd ./firefox
128+
export PATH="$PWD:$PATH"
129+
cd -
130+
131+
# Run tests in browsers
132+
echo "Running test_xeus_cpp in Firefox"
133+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
134+
echo "Running test_xeus_cpp in Google Chrome"
135+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
136+
fi
137+
node test_xeus_cpp.js
138+
timeout-minutes: 4
139+
67140
- name: Jupyter Lite integration
68141
shell: bash -l {0}
69142
run: |
70-
micromamba create -n xeus-lite-host jupyterlite-core jupyter_server
71143
micromamba activate xeus-lite-host
72-
python -m pip install jupyterlite-xeus
73144
jupyter lite build \
74145
--XeusAddon.prefix=${{ env.PREFIX }} \
146+
--XeusAddon.mounts="${{ env.PREFIX }}/share/xeus-cpp/tagfiles:/share/xeus-cpp/tagfiles" \
147+
--XeusAddon.mounts="${{ env.PREFIX }}/etc/xeus-cpp/tags.d:/etc/xeus-cpp/tags.d" \
75148
--contents README.md \
76149
--contents notebooks/xeus-cpp-lite-demo.ipynb \
150+
--contents notebooks/smallpt.ipynb \
77151
--contents notebooks/images/marie.png \
78152
--contents notebooks/audio/audio.wav \
79153
--output-dir dist

.github/workflows/main.yml

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179
if: ${{ success() && (matrix.coverage == true) }}
180180
uses: codecov/codecov-action@v5
181181
with:
182-
file: ./coverage.info
182+
files: ./coverage.info
183183
fail_ci_if_error: true
184184
verbose: true
185185
token: ${{ secrets.CODECOV_TOKEN }}
@@ -234,6 +234,7 @@ jobs:
234234
pushd build
235235
236236
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
237+
echo "BUILD_PREFIX=$BUILD_PREFIX" >> $GITHUB_ENV
237238
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
238239
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
239240
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
@@ -244,24 +245,86 @@ jobs:
244245
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
245246
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
246247
-DSYSROOT_PATH=$SYSROOT_PATH \
248+
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON \
247249
..
248250
emmake make -j ${{ env.ncpus }} install
249251
250252
- name: Test xeus-cpp C++ Emscripten
251253
shell: bash -l {0}
252254
run: |
255+
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
253256
set -e
254-
micromamba create -n xeus-lite-host jupyterlite-core
257+
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyterlite-xeus
255258
micromamba activate xeus-lite-host
256259
cd build/test
260+
# Fresh install browsers, and run Emscripten tests in them
261+
# This is to match the Emscripten build instructions, where
262+
# we run in a fresh browser, to stop any extra installed
263+
# stuff interferring with the running of the tests
264+
# Explaination of options for emrun
265+
# --browser (name of browser on path)
266+
# --kill_exit makes it so that when emrun finishes,
267+
# that the headless browser we create is killed along with it
268+
# --timeout 60 is such that emrun is killed after 60 seconds if
269+
# still running. emrun should have finished long before then,
270+
# so if it is still running, something went wrong (such as a test
271+
# which crashed the html file). This will cause the ci to fail,
272+
# as a non 0 value of will be returned.
273+
# In the case of Chrome we have the extra --no-sandbox flag, as on
274+
# Ubuntu Chrome will refuse to run otherwise, as it expects to have
275+
# been installed with admin privileges. This flag allows it to run
276+
# in userspace.
277+
os="${{ matrix.os }}"
278+
if [[ "${os}" == "macos"* ]]; then
279+
# Install Firefox
280+
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
281+
hdiutil attach Firefox-latest.dmg
282+
cp -r /Volumes/Firefox/Firefox.app $PWD
283+
hdiutil detach /Volumes/Firefox
284+
cd ./Firefox.app/Contents/MacOS/
285+
export PATH="$PWD:$PATH"
286+
cd -
287+
288+
# Install Google Chrome
289+
wget https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg
290+
pkgutil --expand-full googlechrome.pkg google-chrome
291+
cd ./google-chrome/GoogleChrome.pkg/Payload/Google\ Chrome.app/Contents/MacOS/
292+
export PATH="$PWD:$PATH"
293+
cd -
294+
295+
# Run tests in browsers
296+
echo "Running test_xeus_cpp in Firefox"
297+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
298+
echo "Running test_xeus_cpp in Google Chrome"
299+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
300+
else
301+
# Install Google Chrome
302+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
303+
dpkg-deb -x google-chrome-stable_current_amd64.deb $PWD/chrome
304+
cd ./chrome/opt/google/chrome/
305+
export PATH="$PWD:$PATH"
306+
cd -
307+
308+
# Install Firefox
309+
wget https://ftp.mozilla.org/pub/firefox/releases/138.0.1/linux-x86_64/en-GB/firefox-138.0.1.tar.xz
310+
tar -xJf firefox-138.0.1.tar.xz
311+
cd ./firefox
312+
export PATH="$PWD:$PATH"
313+
cd -
314+
315+
# Run tests in browsers
316+
echo "Running test_xeus_cpp in Firefox"
317+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
318+
echo "Running test_xeus_cpp in Google Chrome"
319+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
320+
fi
257321
node test_xeus_cpp.js
258322
timeout-minutes: 4
259323

260324
- name: Jupyter Lite integration
261325
shell: bash -l {0}
262326
run: |
263327
micromamba activate xeus-lite-host
264-
python -m pip install jupyterlite-xeus
265328
jupyter lite build --XeusAddon.prefix=${{ env.PREFIX }}
266329
267330
- name: Setup tmate session

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ bld
4545
# LLM Implementation
4646
*_api_key.txt
4747
*_chat_history.txt
48+
49+
# MacOS specific files
50+
*.DS_Store

CMakeLists.txt

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ option(XEUS_CPP_BUILD_STATIC "Build xeus-cpp static library" ON)
5454
option(XEUS_CPP_BUILD_SHARED "Split xcpp build into executable and library" ON)
5555
option(XEUS_CPP_BUILD_EXECUTABLE "Build the xcpp executable" ON)
5656

57-
option(XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON)
58-
option(XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON)
57+
option(XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON)
58+
option(XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus-cpp shared library (instead of the static library)" ON)
5959
option(XEUS_CPP_EMSCRIPTEN_WASM_BUILD "Build for wasm with emscripten" OFF)
6060

6161
# Test options
@@ -77,10 +77,9 @@ endif()
7777
if(EMSCRIPTEN)
7878
add_compile_definitions(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
7979
message("Build with emscripten")
80-
set(XEUS_CPP_BUILD_STATIC ON)
80+
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
8181
set(XEUS_CPP_BUILD_SHARED OFF)
8282
set(XEUS_CPP_BUILD_EXECUTABLE OFF)
83-
set(XEUS_CPP_USE_SHARED_XEUS OFF)
8483
set(XEUS_CPP_USE_SHARED_XEUS_CPP OFF)
8584
# ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0)
8685
set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXPORTED_RUNTIME_METHODS=[ENV']\"")
@@ -91,7 +90,8 @@ endif()
9190

9291
set(xeus_REQUIRED_VERSION 5.0.0)
9392
set(xeus_zmq_REQUIRED_VERSION 3.0.0)
94-
set(CppInterOp_REQUIRED_VERSION 1.5.0)
93+
set(CppInterOp_REQUIRED_VERSION 1.7.0)
94+
set(xeus_lite_REQUIRED_VERSION 3.2.1)
9595

9696
if (NOT TARGET xeus AND NOT TARGET xeus-static)
9797
find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED)
@@ -111,14 +111,18 @@ find_package(pugixml REQUIRED)
111111
# Configuration
112112
# =============
113113

114+
if(NOT DEFINED XEUS_CPP_RESOURCE_DIR)
115+
set(XEUS_CPP_RESOURCE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/${CPPINTEROP_LLVM_VERSION_MAJOR}")
116+
message(STATUS "Using clang resource dir headers from ${XEUS_CPP_RESOURCE_DIR}")
117+
endif()
118+
114119
if (NOT DEFINED XEUS_CPP_KERNELSPEC_PATH)
115120
set(XEUS_CPP_KERNELSPEC_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/")
116121
endif ()
117122

118123
function(configure_native_kernel kernel)
119124
set(XEUS_CPP_PATH "$ENV{PATH}")
120125
set(XEUS_CPP_LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}")
121-
set(XEUS_CPP_RESOURCE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/clang/${CPPINTEROP_LLVM_VERSION_MAJOR})
122126
set(XEUS_CPP_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
123127

124128
if (WIN32)
@@ -148,7 +152,6 @@ function(configure_native_kernel kernel)
148152
endfunction()
149153

150154
function(configure_wasm_kernel kernel)
151-
set(XEUS_CPP_RESOURCE_DIR "/lib/clang/${CPPINTEROP_LLVM_VERSION_MAJOR}" PARENT_SCOPE)
152155

153156
configure_file (
154157
"${CMAKE_CURRENT_SOURCE_DIR}${kernel}wasm_kernel.json.in"
@@ -433,22 +436,29 @@ if (XEUS_CPP_BUILD_EXECUTABLE)
433436
endif()
434437

435438
if(EMSCRIPTEN)
439+
# Ensure required SDL2 ports (e.g. SDL2) are built before header preloading
440+
execute_process(
441+
COMMAND embuilder build sdl2
442+
RESULT_VARIABLE SDL2_RESULT
443+
)
444+
if(NOT SDL2_RESULT EQUAL 0)
445+
message(FATAL_ERROR "Failed to run 'embuilder build sdl2'")
446+
endif()
436447
include(WasmBuildOptions)
437-
find_package(xeus-lite REQUIRED)
448+
find_package(xeus-lite ${xeus_lite_REQUIRED_VERSION} REQUIRED)
438449
add_executable(xcpp src/main_emscripten_kernel.cpp )
439450
target_link_libraries(xcpp PRIVATE xeus-lite)
440451
xeus_cpp_set_kernel_options(xcpp)
441452
xeus_wasm_compile_options(xcpp)
442453
xeus_wasm_link_options(xcpp "web,worker")
454+
string(REPLACE "@" "@@" ESCAPED_SYSROOT_PATH "${SYSROOT_PATH}")
455+
string(REPLACE "@" "@@" ESCAPED_XEUS_CPP_RESOURCE_DIR "${XEUS_CPP_RESOURCE_DIR}")
443456
target_link_options(xcpp
444-
PUBLIC "SHELL: --preload-file ${SYSROOT_PATH}/include@/include"
445-
#PUBLIC "SHELL: --preload-file ${CMAKE_INSTALL_PREFIX}${XEUS_CPP_RESOURCE_DIR}@${XEUS_CPP_RESOURCE_DIR}"
446-
PUBLIC "SHELL: --preload-file ${XEUS_CPP_DATA_DIR}@/share/xeus-cpp"
447-
PUBLIC "SHELL: --preload-file ${XEUS_CPP_CONF_DIR}@/etc/xeus-cpp"
457+
PUBLIC "SHELL: -s USE_SDL=2"
458+
PUBLIC "SHELL: --preload-file ${ESCAPED_SYSROOT_PATH}/include@/include"
459+
PUBLIC "SHELL: --preload-file ${ESCAPED_XEUS_CPP_RESOURCE_DIR}@/${CMAKE_INSTALL_LIBDIR}/clang/${CPPINTEROP_LLVM_VERSION_MAJOR}"
448460
PUBLIC "SHELL: --post-js ${CMAKE_CURRENT_SOURCE_DIR}/wasm_patches/post.js"
449461
)
450-
# TODO: Uncomment the above line regarding preloading clang's resource dir
451-
# once has been supported through cppinterop.
452462
endif()
453463
# Tests
454464
# =====

0 commit comments

Comments
 (0)