Skip to content

Commit e22de81

Browse files
committed
Merge branch 'feature/idfpy_update_component_manager_tests' into 'master'
CMake - process dependencies for all components by component manager Closes PACMAN-87 See merge request espressif/esp-idf!9357
2 parents 31e565c + a5981c1 commit e22de81

File tree

4 files changed

+68
-42
lines changed

4 files changed

+68
-42
lines changed

tools/ci/test_build_system_cmake.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,12 @@ endmenu\n" >> ${IDF_PATH}/Kconfig
696696
# Make sure that component manager is not installed
697697
pip uninstall -y idf_component_manager
698698
printf "\n#include \"test_component.h\"\n" >> main/main.c
699-
printf "dependencies:\n test_component:\n path: test_component\n git: ${COMPONENT_MANAGER_TEST_REPO}\n" >> idf_project.yml
699+
printf "dependencies:\n test_component:\n path: test_component\n git: ${COMPONENT_MANAGER_TEST_REPO}\n" >> main/idf_component.yml
700700
! idf.py build || failure "Build should fail if dependencies are not installed"
701-
pip install ${COMPONENT_MANAGER_REPO} || failure "Failed to install the component manager"
701+
pip install ${COMPONENT_MANAGER_PACKAGE} --upgrade || failure "Failed to install component manager"
702702
idf.py reconfigure build || failure "Build didn't succeed with required components installed by package manager"
703703
pip uninstall -y idf_component_manager
704-
rm idf_project.yml
704+
rm main/idf_component.yml
705705
git checkout main/main.c
706706

707707
print_status "Build fails if partitions don't fit in flash"

tools/cmake/build.cmake

+64
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,70 @@ macro(idf_build_process target)
407407
idf_build_set_property(__COMPONENT_REQUIRES_COMMON "")
408408
endif()
409409

410+
# Call for component manager to download dependencies for all components
411+
idf_build_set_property(IDF_COMPONENT_MANAGER "$ENV{IDF_COMPONENT_MANAGER}")
412+
idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER)
413+
if(idf_component_manager)
414+
if(idf_component_manager EQUAL "0")
415+
message(VERBOSE "IDF Component manager was explicitly disabled by setting IDF_COMPONENT_MANAGER=0")
416+
elseif(idf_component_manager EQUAL "1")
417+
set(managed_components_list_file ${build_dir}/managed_components_list.temp.cmake)
418+
set(local_components_list_file ${build_dir}/local_components_list.temp.yml)
419+
420+
set(__contents "components:\n")
421+
idf_build_get_property(__component_targets __COMPONENT_TARGETS)
422+
foreach(__component_target ${__component_targets})
423+
__component_get_property(__component_name ${__component_target} COMPONENT_NAME)
424+
__component_get_property(__component_dir ${__component_target} COMPONENT_DIR)
425+
set(__contents "${__contents} - name: \"${__component_name}\"\n path: \"${__component_dir}\"\n")
426+
endforeach()
427+
428+
file(WRITE ${local_components_list_file} "${__contents}")
429+
430+
# Call for the component manager to prepare remote dependencies
431+
execute_process(COMMAND ${PYTHON}
432+
"-m"
433+
"idf_component_manager.prepare_components"
434+
"--project_dir=${project_dir}"
435+
"prepare_dependencies"
436+
"--local_components_list_file=${local_components_list_file}"
437+
"--managed_components_list_file=${managed_components_list_file}"
438+
RESULT_VARIABLE result
439+
ERROR_VARIABLE error)
440+
441+
if(NOT result EQUAL 0)
442+
message(FATAL_ERROR "${error}")
443+
endif()
444+
445+
include(${managed_components_list_file})
446+
447+
# Add managed components to list of all components
448+
# `managed_components` contains the list of components installed by the component manager
449+
# It is defined in the temporary managed_components_list_file file
450+
set(__COMPONENTS "${__COMPONENTS};${managed_components}")
451+
452+
file(REMOVE ${managed_components_list_file})
453+
file(REMOVE ${local_components_list_file})
454+
else()
455+
message(WARNING "IDF_COMPONENT_MANAGER environment variable is set to unknown value "
456+
"\"${idf_component_manager}\". If you want to use component manager set it to 1.")
457+
endif()
458+
else()
459+
idf_build_get_property(__component_targets __COMPONENT_TARGETS)
460+
set(__components_with_manifests "")
461+
foreach(__component_target ${__component_targets})
462+
__component_get_property(__component_dir ${__component_target} COMPONENT_DIR)
463+
if(EXISTS "${__component_dir}/idf_component.yml")
464+
set(__components_with_manifests "${__components_with_manifests}\t${__component_dir}\n")
465+
endif()
466+
endforeach()
467+
468+
if(NOT "${__components_with_manifests}" STREQUAL "")
469+
message(WARNING "\"idf_component.yml\" file was found for components:\n${__components_with_manifests}"
470+
"However, the component manager is not enabled.")
471+
endif()
472+
endif()
473+
410474
# Perform early expansion of component CMakeLists.txt in CMake scripting mode.
411475
# It is here we retrieve the public and private requirements of each component.
412476
# It is also here we add the common component requirements to each component's

