From 0e8c7284ce7652d20a91771a2b34c21af0542c5d Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 8 Aug 2022 12:57:45 +0200 Subject: [PATCH 1/2] 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 e7e34f12d5..10b85b882f 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -843,6 +843,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 4e81aa35c3..1aa70adfec 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -429,10 +429,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() From 1be5e5eae5e7a7a5b26a8ff9539d75e5e94a2c5e Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 24 Aug 2022 10:34:54 +0200 Subject: [PATCH 2/2] ci: fix incorrect paths in the build system test The working directory when the test runs is not $IDF_PATH, it is the directory of the template project. --- tools/ci/test_build_system_cmake.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 10b85b882f..9cc0f91390 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -854,25 +854,24 @@ endmenu\n" >> ${IDF_PATH}/Kconfig 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." - cd "$IDF_PATH/projects/temp_test_project" + pushd "$PWD/projects/temp_test_project" echo "Building the project temp_test_project . . ." idf.py build || failure "Failed to build the project." - cd "$IDF_PATH" - rm -rf "$IDF_PATH/projects/temp_test_project" + popd + rm -rf "$PWD/projects/temp_test_project" print_status "Create component using idf.py, create project using idf.py." print_status "Add the component to the created project and build the project." echo "Trying to create project . . ." (idf.py -C projects create-project temp_test_project) || failure "Failed to create the project." + pushd "$PWD/projects/temp_test_project" echo "Trying to create component . . ." (idf.py -C components create-component temp_test_component) || failure "Failed to create the component." - ${SED} -i '5i\\tfunc();' "$IDF_PATH/projects/temp_test_project/main/temp_test_project.c" - ${SED} -i '5i#include "temp_test_component.h"' "$IDF_PATH/projects/temp_test_project/main/temp_test_project.c" - cd "$IDF_PATH/projects/temp_test_project" + ${SED} -i '5i\\tfunc();' "main/temp_test_project.c" + ${SED} -i '5i#include "temp_test_component.h"' "main/temp_test_project.c" idf.py build || failure "Failed to build the project." - cd "$IDF_PATH" - rm -rf "$IDF_PATH/projects/temp_test_project" - rm -rf "$IDF_PATH/components/temp_test_component" + popd + rm -rf "$PWD/projects/temp_test_project" print_status "Check that command for creating new project will fail if the target folder is not empty." mkdir "$IDF_PATH/example_proj/"