From d65e0e39c6c7ed532fbe2402e0cc0677731525bd Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Fri, 22 Aug 2025 15:12:30 +0200 Subject: [PATCH] fix: make sure sdkconfig.json is updated after running the menuconfig --- tools/cmake/kconfig.cmake | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/tools/cmake/kconfig.cmake b/tools/cmake/kconfig.cmake index e9413be9af..af9f02ea57 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -216,30 +216,23 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults) set(sdkconfig_json ${config_dir}/sdkconfig.json) set(sdkconfig_json_menus ${config_dir}/kconfig_menus.json) + set(kconfgen_output_options + --output header ${sdkconfig_header} + --output cmake ${sdkconfig_cmake} + --output json ${sdkconfig_json} + --output json_menus ${sdkconfig_json_menus}) idf_build_get_property(output_sdkconfig __OUTPUT_SDKCONFIG) if(output_sdkconfig) - execute_process( - COMMAND ${prepare_kconfig_files_command}) - execute_process( - COMMAND ${kconfgen_basecommand} - --output header ${sdkconfig_header} - --output cmake ${sdkconfig_cmake} - --output json ${sdkconfig_json} - --output json_menus ${sdkconfig_json_menus} - --output config ${sdkconfig} - RESULT_VARIABLE config_result) - else() - execute_process( - COMMAND ${prepare_kconfig_files_command}) - execute_process( - COMMAND ${kconfgen_basecommand} - --output header ${sdkconfig_header} - --output cmake ${sdkconfig_cmake} - --output json ${sdkconfig_json} - --output json_menus ${sdkconfig_json_menus} - RESULT_VARIABLE config_result) + list(APPEND kconfgen_output_options --output config ${sdkconfig}) endif() + execute_process( + COMMAND ${prepare_kconfig_files_command}) + execute_process( + COMMAND ${kconfgen_basecommand} + ${kconfgen_output_options} + RESULT_VARIABLE config_result) + if(config_result) message(FATAL_ERROR "Failed to run kconfgen (${kconfgen_basecommand}). Error ${config_result}") endif() @@ -298,7 +291,7 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults) --env "IDF_ENV_FPGA=${idf_env_fpga}" --env "IDF_INIT_VERSION=${idf_init_version}" --dont-write-deprecated - --output config ${sdkconfig} + ${kconfgen_output_options} COMMAND ${TERM_CHECK_CMD} COMMAND ${CMAKE_COMMAND} -E env "COMPONENT_KCONFIGS_SOURCE_FILE=${kconfigs_path}" @@ -318,7 +311,7 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults) --env "IDF_TOOLCHAIN=${idf_toolchain}" --env "IDF_ENV_FPGA=${idf_env_fpga}" --env "IDF_INIT_VERSION=${idf_init_version}" - --output config ${sdkconfig} + ${kconfgen_output_options} ) # Custom target to run kconfserver from the build tool