diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-11 08:19:05 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-11 08:19:05 +0100 |
| commit | fdf9345d5de1c951603e5da3ee8454e9efe2dc28 (patch) | |
| tree | ee0dcf35de7d2800b20faf861cd70cb168d773f8 /cmake/Validation.cmake | |
| parent | 6d64674f7e3d00a9d18ec61eaf968ed37c8e849b (diff) | |
refactor: Modularize CMake build system into 10 specialized modules
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 <noreply@anthropic.com>
Diffstat (limited to 'cmake/Validation.cmake')
| -rw-r--r-- | cmake/Validation.cmake | 40 |
1 files changed, 40 insertions, 0 deletions
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}) |
