Skip to content

Commit f9f8931

Browse files
committed
feat: add Emscripten WASM bindings with Embind
Add Embind-based WebAssembly bindings for libOpenDRIVE, enabling browser-side OpenDRIVE processing. Bindings expose: - OpenDriveMap: createFromXml, get_road_network_mesh, get_roads - Road: get_road_signal_mesh, road signals/objects - Lane: get_lane_outline_indices, lane metadata - RoadNetworkMesh: lanes, roadmarks, road objects, road signals - Helper maps: lane types, road mark colors, junction IDs, road/lane metadata, road/lane linkage Includes fix for compile errors in helper function signatures.
1 parent c3a5c8c commit f9f8931

3 files changed

Lines changed: 787 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include(GNUInstallDirs)
77
include(CMakePackageConfigHelpers)
88

99
option(OPENDRIVE_BUILD_TESTS "Build OpenDrive tests" OFF)
10+
option(OPENDRIVE_BUILD_WASM "Build Emscripten WASM bindings" OFF)
1011

1112
find_package(pugixml QUIET CONFIG)
1213
if(NOT TARGET pugixml::pugixml)
@@ -121,3 +122,27 @@ install(FILES
121122
"${CMAKE_CURRENT_BINARY_DIR}/OpenDriveConfigVersion.cmake"
122123
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenDrive
123124
)
125+
126+
# ─── Emscripten WASM bindings ─────────────────────────────────────────────────
127+
if(OPENDRIVE_BUILD_WASM OR EMSCRIPTEN)
128+
add_executable(libOpenDRIVE ${SOURCES} src/Embind.cpp)
129+
set_target_properties(libOpenDRIVE PROPERTIES
130+
CXX_STANDARD 17
131+
CXX_STANDARD_REQUIRED ON
132+
SUFFIX ".js"
133+
)
134+
target_include_directories(libOpenDRIVE PRIVATE
135+
${CMAKE_CURRENT_SOURCE_DIR}/include
136+
)
137+
target_link_libraries(libOpenDRIVE PRIVATE pugixml::pugixml)
138+
target_link_options(libOpenDRIVE PRIVATE
139+
--bind
140+
-sENVIRONMENT=web,worker
141+
-sMODULARIZE=1
142+
-sEXPORT_ES6=1
143+
-sALLOW_MEMORY_GROWTH=1
144+
-sFILESYSTEM=1
145+
-sWASM=1
146+
-O2
147+
)
148+
endif()

0 commit comments

Comments
 (0)