Skip to content
Open
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
23 changes: 22 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,25 @@ jobs:
- name: test
run: ctest --test-dir build --output-on-failure
- name: install
run: cmake --install build --config Release
run: cmake --install build --config Release
build-wasm:
name: emscripten-wasm
runs-on: ubuntu-22.04
defaults:
run:
shell: bash -e -o pipefail {0}
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: setup emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.61
- name: configure
run: emcmake cmake -S . -B build-wasm -DOPENDRIVE_BUILD_WASM=ON -G Ninja
- name: build
run: cmake --build build-wasm
- name: verify artifacts
run: |
test -f build-wasm/libOpenDRIVE.js
test -f build-wasm/libOpenDRIVE.wasm
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

option(OPENDRIVE_BUILD_TESTS "Build OpenDrive tests" OFF)
option(OPENDRIVE_BUILD_WASM "Build Emscripten WASM bindings" OFF)

find_package(pugixml QUIET CONFIG)
if(NOT TARGET pugixml::pugixml)
Expand Down Expand Up @@ -121,3 +122,27 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/OpenDriveConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenDrive
)

# ─── Emscripten WASM bindings ─────────────────────────────────────────────────
if(OPENDRIVE_BUILD_WASM OR EMSCRIPTEN)
add_executable(libOpenDRIVE ${SOURCES} src/Embind.cpp)
set_target_properties(libOpenDRIVE PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
SUFFIX ".js"
)
target_include_directories(libOpenDRIVE PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(libOpenDRIVE PRIVATE pugixml::pugixml)
target_link_options(libOpenDRIVE PRIVATE
--bind
-sENVIRONMENT=web,worker
-sMODULARIZE=1
-sEXPORT_ES6=1
-sALLOW_MEMORY_GROWTH=1
-sFILESYSTEM=1
-sWASM=1
-O2
)
endif()
Loading