From 63e966c36bc57a7544717dbceec932192f005a36 Mon Sep 17 00:00:00 2001 From: Carlo van Driesten Date: Sun, 26 Jul 2026 16:58:59 +0000 Subject: [PATCH] fix(build): support Emscripten as a target platform Emscripten defines __unix__ but not __linux__, and is matched by none of the existing platform branches. All three files below therefore fall through to their #error fallback, so the library cannot be compiled to WebAssembly at all: - cpp/openScenarioLib/src/common/ExportDefinitions.h - cpp/expressionsLib/inc/OscExprExportDefs.h - cpp/openScenarioLib/src/loader/FileResourceLocator.cpp Add an __EMSCRIPTEN__ branch to the two symbol-visibility chains (no visibility attribute is needed, as for __APPLE__), and accept __EMSCRIPTEN__ in the POSIX branch of FileResourceLocator, which already handles Linux and macOS identically and needs no change beyond the guard. Verified that the preprocessor chains resolve under -D__EMSCRIPTEN__ and that the existing Windows, Linux and macOS branches are reached exactly as before. Signed-off-by: Carlo van Driesten --- cpp/expressionsLib/inc/OscExprExportDefs.h | 2 ++ cpp/openScenarioLib/src/common/ExportDefinitions.h | 2 ++ cpp/openScenarioLib/src/loader/FileResourceLocator.cpp | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cpp/expressionsLib/inc/OscExprExportDefs.h b/cpp/expressionsLib/inc/OscExprExportDefs.h index 1f24fbc3..4b34379e 100644 --- a/cpp/expressionsLib/inc/OscExprExportDefs.h +++ b/cpp/expressionsLib/inc/OscExprExportDefs.h @@ -35,6 +35,8 @@ # endif #elif defined(__APPLE__) # define OSC_EXPR_EXP +#elif defined(__EMSCRIPTEN__) +# define OSC_EXPR_EXP #else # error "OPENSCENARIOLIB: Operating system not supported." #endif // _WIN32 diff --git a/cpp/openScenarioLib/src/common/ExportDefinitions.h b/cpp/openScenarioLib/src/common/ExportDefinitions.h index 2b0dfb2d..0e46f766 100644 --- a/cpp/openScenarioLib/src/common/ExportDefinitions.h +++ b/cpp/openScenarioLib/src/common/ExportDefinitions.h @@ -19,6 +19,8 @@ # endif #elif defined(__APPLE__) # define OPENSCENARIOLIB_EXP +#elif defined(__EMSCRIPTEN__) +# define OPENSCENARIOLIB_EXP #else # error "OPENSCENARIOLIB: Operating system not supported." #endif // _WIN32 diff --git a/cpp/openScenarioLib/src/loader/FileResourceLocator.cpp b/cpp/openScenarioLib/src/loader/FileResourceLocator.cpp index 7a9e7600..b8d7d6ad 100644 --- a/cpp/openScenarioLib/src/loader/FileResourceLocator.cpp +++ b/cpp/openScenarioLib/src/loader/FileResourceLocator.cpp @@ -41,7 +41,7 @@ namespace NET_ASAM_OPENSCENARIO } auto infile = std::make_shared(result.c_str(), std::ios::binary); -#elif defined (__linux__) || defined (__APPLE__) +#elif defined (__linux__) || defined (__APPLE__) || defined (__EMSCRIPTEN__) auto infile = std::make_shared(symbolicFilename, std::ios::binary); #else # error "Operating system not supported."