diff options
| author | skal <pascal.massimino@gmail.com> | 2026-03-07 21:23:10 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-03-07 21:23:10 +0100 |
| commit | fa0beb7cc3e4ab9edfd123933fd205053dc3ac31 (patch) | |
| tree | 67f4966abf1c78a5b0fd006c5338795d8fe27bcd /cmake/DemoCodegen.cmake | |
| parent | 72ed90b4da8658260b527fbd41d23bcb55cdd6f5 (diff) | |
fix(cmake): avoid spurious recompiles when only shader assets change
asset_packer always rewrote assets.h, bumping its mtime even when the
AssetId enum was unchanged, causing audio/3d TUs to recompile on every
.wgsl edit. Write to assets.h.new first and use copy_if_different so
assets.h mtime only advances when enum content actually changes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'cmake/DemoCodegen.cmake')
| -rw-r--r-- | cmake/DemoCodegen.cmake | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cmake/DemoCodegen.cmake b/cmake/DemoCodegen.cmake index 2d21b14..32cb06c 100644 --- a/cmake/DemoCodegen.cmake +++ b/cmake/DemoCodegen.cmake @@ -236,10 +236,16 @@ add_custom_command( add_custom_target(generate_demo_data DEPENDS ${GEN_DEMO_H}.data_stamp) # Unified asset generation (triggered when any category changes) +# assets.h is written via copy_if_different so its mtime only changes when the +# enum content changes (e.g. new asset added). This prevents unrelated +# translation units (audio, 3d, …) from recompiling on every shader edit. +set(GEN_DEMO_H_STAMP ${GEN_DEMO_H}.gen_stamp) add_custom_command( - OUTPUT ${GEN_DEMO_H} ${GEN_DEMO_CC} + OUTPUT ${GEN_DEMO_H_STAMP} ${GEN_DEMO_CC} COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_SOURCE_DIR}/src/generated - COMMAND ${ASSET_PACKER_CMD} ${WORKSPACE_ASSETS} ${GEN_DEMO_H} ${GEN_DEMO_CC} + COMMAND ${ASSET_PACKER_CMD} ${WORKSPACE_ASSETS} ${GEN_DEMO_H}.new ${GEN_DEMO_CC} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GEN_DEMO_H}.new ${GEN_DEMO_H} + COMMAND ${CMAKE_COMMAND} -E touch ${GEN_DEMO_H_STAMP} DEPENDS ${ASSET_PACKER_DEPENDS} ${WORKSPACE_ASSETS} ${GEN_DEMO_H}.shaders_stamp ${GEN_DEMO_H}.audio_stamp @@ -249,7 +255,7 @@ add_custom_command( ) # Combined target for compatibility -add_custom_target(generate_demo_assets DEPENDS ${GEN_DEMO_H} ${GEN_DEMO_CC}) +add_custom_target(generate_demo_assets DEPENDS ${GEN_DEMO_H_STAMP} ${GEN_DEMO_CC}) # Test assets (unchanged) pack_test_assets(test_assets ${CMAKE_CURRENT_SOURCE_DIR}/workspaces/test/assets.txt GEN_TEST_H GEN_TEST_CC generate_test_assets) |
