diff --git a/tools/ci/test_build_system_cmake.sh b/tools/ci/test_build_system_cmake.sh index 4072a9cec5..d0d24dd6bb 100755 --- a/tools/ci/test_build_system_cmake.sh +++ b/tools/ci/test_build_system_cmake.sh @@ -696,12 +696,12 @@ endmenu\n" >> ${IDF_PATH}/Kconfig # Make sure that component manager is not installed pip uninstall -y idf_component_manager printf "\n#include \"test_component.h\"\n" >> main/main.c - printf "dependencies:\n test_component:\n path: test_component\n git: ${COMPONENT_MANAGER_TEST_REPO}\n" >> idf_project.yml + printf "dependencies:\n test_component:\n path: test_component\n git: ${COMPONENT_MANAGER_TEST_REPO}\n" >> main/idf_component.yml ! idf.py build || failure "Build should fail if dependencies are not installed" - pip install ${COMPONENT_MANAGER_REPO} || failure "Failed to install the component manager" + pip install ${COMPONENT_MANAGER_PACKAGE} --upgrade || failure "Failed to install component manager" idf.py reconfigure build || failure "Build didn't succeed with required components installed by package manager" pip uninstall -y idf_component_manager - rm idf_project.yml + rm main/idf_component.yml git checkout main/main.c print_status "Build fails if partitions don't fit in flash" diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 934ab8905f..54fd6520fb 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -407,6 +407,70 @@ macro(idf_build_process target) idf_build_set_property(__COMPONENT_REQUIRES_COMMON "") endif() + # Call for component manager to download dependencies for all components + idf_build_set_property(IDF_COMPONENT_MANAGER "$ENV{IDF_COMPONENT_MANAGER}") + idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER) + if(idf_component_manager) + if(idf_component_manager EQUAL "0") + message(VERBOSE "IDF Component manager was explicitly disabled by setting IDF_COMPONENT_MANAGER=0") + elseif(idf_component_manager EQUAL "1") + set(managed_components_list_file ${build_dir}/managed_components_list.temp.cmake) + 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) + set(__contents "${__contents} - name: \"${__component_name}\"\n path: \"${__component_dir}\"\n") + endforeach() + + file(WRITE ${local_components_list_file} "${__contents}") + + # Call for the component manager to prepare remote dependencies + execute_process(COMMAND ${PYTHON} + "-m" + "idf_component_manager.prepare_components" + "--project_dir=${project_dir}" + "prepare_dependencies" + "--local_components_list_file=${local_components_list_file}" + "--managed_components_list_file=${managed_components_list_file}" + RESULT_VARIABLE result + ERROR_VARIABLE error) + + if(NOT result EQUAL 0) + message(FATAL_ERROR "${error}") + endif() + + include(${managed_components_list_file}) + + # Add managed components to list of all components + # `managed_components` contains the list of components installed by the component manager + # It is defined in the temporary managed_components_list_file file + set(__COMPONENTS "${__COMPONENTS};${managed_components}") + + file(REMOVE ${managed_components_list_file}) + file(REMOVE ${local_components_list_file}) + else() + message(WARNING "IDF_COMPONENT_MANAGER environment variable is set to unknown value " + "\"${idf_component_manager}\". If you want to use component manager set it to 1.") + endif() + else() + idf_build_get_property(__component_targets __COMPONENT_TARGETS) + set(__components_with_manifests "") + foreach(__component_target ${__component_targets}) + __component_get_property(__component_dir ${__component_target} COMPONENT_DIR) + if(EXISTS "${__component_dir}/idf_component.yml") + set(__components_with_manifests "${__components_with_manifests}\t${__component_dir}\n") + endif() + endforeach() + + if(NOT "${__components_with_manifests}" STREQUAL "") + message(WARNING "\"idf_component.yml\" file was found for components:\n${__components_with_manifests}" + "However, the component manager is not enabled.") + endif() + endif() + # Perform early expansion of component CMakeLists.txt in CMake scripting mode. # It is here we retrieve the public and private requirements of each component. # It is also here we add the common component requirements to each component's diff --git a/tools/cmake/component.cmake b/tools/cmake/component.cmake index 47e3f21594..5a99ba84e7 100644 --- a/tools/cmake/component.cmake +++ b/tools/cmake/component.cmake @@ -232,7 +232,7 @@ function(__component_get_requirements) "-m" "idf_component_manager.prepare_components" "--project_dir=${project_dir}" - "inject_requrements" + "inject_requirements" "--idf_path=${idf_path}" "--build_dir=${build_dir}" "--component_requires_file=${component_requires_file}" diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 8329ed50af..c9479565e5 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -169,7 +169,6 @@ function(__project_init components_var test_components_var) endif() endfunction() - idf_build_set_property(IDF_COMPONENT_MANAGER "$ENV{IDF_COMPONENT_MANAGER}") # Add component directories to the build, given the component filters, exclusions # extra directories, etc. passed from the root CMakeLists.txt. @@ -181,43 +180,6 @@ function(__project_init components_var test_components_var) __project_component_dir(${component_dir}) endforeach() else() - # Add project manifest and lock file to the list of dependencies - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/idf_project.yml") - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/dependencies.lock") - - idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER) - if(idf_component_manager) - if(idf_component_manager EQUAL "0") - message(VERBOSE "IDF Component manager was explicitly disabled by setting IDF_COMPONENT_MANAGER=0") - elseif(idf_component_manager EQUAL "1") - set(managed_components_list_file ${CMAKE_BINARY_DIR}/managed_components_list.temp.cmake) - - # Call for package manager to prepare remote dependencies - execute_process(COMMAND ${PYTHON} - "-m" - "idf_component_manager.prepare_components" - "--project_dir=${CMAKE_CURRENT_LIST_DIR}" - "prepare_dependencies" - "--managed_components_list_file=${managed_components_list_file}" - RESULT_VARIABLE result - ERROR_VARIABLE error) - - if(NOT result EQUAL 0) - message(FATAL_ERROR "${error}") - endif() - - # Include managed components - include(${managed_components_list_file}) - file(REMOVE ${managed_components_list_file}) - else() - message(WARNING "IDF_COMPONENT_MANAGER environment variable is set to unknown value " - "\"${idf_component_manager}\". If you want to use component manager set it to 1.") - endif() - elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/idf_project.yml") - message(WARNING "\"idf_project.yml\" file is found in project directory, " - "but component manager is not enabled. Please set IDF_COMPONENT_MANAGER environment variable.") - endif() - spaces2list(EXTRA_COMPONENT_DIRS) foreach(component_dir ${EXTRA_COMPONENT_DIRS}) __project_component_dir("${component_dir}")