Skip to content

Commit 9b0d46c

Browse files
raiden00plxiaoxiang781216
authored andcommitted
cmake: normalize .config on reconfigure
olddefconfig only ran when .config was generated from the defconfig, so changes applied to an existing .config (e.g. with kconfig-tweak) never got their dependent defaults. Run olddefconfig on reconfigure as well, as the Make flow does on every build. Signed-off-by: raiden00pl <raiden00@railab.me> Assisted-by: Claude Code
1 parent 30cbb23 commit 9b0d46c

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,9 @@ if(NOT EXISTS ${NUTTX_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
368368
# Do olddefconfig step to expand the abbreviated defconfig into normal config
369369
nuttx_olddefconfig()
370370

371+
# save the orig compressed formatted defconfig at the very beginning
372+
nuttx_save_defconfig_orig()
373+
371374
file(RENAME ${NUTTX_BINARY_DIR}/.config.compressed
372375
${NUTTX_BINARY_DIR}/.config)
373376
set(ENV{KCONFIG_CONFIG} ${NUTTX_BINARY_DIR}/.config)
@@ -385,9 +388,11 @@ if(NOT EXISTS ${NUTTX_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
385388
endif()
386389
file(WRITE ${NUTTX_BINARY_DIR}/.config "${_config_init_content}")
387390

388-
# store original expanded .config
389-
configure_file(${NUTTX_BINARY_DIR}/.config ${NUTTX_BINARY_DIR}/.config.orig
390-
COPYONLY)
391+
# store original expanded .config; plain copy so .config does not become a
392+
# configure dependency: the compiler cannot change after the first configure,
393+
# so a modified .config must not reconfigure mid-build
394+
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_BINARY_DIR}/.config
395+
${NUTTX_BINARY_DIR}/.config.orig)
391396

392397
set(NUTTX_DEFCONFIG_SAVED
393398
${NUTTX_DEFCONFIG}
@@ -411,6 +416,11 @@ if(NOT EXISTS ${NUTTX_BINARY_DIR}/.config OR NOT "${NUTTX_DEFCONFIG}" STREQUAL
411416
message(STATUS " Board: ${NUTTX_BOARD}")
412417
message(STATUS " Config: ${NUTTX_CONFIG}")
413418
message(STATUS " Appdir: ${NUTTX_APPS_DIR}")
419+
else()
420+
# Normalize user modifications to .config (e.g. kconfig-tweak) so dependent
421+
# defaults materialize, as the Make flow does on each build
422+
set(ENV{KCONFIG_CONFIG} ${NUTTX_BINARY_DIR}/.config)
423+
nuttx_olddefconfig()
414424
endif()
415425

416426
# declare global custom targets at very beginning `nuttx_global` is used to hold

cmake/nuttx_kconfig.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,12 @@ function(nuttx_olddefconfig)
216216
"nuttx_olddefconfig: Failed to initialize Kconfig configuration: ${KCONFIG_OUTPUT}"
217217
)
218218
endif()
219+
endfunction()
220+
221+
# save the orig compressed formatted defconfig at the very beginning; only valid
222+
# during the initial configure while .config.compressed exists
219223

220-
# save the orig compressed formatted defconfig at the very beginning
224+
function(nuttx_save_defconfig_orig)
221225
execute_process(COMMAND savedefconfig --out ${NUTTX_BINARY_DIR}/defconfig.tmp
222226
WORKING_DIRECTORY ${NUTTX_DIR})
223227

@@ -227,7 +231,6 @@ function(nuttx_olddefconfig)
227231
${NUTTX_BINARY_DIR}/.config.compressed ${NUTTX_BINARY_DIR}/defconfig.tmp
228232
${NUTTX_BINARY_DIR}/defconfig.orig
229233
WORKING_DIRECTORY ${NUTTX_DIR})
230-
231234
endfunction()
232235

233236
function(nuttx_setconfig)

0 commit comments

Comments
 (0)