From 3b7eee3978c31dde7ee99ca07d0b61739360cc15 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 8 Aug 2022 12:57:45 +0200 Subject: [PATCH] build: fix excluded components being passed to component manager `__COMPONENT_TARGETS` is evaluated very early when components and component directories are added to the build, which means that all components (including the ones which are in EXCLUDE_COMPONENTS) have a build system target defined. The component manager was given the list of all known components (derived from the list of targets), not the list of components after EXCLUDE_COMPONENTS were processed. Because of that, EXCLUDE_COMPONENTS didn't effectively exclude the component from the consideration of the component manager. --- tools/ci/test_build_system_cmake.sh | 8 ++++++++ tools/cmake/build.cmake | 6 ++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 247d3e1e05a..f75a3e710ba 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -936,6 +936,14 @@ endmenu\n" >> ${IDF_PATH}/Kconfig mv CMakeLists.bak CMakeLists.txt # revert previous modifications rm -rf extra_dir components + print_status "Components in EXCLUDE_COMPONENTS not passed to idf_component_manager" + clean_build_dir + idf.py create-component -C components/ to_be_excluded || failure "Failed to create a component" + echo "invalid syntax..." > components/to_be_excluded/idf_component.yml + ! idf.py reconfigure || failure "Build should have failed due to invalid syntax in idf_component.yml" + idf.py -DEXCLUDE_COMPONENTS=to_be_excluded reconfigure || failure "Build should have succeeded when the component is excluded" + rm -rf components/to_be_excluded + print_status "Create project using idf.py and build it" echo "Trying to create project." (idf.py -C projects create-project temp_test_project) || failure "Failed to create the project." diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 0a274e89ebe..589d163fb7b 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -494,10 +494,8 @@ macro(idf_build_process target) set(local_components_list_file ${build_dir}/local_components_list.temp.yml) set(__contents "components:\n") - idf_build_get_property(__component_targets __COMPONENT_TARGETS) - foreach(__component_target ${__component_targets}) - __component_get_property(__component_name ${__component_target} COMPONENT_NAME) - __component_get_property(__component_dir ${__component_target} COMPONENT_DIR) + 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") endforeach()