Skip to content

Commit

Permalink
fix: Build the emscripten bindings with EXPORT_ES6=1 (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoraggi authored Jul 4, 2023
1 parent 7792714 commit 91926d7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions .devcontainer/emscripten_dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM emscripten/emsdk:3.1.42

RUN apt-get update && apt-get install -y \
bash-completion \
ninja-build \
wget \
unzip
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/emscripten_dev/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"cmake.configureArgs": [
"-DCMAKE_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"-DFLATBUFFERS_FLATC_EXECUTABLE=/usr/bin/flatc",
"-DCMAKE_BUILD_TYPE=MinSizeRel",
"-DKWGEN_EXECUTABLE=/usr/bin/kwgen"
],
"cmake.buildDirectory": "${workspaceFolder}/build.em",
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ jobs:
- name: Test
working-directory: packages/cxx-frontend/examples
run: |
node dump.mjs
for i in *.mjs; do
node dump.mjs
done
- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
2 changes: 2 additions & 0 deletions packages/cxx-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"keywords": [
"c++",
"compiler",
"lexer",
"parser",
"preprocessor",
"syntax"
],
"author": {
Expand Down
12 changes: 7 additions & 5 deletions scripts/build-emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ project_root=$(cd "$me/.." && pwd)

CMAKE_CONFIGURE_OPTIONS="
-DCMAKE_INSTALL_PREFIX=build.em/install/usr \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=1 \
-DKWGEN_EXECUTABLE=/usr/bin/kwgen \
-DFLATBUFFERS_FLATC_EXECUTABLE=/usr/bin/flatc"
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-MinSizeRel} \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=${CMAKE_INTERPROCEDURAL_OPTIMIZATION:-1} \
-DKWGEN_EXECUTABLE=${KWGEN_EXECUTABLE:-/usr/bin/kwgen} \
-DFLATBUFFERS_FLATC_EXECUTABLE=${FLATBUFFERS_FLATC_EXECUTABLE:-/usr/bin/flatc}"

if [ ! -z "${CODESPACES}" ] && [ ! -z "${EMSDK}" ]; then
cmake -G Ninja ${CMAKE_CONFIGURE_OPTIONS} -S ${project_root} -B ${project_root}/build.em
if [ ! -d "${project_root}/build.em" ]; then
cmake -G Ninja ${CMAKE_CONFIGURE_OPTIONS} -S ${project_root} -B ${project_root}/build.em
fi
cmake --build $project_root/build.em
exit 0
fi
Expand Down
2 changes: 1 addition & 1 deletion src/js/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ target_link_libraries(cxx-js cxx-parser)
target_link_options(cxx-js PUBLIC
"SHELL:--bind"
"SHELL:-s ENVIRONMENT=web"
"SHELL:-s EXPORT_ES6=1"
"SHELL:-s WASM_ASYNC_COMPILATION=1"
"SHELL:-s MODULARIZE=1"
"SHELL:-s MALLOC=emmalloc"
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
"SHELL:-s FILESYSTEM=0"
"SHELL:-s NO_DYNAMIC_EXECUTION=1"
"SHELL:-s WASM_BIGINT=1"
"SHELL:--extern-post-js ${CMAKE_CURRENT_SOURCE_DIR}/cxx/suffix.js"
)

2 changes: 0 additions & 2 deletions src/js/cxx/suffix.js

This file was deleted.

0 comments on commit 91926d7

Please sign in to comment.