Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(engine): two of the four subsystem switches did not build with them off

esengine590cf6815330
diff --git a/build-tools/tasks/wasm.js b/build-tools/tasks/wasm.js
index e0fa47c4d..c84600045 100644
--- a/build-tools/tasks/wasm.js
+++ b/build-tools/tasks/wasm.js
@@ -23,6 +23,17 @@ function testProbeFlags() {
return [`-DES_ENABLE_TEST_PROBES=${process.env.ESTELLA_TEST_PROBES === '1' ? 'ON' : 'OFF'}`];
}
+/**
+ * Extra `-D` flags for one build, from `ESTELLA_CMAKE_FLAGS`.
+ *
+ * Measuring what a subsystem costs in the core means building without it, and
+ * every switch for that is already a CMake option — what was missing was a way
+ * to reach one. Space-separated, as on a cmake line.
+ */
+function extraCmakeFlags() {
+ return (process.env.ESTELLA_CMAKE_FLAGS ?? '').split(/\s+/).filter(Boolean);
+}
+
async function computeWasmHash(target, targetConfig, debug) {
const rootDir = config.paths.root;
const srcDir = path.join(rootDir, 'src/esengine');
@@ -149,6 +160,7 @@ async function executeWasmBuild(target, targetConfig, { debug, clean, buildDir,
'cmake',
...targetConfig.cmakeFlags,
...testProbeFlags(),
+ ...extraCmakeFlags(),
`-DCMAKE_BUILD_TYPE=${buildType}`,
];
diff --git a/src/esengine/bindings/RendererBindings.cpp b/src/esengine/bindings/RendererBindings.cpp
index f01100ccf..cede49d07 100644
--- a/src/esengine/bindings/RendererBindings.cpp
+++ b/src/esengine/bindings/RendererBindings.cpp
@@ -30,9 +30,10 @@
#include "../ecs/components/Light.hpp"
#include "../ecs/components/Hierarchy.hpp"
#include "../core/Log.hpp"
+// Core, not particles: the seed binding below is unconditional.
+#include "../core/RandomSource.hpp"
#ifdef ES_ENABLE_PARTICLES
#include "../particle/ParticleSystem.hpp"
-#include "../core/RandomSource.hpp"
#endif
#include "../trail/TrailSystem.hpp"
#include "../ui/UISystem.hpp"
diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cpp
index 9268777d0..fd71d2eda 100644
--- a/src/esengine/bindings/WebSDKEntry.cpp
+++ b/src/esengine/bindings/WebSDKEntry.cpp
@@ -50,7 +50,9 @@
#include "../renderer/draw/CustomGeometry.hpp"
#include "../resource/ResourceManager.hpp"
#include "../resource/ShaderParser.hpp"
+#ifdef ES_ENABLE_BITMAP_TEXT
#include "../text/SdfGenerator.hpp"
+#endif
#include "../ecs/TransformSystem.hpp"
#include "../core/World.hpp"
#include "../ecs/components/Velocity.hpp"
@@ -349,9 +351,10 @@ void notifyDeviceLost(u32 reason, const std::string& message) {
}
}
-// Runtime glyph atlas: convert a Canvas2D-rasterized alpha
-// bitmap to a signed distance field. Both buffers are caller-allocated in WASM
-// linear memory (TS passes HEAPU8 pointers); `alpha` and `out` are width*height.
+// Runtime glyph atlas: a Canvas2D-rasterized alpha bitmap to a signed distance
+// field. Both buffers are caller-allocated in WASM linear memory and are
+// width*height. Under the text flag, because the generator it calls is.
+#ifdef ES_ENABLE_BITMAP_TEXT
void web_sdfFromAlpha(uintptr_t alphaPtr, uintptr_t outPtr, u32 width, u32 height, f32 spread) {
const u64 pixels = static_cast<u64>(width) * height;
const u8* alpha = boundarySpan<u8>(alphaPtr, pixels, "sdfFromAlpha.alpha");
@@ -359,6 +362,7 @@ void web_sdfFromAlpha(uintptr_t alphaPtr, uintptr_t outPtr, u32 width, u32 heigh
if (!alpha || !out) return;
text::sdfFromAlpha(alpha, out, width, height, spread);
}
+#endif
// =============================================================================
// Pointer-based Component Access
@@ -462,7 +466,9 @@ EMSCRIPTEN_BINDINGS(esengine_renderer) {
emscripten::function("initRendererWebGPU", &esengine::initRendererWebGPU);
emscripten::function("shutdownRenderer", &esengine::shutdownRenderer);
emscripten::function("getResourceManager", &esengine::getResourceManager, emscripten::allow_raw_pointers());
+#ifdef ES_ENABLE_BITMAP_TEXT
emscripten::function("sdfFromAlpha", &esengine::web_sdfFromAlpha);
+#endif
emscripten::function("deviceStatus", &esengine::deviceStatus);
emscripten::function("deviceLostReport", &esengine::deviceLostReport);
emscripten::function("deviceIdentity", &esengine::deviceIdentity);
diff --git a/src/esengine/core/EstellaContext.cpp b/src/esengine/core/EstellaContext.cpp
index 11680fcf7..8d0f1a978 100644
--- a/src/esengine/core/EstellaContext.cpp
+++ b/src/esengine/core/EstellaContext.cpp
@@ -25,10 +25,13 @@
#endif
#include "../renderer/plugins/ShapePlugin.hpp"
#include "../renderer/plugins/MeshPlugin.hpp"
+// The engine's one random stream, registered unconditionally below: a core type
+// that reached this file only through a particle header, so turning particles
+// off stopped the CORE from compiling.
+#include "RandomSource.hpp"
#ifdef ES_ENABLE_PARTICLES
#include "../renderer/plugins/ParticlePlugin.hpp"
#include "../particle/ParticleSystem.hpp"
-#include "RandomSource.hpp"
#endif
#include "../renderer/plugins/TrailPlugin.hpp"
#include "../trail/TrailSystem.hpp"