Skip to content

Fix standalone esminiJS WASM build: generate CommonMini/version.cpp#825

Open
jdsika wants to merge 1 commit into
esmini:masterfrom
jdsika:fix/esminijs-standalone-version
Open

Fix standalone esminiJS WASM build: generate CommonMini/version.cpp#825
jdsika wants to merge 1 commit into
esmini:masterfrom
jdsika:fix/esminijs-standalone-version

Conversation

@jdsika

@jdsika jdsika commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Problem

Building the standalone esminiJS Emscripten/WASM target
(EnvironmentSimulator/Libraries/esminiJS, per its build.sh / CMakeLists.txt)
compiles all objects but then fails to link:

undefined symbol: ESMINI_GIT_REV
undefined symbol: ESMINI_GIT_TAG
undefined symbol: ESMINI_GIT_BRANCH
undefined symbol: ESMINI_BUILD_VERSION

Those symbols are referenced by CommonMini.cpp and defined in a generated
version.cpp (produced from version.cpp.in by CommonMini/version.cmake). The
full esmini build generates it via CommonMini/CMakeLists.txt, but the standalone
esminiJS target never triggers that generation, so version.cpp is missing from
the link.

Fix

Invoke version.cmake from the esminiJS CMakeLists.txt exactly the way
CommonMini/CMakeLists.txt already does
(cmake -DESMINI_BUILD_VERSION=... -P version.cmake). The existing
COMMONMINI_SOURCES glob then picks up the generated CommonMini/version.cpp, so
no source-list change is needed. 20 lines, one file.

Under a shallow checkout git describe yields nothing and the values resolve to
"N/A", which is harmless.

Verification

With this change the esminiJS target builds and links standalone via
emcmake cmake -G Ninja -DCMAKE_BUILD_TYPE=Release + SINGLE_FILE=1, producing a
working esmini.js. I ran it in headless Chromium: get_road_geometry() returns
lane surfaces / lane centers and step_frame() advances entities, with reset()
restarting the run (endless-loop playback).

Refs #357.

Note

Happy to follow up on distribution (an npm package / a prebuilt WASM release asset)
if that's useful — there is currently no published artifact, which is the main thing
keeping downstream projects from consuming esminiJS directly.

The esminiJS Emscripten/WASM target links CommonMini, whose CommonMini.cpp
references ESMINI_GIT_REV, ESMINI_GIT_TAG, ESMINI_GIT_BRANCH and
ESMINI_BUILD_VERSION. Those symbols are *defined* in a generated version.cpp
(produced from version.cpp.in by CommonMini/version.cmake). The full esmini build
generates it via CommonMini/CMakeLists.txt, but the standalone esminiJS build
never did, so linking failed with "undefined symbol: ESMINI_GIT_REV" (and the
other three) after all objects compiled.

Invoke version.cmake from the esminiJS CMakeLists the same way CommonMini does
(cmake -DESMINI_BUILD_VERSION=... -P version.cmake). The existing
COMMONMINI_SOURCES glob then picks up the generated version.cpp, so no source list
change is needed. Under a shallow checkout git describe yields nothing and the
values resolve to "N/A", which is harmless.

This makes the esminiJS WASM target build+link standalone (emcmake + Ninja).

Refs: esmini#357
Signed-off-by: Carlo van Driesten <carlo.van-driesten@bmw.de>
@jdsika
jdsika force-pushed the fix/esminijs-standalone-version branch from f174540 to c30b626 Compare July 24, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant