Merge branch 'bugfix/default_components_for_component_manager' into 'master'

build & config: Don't include common components on early expansion

Closes IDF-4823

See merge request espressif/esp-idf!17728
This commit is contained in:
Sergei Silnov
2022-05-31 01:26:28 +08:00
5 changed files with 27 additions and 6 deletions

View File

@@ -1280,10 +1280,12 @@ These are properties that describe a component. Values of component properties c
- KCONFIG - component Kconfig file; set by ``idf_build_component`` - KCONFIG - component Kconfig file; set by ``idf_build_component``
- KCONFIG_PROJBUILD - component Kconfig.projbuild; set by ``idf_build_component`` - KCONFIG_PROJBUILD - component Kconfig.projbuild; set by ``idf_build_component``
- LDFRAGMENTS - list of component linker fragment files; set from ``idf_component_register`` LDFRAGMENTS argument - LDFRAGMENTS - list of component linker fragment files; set from ``idf_component_register`` LDFRAGMENTS argument
- MANAGED_PRIV_REQUIRES - list of private component dependencies added by the IDF component manager from dependencies in ``idf_component.yml`` manifest file
- MANAGED_REQUIRES - list of public component dependencies added by the IDF component manager from dependencies in ``idf_component.yml`` manifest file
- PRIV_INCLUDE_DIRS - list of component private include directories; set from ``idf_component_register`` PRIV_INCLUDE_DIRS on components of type LIBRARY - PRIV_INCLUDE_DIRS - list of component private include directories; set from ``idf_component_register`` PRIV_INCLUDE_DIRS on components of type LIBRARY
- PRIV_REQUIRES - list of private component dependentices; set from ``idf_component_register`` PRIV_REQUIRES argument - PRIV_REQUIRES - list of private component dependentices; set from value of ``idf_component_register`` PRIV_REQUIRES argument and dependencies in ``idf_component.yml`` manifest file
- REQUIRED_IDF_TARGETS - list of targets the component supports; set from ``idf_component_register`` EMBED_TXTFILES argument - REQUIRED_IDF_TARGETS - list of targets the component supports; set from ``idf_component_register`` EMBED_TXTFILES argument
- REQUIRES - list of public component dependencies; set from ``idf_component_register`` REQUIRES argument - REQUIRES - list of public component dependencies; set from value of ``idf_component_register`` REQUIRES argument and dependencies in ``idf_component.yml`` manifest file
- SRCS - list of component source files; set from SRCS or SRC_DIRS/EXCLUDE_SRCS argument of ``idf_component_register`` - SRCS - list of component source files; set from SRCS or SRC_DIRS/EXCLUDE_SRCS argument of ``idf_component_register``
- WHOLE_ARCHIVE - if this property is set to ``TRUE`` (or any boolean "true" CMake value: 1, ``ON``, ``YES``, ``Y``), the component library is surrounded by ``-Wl,--whole-archive``, ``-Wl,--no-whole-archive`` when linked. This can be used to force the linker to include every object file into the executable, even if the object file doesn't resolve any references from the rest of the application. This is commonly used when a component contains plugins or modules which rely on link-time registration. This property is ``FALSE`` by default. It can be set to ``TRUE`` from the component CMakeLists.txt file. - WHOLE_ARCHIVE - if this property is set to ``TRUE`` (or any boolean "true" CMake value: 1, ``ON``, ``YES``, ``Y``), the component library is surrounded by ``-Wl,--whole-archive``, ``-Wl,--no-whole-archive`` when linked. This can be used to force the linker to include every object file into the executable, even if the object file doesn't resolve any references from the rest of the application. This is commonly used when a component contains plugins or modules which rely on link-time registration. This property is ``FALSE`` by default. It can be set to ``TRUE`` from the component CMakeLists.txt file.

View File

