Skip to content

Commit a5775cf

Browse files
authored
compile as main module (#41)
* main module * ci * ci * ci * ci * cmake min ver * cmake min ver * cmake min ver * yes * yes * yes * yes * yes * yes * shared as fuck
1 parent 2c75fe6 commit a5775cf

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
name: CI
22
on:
3-
43
workflow_dispatch:
54
pull_request:
65
push:
76
branches:
8-
- main
7+
- main
98

109
schedule:
1110
- cron: '0 2 * * *' # run at 2 AM UTC
@@ -17,8 +16,7 @@ jobs:
1716

1817
strategy:
1918
fail-fast: false
20-
matrix:
21-
emsdk_ver: ["3.1.45"]
19+
2220

2321
steps:
2422
- uses: actions/checkout@v4
@@ -32,31 +30,20 @@ jobs:
3230
environment-file: environment-wasm-build.yml
3331
environment-name: xeus-javascript-wasm-build
3432

35-
################################################################
36-
# emsdk itself
37-
################################################################
38-
- name: Setup emsdk
39-
shell: bash -l {0}
40-
run: |
41-
42-
emsdk install ${{ matrix.emsdk_ver }}
43-
4433
################################################################
4534
# C++ build
4635
################################################################
4736
- name: Build
4837
shell: bash -l {0}
4938
run: |
5039
51-
emsdk activate ${{ matrix.emsdk_ver }}
5240
53-
source $CONDA_EMSDK_DIR/emsdk_env.sh
54-
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
41+
42+
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32 --yes
5543
5644
mkdir build
5745
pushd build
5846
59-
export EMPACK_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-javascript-wasm-build
6047
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-javascript-wasm-host
6148
export CMAKE_PREFIX_PATH=$PREFIX
6249
export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
@@ -97,7 +84,7 @@ jobs:
9784
# upload to github pages
9885
################################################################
9986
- name: Upload Pages artifact
100-
uses: actions/upload-pages-artifact@v2
87+
uses: actions/upload-pages-artifact@v3
10188
with:
10289
path: _output
10390

@@ -126,4 +113,4 @@ jobs:
126113
steps:
127114
- name: Deploy to GitHub Pages
128115
id: deployment
129-
uses: actions/deploy-pages@v3 # or specific "vX.X.X" version tag for this action
116+
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action

CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#The full license is in the file LICENSE, distributed with this software.
77
#############################################################################
88

9-
cmake_minimum_required(VERSION 3.4.3)
9+
cmake_minimum_required(VERSION 4.0.0)
1010
project(xeus-javascript)
1111
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
1212

@@ -57,7 +57,7 @@ if(EMSCRIPTEN)
5757
SET(XEUS_JAVASCRIPT_BUILD_STATIC ON)
5858
SET(XEUS_JAVASCRIPT_BUILD_SHARED OFF)
5959
SET(XEUS_JAVASCRIPT_BUILD_EXECUTABLE OFF)
60-
SET(XEUS_JAVASCRIPT_USE_SHARED_XEUS OFF)
60+
SET(XEUS_JAVASCRIPT_USE_SHARED_XEUS ON)
6161
SET(XEUS_JAVASCRIPT_USE_SHARED_XEUS_JAVASCRIPT OFF)
6262
SET(XEUS_JAVASCRIPT_BUILD_TESTS OFF)
6363
endif()
@@ -261,17 +261,28 @@ if (XEUS_JAVASCRIPT_BUILD_STATIC)
261261
list(APPEND XEUS_JAVASCRIPT_TARGETS xeus-javascript-static)
262262
endif ()
263263

264+
target_link_options(xeus-javascript-static
265+
PUBLIC "SHELL: -s WASM_BIGINT=1"
266+
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
267+
)
264268

265269
include(WasmBuildOptions)
266270

267271
add_executable(xjavascript src/main_emscripten_kernel.cpp )
268-
target_compile_options(xjavascript PRIVATE -fPIC)
272+
target_compile_options(xjavascript
273+
PRIVATE "-fPIC"
274+
PUBLIC "SHELL: -s WASM_BIGINT=1"
275+
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
276+
)
269277
XEUS_JAVASCRIPT_set_kernel_options(xjavascript)
270278
xeus_wasm_compile_options(xjavascript)
271279
xeus_wasm_link_options(xjavascript "web,worker")
272280

273281
#
274282
target_link_options(xjavascript
283+
PUBLIC "SHELL: -s WASM_BIGINT=1"
284+
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
285+
PUBLIC "SHELL: -s MAIN_MODULE=1"
275286
PUBLIC "SHELL: -s NO_EXIT_RUNTIME=1"
276287
PUBLIC "SHELL: -s FORCE_FILESYSTEM=1"
277288
PUBLIC "SHELL: --pre-js ${CMAKE_CURRENT_SOURCE_DIR}/src/pre.js"

environment-wasm-build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
name: xeus-javascript-wasm-build
22
channels:
3+
- https://repo.prefix.dev/emscripten-forge-dev
34
- conda-forge
45
dependencies:
6+
- cmake
7+
- pkg-config
8+
- emscripten_emscripten-wasm32==3.1.73
59
- anywidget
610
- cmake
7-
- emsdk >=3.1.46
8-
- empack >=3.2.0
911
- jupyter_server # to enable contents
1012
- jupyterlite-core
1113
- jupyterlite-xeus

environment-wasm-host.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: xeus-javascript-wasm-host
22
channels:
3-
- https://repo.mamba.pm/emscripten-forge
3+
- https://repo.prefix.dev/emscripten-forge-dev
44
- https://repo.mamba.pm/conda-forge
55
dependencies:
66
- nlohmann_json
7-
- xeus-lite >=3.0.0,<4.0
8-
- xeus >=5.0.0,<6.0
7+
- xeus-lite >= 4.0.0
8+
- xeus >= 2.4.0

src/post.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,12 @@ Module._complete_request = _complete_request;
685685
Module.FS = FS;
686686
Module.ijs = ijs;
687687

688+
if (!('wasmTable' in Module)) {
689+
Module['wasmTable'] = wasmTable
690+
}
688691

689-
// function get_comm_manager(){
690-
// return Module._com_manager;
691-
// }
692-
// Module.get_comm_manager = get_comm_manager;
692+
Module['FS'] = FS
693+
Module['PATH'] = PATH
694+
Module['LDSO'] = LDSO
695+
Module['getDylinkMetadata'] = getDylinkMetadata
696+
Module['loadDynamicLibrary'] = loadDynamicLibrary

0 commit comments

Comments
 (0)