tools/cmake/component.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ function(__component_get_requirements)
232232
"-m"
233233
"idf_component_manager.prepare_components"
234234
"--project_dir=${project_dir}"
235-
"inject_requrements"
235+
"inject_requirements"
236236
"--idf_path=${idf_path}"
237237
"--build_dir=${build_dir}"
238238
"--component_requires_file=${component_requires_file}"

tools/cmake/project.cmake

-38
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ function(__project_init components_var test_components_var)
169169
endif()
170170
endfunction()
171171

172-
idf_build_set_property(IDF_COMPONENT_MANAGER "$ENV{IDF_COMPONENT_MANAGER}")
173172

174173
# Add component directories to the build, given the component filters, exclusions
175174
# extra directories, etc. passed from the root CMakeLists.txt.
@@ -181,43 +180,6 @@ function(__project_init components_var test_components_var)
181180
__project_component_dir(${component_dir})
182181
endforeach()
183182
else()
184-
# Add project manifest and lock file to the list of dependencies
185-
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/idf_project.yml")
186-
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/dependencies.lock")
187-
188-
idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER)
189-
if(idf_component_manager)
190-
if(idf_component_manager EQUAL "0")
191-
message(VERBOSE "IDF Component manager was explicitly disabled by setting IDF_COMPONENT_MANAGER=0")
192-
elseif(idf_component_manager EQUAL "1")
193-
set(managed_components_list_file ${CMAKE_BINARY_DIR}/managed_components_list.temp.cmake)
194-
195-
# Call for package manager to prepare remote dependencies
196-
execute_process(COMMAND ${PYTHON}
197-
"-m"
198-
"idf_component_manager.prepare_components"
199-
"--project_dir=${CMAKE_CURRENT_LIST_DIR}"
200-
"prepare_dependencies"
201-
"--managed_components_list_file=${managed_components_list_file}"
202-
RESULT_VARIABLE result
203-
ERROR_VARIABLE error)
204-
205-
if(NOT result EQUAL 0)
206-
message(FATAL_ERROR "${error}")
207-
endif()
208-
209-
# Include managed components
210-
include(${managed_components_list_file})
211-
file(REMOVE ${managed_components_list_file})
212-
else()
213-
message(WARNING "IDF_COMPONENT_MANAGER environment variable is set to unknown value "
214-
"\"${idf_component_manager}\". If you want to use component manager set it to 1.")
215-
endif()
216-
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/idf_project.yml")
217-
message(WARNING "\"idf_project.yml\" file is found in project directory, "
218-
"but component manager is not enabled. Please set IDF_COMPONENT_MANAGER environment variable.")
219-
endif()
220-
221183
spaces2list(EXTRA_COMPONENT_DIRS)
222184
foreach(component_dir ${EXTRA_COMPONENT_DIRS})
223185
__project_component_dir("${component_dir}")

0 commit comments

Comments
 (0)