From fdf9345d5de1c951603e5da3ee8454e9efe2dc28 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 11 Feb 2026 08:19:05 +0100 Subject: refactor: Modularize CMake build system into 10 specialized modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor monolithic 866-line CMakeLists.txt into 54-line orchestrator + 10 modules: - DemoOptions.cmake - Build option declarations - DemoConfig.cmake - Option implications and platform detection - DemoCommon.cmake - Shared macros (conditional sources, size opts, linking) - DemoDependencies.cmake - External library discovery (WGPU, GLFW) - DemoSourceLists.cmake - Conditional source file lists - DemoLibraries.cmake - Subsystem library targets - DemoTools.cmake - Build tools (asset_packer, compilers) - DemoCodegen.cmake - Code generation (assets, timeline, music) - DemoExecutables.cmake - Main binaries (demo64k, test_demo) - DemoTests.cmake - Test infrastructure (36 tests) - Validation.cmake - Uniform buffer validation Benefits: - 94% reduction in main file size (866 → 54 lines) - Conditional module inclusion (tests only parsed if DEMO_BUILD_TESTS=ON) - Shared macros eliminate 200+ lines of repetition - Clear separation of concerns All 36 tests passing. All build modes verified. Documentation: Created doc/CMAKE_MODULES.md with module architecture. Co-Authored-By: Claude Sonnet 4.5 --- cmake/Validation.cmake | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 cmake/Validation.cmake (limited to 'cmake/Validation.cmake') diff --git a/cmake/Validation.cmake b/cmake/Validation.cmake new file mode 100644 index 0000000..fb5e71d --- /dev/null +++ b/cmake/Validation.cmake @@ -0,0 +1,40 @@ +# Uniform Buffer Validation +# Extracted from main CMakeLists.txt + +# Sub-task 7: Integrate validation tool into CI/build system + +# Ensure the Python validation script is available +add_custom_target(validate_uniforms_script ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/validate_uniforms.py) + +# Find all WGSL files recursively in src/gpu +file(GLOB WGSL_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/*.wgsl ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/**/*.wgsl) + +# List of C++ files containing uniform struct definitions and shader code +# Add more C++ files here if new effects with structs are added. +set(VALIDATION_CPP_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/heptagon_effect.cc + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/post_process_helper.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/fade_effect.cc + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/theme_modulation_effect.cc + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/chroma_aberration_effect.cc + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/vignette_effect.cc + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/gaussian_blur_effect.cc + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/distort_effect.cc + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/demo_effects.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/gpu/effects/circle_mask_effect.h +) + +# Add custom command to run the validator +# It depends on the script itself, WGSL files, and the C++ files being validated. +# Outputting a flag file to signal completion. +set(VALIDATION_FLAG ${CMAKE_CURRENT_BINARY_DIR}/uniform_validation_complete.flag) +add_custom_command( + OUTPUT ${VALIDATION_FLAG} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/tools/validate_uniforms.py ${VALIDATION_FLAG} + COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/tools/validate_uniforms.py ${CMAKE_CURRENT_SOURCE_DIR}/assets/final/shaders ${VALIDATION_CPP_FILES} + DEPENDS validate_uniforms_script ${WGSL_FILES} ${VALIDATION_CPP_FILES} + COMMENT "Validating uniform buffer sizes and alignments..." +) + +# Add custom target that depends on the validation output flag +add_custom_target(validate_uniforms ALL DEPENDS ${VALIDATION_FLAG}) -- cgit v1.2.3