@@ -222,6 +222,14 @@ function(__build_expand_requirements component_target)
get_property(reqs TARGET ${component_target} PROPERTY REQUIRES) get_property(reqs TARGET ${component_target} PROPERTY REQUIRES)
get_property(priv_reqs TARGET ${component_target} PROPERTY PRIV_REQUIRES) get_property(priv_reqs TARGET ${component_target} PROPERTY PRIV_REQUIRES)
__component_get_property(component_name ${component_target} COMPONENT_NAME) __component_get_property(component_name ${component_target} COMPONENT_NAME)
__component_get_property(component_alias ${component_target} COMPONENT_ALIAS)
idf_build_get_property(common_reqs __COMPONENT_REQUIRES_COMMON)
list(APPEND reqs ${common_reqs})
if(reqs)
list(REMOVE_DUPLICATES reqs)
list(REMOVE_ITEM reqs ${component_alias} ${component_name})
endif()
foreach(req ${reqs}) foreach(req ${reqs})
depgraph_add_edge(${component_name} ${req} REQUIRES) depgraph_add_edge(${component_name} ${req} REQUIRES)
@@ -452,10 +460,12 @@ macro(idf_build_process target)
# Call for the component manager to prepare remote dependencies # Call for the component manager to prepare remote dependencies
idf_build_get_property(python PYTHON) idf_build_get_property(python PYTHON)
idf_build_get_property(component_manager_interface_version __COMPONENT_MANAGER_INTERFACE_VERSION)
execute_process(COMMAND ${python} execute_process(COMMAND ${python}
"-m" "-m"
"idf_component_manager.prepare_components" "idf_component_manager.prepare_components"
"--project_dir=${project_dir}" "--project_dir=${project_dir}"
"--interface_version=${component_manager_interface_version}"
"prepare_dependencies" "prepare_dependencies"
"--local_components_list_file=${local_components_list_file}" "--local_components_list_file=${local_components_list_file}"
"--managed_components_list_file=${managed_components_list_file}" "--managed_components_list_file=${managed_components_list_file}"

View File

@@ -227,10 +227,17 @@ function(__component_get_requirements)
idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER) idf_build_get_property(idf_component_manager IDF_COMPONENT_MANAGER)
if(idf_component_manager EQUAL 1) if(idf_component_manager EQUAL 1)
idf_build_get_property(python PYTHON) idf_build_get_property(python PYTHON)
idf_build_get_property(component_manager_interface_version __COMPONENT_MANAGER_INTERFACE_VERSION)
# Call for the component manager once again to inject dependencies
# It modifies the requirements file generated by component_get_requirements.cmake script by adding dependencies
# defined in component manager manifests to REQUIRES and PRIV_REQUIRES fields.
# These requirements are also set as MANAGED_REQUIRES and MANAGED_PRIV_REQUIRES component properties.
execute_process(COMMAND ${python} execute_process(COMMAND ${python}
"-m" "-m"
"idf_component_manager.prepare_components" "idf_component_manager.prepare_components"
"--project_dir=${project_dir}" "--project_dir=${project_dir}"
"--interface_version=${component_manager_interface_version}"
"inject_requirements" "inject_requirements"
"--idf_path=${idf_path}" "--idf_path=${idf_path}"
"--build_dir=${build_dir}" "--build_dir=${build_dir}"

View File

@@ -43,6 +43,8 @@ endif()
if(NOT "$ENV{IDF_COMPONENT_MANAGER}" EQUAL "0") if(NOT "$ENV{IDF_COMPONENT_MANAGER}" EQUAL "0")
idf_build_set_property(IDF_COMPONENT_MANAGER 1) idf_build_set_property(IDF_COMPONENT_MANAGER 1)
endif() endif()
# Set component manager interface version
idf_build_set_property(__COMPONENT_MANAGER_INTERFACE_VERSION 1)
# #
# Get the project version from either a version file or the Git revision. This is passed # Get the project version from either a version file or the Git revision. This is passed
@@ -445,8 +447,10 @@ macro(project project_name)
__component_get_target(main_target idf::main) __component_get_target(main_target idf::main)
__component_get_property(reqs ${main_target} REQUIRES) __component_get_property(reqs ${main_target} REQUIRES)
__component_get_property(priv_reqs ${main_target} PRIV_REQUIRES) __component_get_property(priv_reqs ${main_target} PRIV_REQUIRES)
idf_build_get_property(common_reqs __COMPONENT_REQUIRES_COMMON) __component_get_property(managed_reqs ${main_target} MANAGED_REQUIRES)
if(reqs STREQUAL common_reqs AND NOT priv_reqs) #if user has not set any requirements __component_get_property(managed_priv_reqs ${main_target} MANAGED_PRIV_REQUIRES)
#if user has not set any requirements, except ones added with the component manager
if((NOT reqs OR reqs STREQUAL managed_reqs) AND (NOT priv_reqs OR priv_reqs STREQUAL managed_priv_reqs))
if(test_components) if(test_components)
list(REMOVE_ITEM build_components ${test_components}) list(REMOVE_ITEM build_components ${test_components})
endif() endif()

View File

@@ -123,8 +123,6 @@ foreach(__component_target ${__component_targets})
__component_get_requirements() __component_get_requirements()
list(APPEND __component_requires "${__common_reqs}")
# Remove duplicates and the component itself from its requirements # Remove duplicates and the component itself from its requirements
__component_get_property(__component_alias ${__component_target} COMPONENT_ALIAS) __component_get_property(__component_alias ${__component_target} COMPONENT_ALIAS)
__component_get_property(__component_name ${__component_target} COMPONENT_NAME) __component_get_property(__component_name ${__component_target} COMPONENT_NAME)