diff --git a/Makefile b/Makefile index 1103b8e..c5179d4 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,13 @@ CC = clang TARGET = clayterm.wasm SRC = src/module.c +CLAY_PATCH = patches/clay-disable-debug-tools.patch CFLAGS = --target=wasm32 -nostdlib -O2 \ -ffunction-sections -fdata-sections \ -mbulk-memory \ -DCLAY_IMPLEMENTATION -DCLAY_WASM \ + -DCLAY_DISABLE_DEBUG_TOOLS \ -Isrc -I. EXPORTS = \ @@ -46,7 +48,13 @@ all: $(TARGET) wasm.ts DEPS = $(wildcard src/*.c src/*.h) -$(TARGET): $(DEPS) +# Gate out Clay's unused debug-tools UI (upstream-compatible #ifndef guards), +# opted in via -DCLAY_DISABLE_DEBUG_TOOLS. Idempotent (skips if the guard is +# already present) and verified (fails the build if it didn't apply). +# Drop once Clay ships the flag upstream. +$(TARGET): $(DEPS) $(CLAY_PATCH) + @grep -q CLAY_DISABLE_DEBUG_TOOLS clay/clay.h || git -C clay apply ../$(CLAY_PATCH) + @grep -q CLAY_DISABLE_DEBUG_TOOLS clay/clay.h || { echo "ERROR: failed to apply $(CLAY_PATCH) to clay/clay.h" >&2; exit 1; } $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC) wasm.ts: $(TARGET) @@ -54,5 +62,6 @@ wasm.ts: $(TARGET) clean: rm -f $(TARGET) wasm.ts + -git -C clay checkout -- clay.h .PHONY: all clean diff --git a/patches/clay-disable-debug-tools.patch b/patches/clay-disable-debug-tools.patch new file mode 100644 index 0000000..0d341fc --- /dev/null +++ b/patches/clay-disable-debug-tools.patch @@ -0,0 +1,34 @@ +diff --git a/clay.h b/clay.h +index 80d8393..8bf723b 100644 +--- a/clay.h ++++ b/clay.h +@@ -3145,6 +3145,7 @@ CLAY_DLL_EXPORT Clay_ElementIdArray Clay_GetPointerOverIds(void) { + return Clay_GetCurrentContext()->pointerOverIds; + } + ++#ifndef CLAY_DISABLE_DEBUG_TOOLS + #pragma region DebugTools + Clay_Color CLAY__DEBUGVIEW_COLOR_1 = {58, 56, 52, 255}; + Clay_Color CLAY__DEBUGVIEW_COLOR_2 = {62, 60, 58, 255}; +@@ -3842,6 +3843,7 @@ void Clay__RenderDebugView(void) { + } + } + #pragma endregion ++#endif // CLAY_DISABLE_DEBUG_TOOLS + + uint32_t Clay__debugViewWidth = 400; + Clay_Color Clay__debugViewHighlightColor = { 168, 66, 28, 100 }; +@@ -4237,11 +4239,13 @@ Clay_RenderCommandArray Clay_EndLayout(void) { + Clay_Context* context = Clay_GetCurrentContext(); + Clay__CloseElement(); + bool elementsExceededBeforeDebugView = context->booleanWarnings.maxElementsExceeded; ++#ifndef CLAY_DISABLE_DEBUG_TOOLS + if (context->debugModeEnabled && !elementsExceededBeforeDebugView) { + context->warningsEnabled = false; + Clay__RenderDebugView(); + context->warningsEnabled = true; + } ++#endif // CLAY_DISABLE_DEBUG_TOOLS + if (context->booleanWarnings.maxElementsExceeded) { + Clay_String message; + if (!elementsExceededBeforeDebugView) {