From 879494b7ac5bde5aaf4a76970f07f245efeb1802 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 7d6f3c3767..22bb1b9063 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -201,30 +201,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() @@ -270,7 +263,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}" @@ -289,7 +282,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