mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(cmakev2/build): track components linked to library
There may be multiple libraries, each linking a different set of components. Introduce a new library property, LIBRARY_COMPONENTS_LINKED, to track the components linked with a specific library. This property can be used, for example, by menuconfig to distinguish between included and excluded components on a per-library or per-executable basis, or by ldgen to identify linker scripts for the linked components. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -228,6 +228,14 @@ endfunction()
|
|||||||
``INTERFACE`` option and link component targets to it based on the component
|
``INTERFACE`` option and link component targets to it based on the component
|
||||||
names provided in the ``COMPONENTS`` option. If ``COMPONENTS`` option is not
|
names provided in the ``COMPONENTS`` option. If ``COMPONENTS`` option is not
|
||||||
set, link component targets of all discovered components.
|
set, link component targets of all discovered components.
|
||||||
|
|
||||||
|
List of library properties
|
||||||
|
|
||||||
|
:LIBRARY_COMPONENTS: List of component as specified by the ``COMPONENTS``
|
||||||
|
option.
|
||||||
|
:LIBRARY_COMPONENTS_LINKED: List of components linked to the library based
|
||||||
|
on recursive evaluations of the INTERFACE_LINK_LIBRARIES
|
||||||
|
and LINK_LIBRARIES target properties.
|
||||||
#]]
|
#]]
|
||||||
function(idf_build_library)
|
function(idf_build_library)
|
||||||
set(options)
|
set(options)
|
||||||
@@ -271,4 +279,23 @@ function(idf_build_library)
|
|||||||
idf_component_get_property(component_interface "${component_name}" COMPONENT_INTERFACE)
|
idf_component_get_property(component_interface "${component_name}" COMPONENT_INTERFACE)
|
||||||
target_link_libraries("${ARG_INTERFACE}" INTERFACE "${component_interface}")
|
target_link_libraries("${ARG_INTERFACE}" INTERFACE "${component_interface}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# Identify the components linked to the library by obtaining all targets
|
||||||
|
# that are transitively linked to the library and mapping these targets to
|
||||||
|
# components.
|
||||||
|
__get_target_dependencies(TARGET "${ARG_INTERFACE}" OUTPUT dependencies)
|
||||||
|
set(dep_component_interfaces)
|
||||||
|
foreach(dep IN LISTS dependencies)
|
||||||
|
__get_component_interface(COMPONENT "${dep}" OUTPUT component_interface)
|
||||||
|
if(NOT component_interface)
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
if("${component_interface}" IN_LIST dep_component_interfaces)
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND dep_component_interfaces "${component_interface}")
|
||||||
|
idf_component_get_property(component_name "${component_interface}" COMPONENT_NAME)
|
||||||
|
idf_library_set_property("${ARG_INTERFACE}" LIBRARY_COMPONENTS_LINKED "${component_name}" APPEND)
|
||||||
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
Reference in New Issue
Block a user