From 72d9a29a52265516e4affe2ed535aab3e61262eb Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Tue, 30 Jan 2024 14:56:58 +0100 Subject: [PATCH] fix: component manager load all component dirs even set(COMPONENTS ...) --- tools/cmake/build.cmake | 14 +++++++++++--- tools/cmake/component.cmake | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index fc70aee90d..fad7306210 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -494,9 +494,17 @@ macro(idf_build_process target) set(local_components_list_file ${build_dir}/local_components_list.temp.yml) set(__contents "components:\n") - foreach(__component_name ${components}) - idf_component_get_property(__component_dir ${__component_name} COMPONENT_DIR) - set(__contents "${__contents} - name: \"${__component_name}\"\n path: \"${__component_dir}\"\n") + idf_build_get_property(build_component_targets BUILD_COMPONENT_TARGETS) + foreach(__build_component_target ${build_component_targets}) + __component_get_property(__component_name ${__build_component_target} COMPONENT_NAME) + __component_get_property(__component_dir ${__build_component_target} COMPONENT_DIR) + + # Exclude components could be passed with -DEXCLUDE_COMPONENTS + # after the call to __component_add finished in the last run. + # Need to check if the component is excluded again + if(NOT __component_name IN_LIST EXCLUDE_COMPONENTS) + set(__contents "${__contents} - name: \"${__component_name}\"\n path: \"${__component_dir}\"\n") + endif() endforeach() file(WRITE ${local_components_list_file} "${__contents}") diff --git a/tools/cmake/component.cmake b/tools/cmake/component.cmake index 726fff2c19..be03aa2883 100644 --- a/tools/cmake/component.cmake +++ b/tools/cmake/component.cmake @@ -192,8 +192,9 @@ function(__component_add component_dir prefix) # Set Kconfig related properties on the component __kconfig_component_init(${component_target}) - # set BUILD_COMPONENT_DIRS build property + # these two properties are used to keep track of the components known to the build system idf_build_set_property(BUILD_COMPONENT_DIRS ${component_dir} APPEND) + idf_build_set_property(BUILD_COMPONENT_TARGETS ${component_target} APPEND) endfunction() #