Skip to content

Commit 0b722b4

Browse files
committed
cmake: kconfig: skip the Kconfig checksum recalculation when it is unused
The loop that recalculates the checksum after kconfig.py runs is only consumed inside if(CREATE_NEW_DOTCONFIG). On any configure that does not regenerate .config its result is discarded, so hashing all 5001 parsed Kconfig sources is pure waste, measured in isolation at 168 ms. Move the loop into the block that consumes it. The file(STRINGS) read above stays where it is, as it also feeds the CMAKE_CONFIGURE_DEPENDS registration, which must keep running unconditionally. Assisted-by: Claude Code:claude-opus-5 Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent 7ddf02c commit 0b722b4

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

cmake/modules/kconfig.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,6 @@ endif()
435435
# Read out the list of 'Kconfig' sources that were used by the engine.
436436
file(STRINGS ${PARSED_KCONFIG_SOURCES_TXT} parsed_kconfig_sources_list ENCODING UTF-8)
437437

438-
# Recalculate the Kconfig files' checksum, since the list of files may have
439-
# changed.
440-
set(merge_kconfig_checksum "")
441-
foreach(f ${parsed_kconfig_sources_list})
442-
file(MD5 ${f} checksum)
443-
string(APPEND merge_kconfig_checksum "${checksum}")
444-
endforeach()
445-
446438
# Force CMAKE configure when the Kconfig sources or configuration files changes.
447439
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
448440
${merge_config_files}
@@ -451,6 +443,14 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
451443
)
452444

453445
if(CREATE_NEW_DOTCONFIG)
446+
# Recalculate the Kconfig files' checksum, since the list of files may have
447+
# changed.
448+
set(merge_kconfig_checksum "")
449+
foreach(f ${parsed_kconfig_sources_list})
450+
file(MD5 ${f} checksum)
451+
string(APPEND merge_kconfig_checksum "${checksum}")
452+
endforeach()
453+
454454
# Write the new configuration fragment checksum. Only do this if kconfig.py
455455
# succeeds, to avoid marking zephyr/.config as up-to-date when it hasn't been
456456
# regenerated.

0 commit comments

Comments
 (0)