mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(cmakev2/component): use __idf_component_get_property_unchecked
In some instances, the COMPONENTS_DISCOVERED build property is used to walk through the component list and obtain component properties, such as during configuration preparation or the inclusion of project_include files. Since we know the component interfaces from the COMPONENT_INTERFACES build property, we can switch to the faster `__idf_component_get_property_unchecked` method to obtain component properties in these cases. This change reduces the reconfiguration time by 0.4 seconds on my computer. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
+25
-22
@@ -611,12 +611,12 @@ function(idf_build_executable executable)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#[[
|
#[[
|
||||||
__get_components_metadata(COMPONENTS <component>...
|
__get_components_metadata(COMPONENTS <component_interface>...
|
||||||
OUTPUT <variable>)
|
OUTPUT <variable>)
|
||||||
|
|
||||||
*COMPONENTS[in]*
|
*COMPONENTS[in]*
|
||||||
|
|
||||||
List of components for which to generate metadata.
|
List of component interfaces for which to generate metadata.
|
||||||
|
|
||||||
*OUTPUT[out]*
|
*OUTPUT[out]*
|
||||||
|
|
||||||
@@ -641,19 +641,20 @@ function(__get_components_metadata)
|
|||||||
|
|
||||||
set(components_json "")
|
set(components_json "")
|
||||||
|
|
||||||
foreach(name IN LISTS ARG_COMPONENTS)
|
foreach(interface IN LISTS ARG_COMPONENTS)
|
||||||
idf_component_get_property(target ${name} COMPONENT_REAL_TARGET)
|
__idf_component_get_property_unchecked(name ${interface} COMPONENT_NAME)
|
||||||
idf_component_get_property(alias ${name} COMPONENT_ALIAS)
|
__idf_component_get_property_unchecked(target ${interface} COMPONENT_REAL_TARGET)
|
||||||
idf_component_get_property(prefix ${name} __PREFIX)
|
__idf_component_get_property_unchecked(alias ${interface} COMPONENT_ALIAS)
|
||||||
idf_component_get_property(dir ${name} COMPONENT_DIR)
|
__idf_component_get_property_unchecked(prefix ${interface} __PREFIX)
|
||||||
idf_component_get_property(type ${name} COMPONENT_TYPE)
|
__idf_component_get_property_unchecked(dir ${interface} COMPONENT_DIR)
|
||||||
idf_component_get_property(lib ${name} COMPONENT_LIB)
|
__idf_component_get_property_unchecked(type ${interface} COMPONENT_TYPE)
|
||||||
idf_component_get_property(reqs ${name} REQUIRES)
|
__idf_component_get_property_unchecked(lib ${interface} COMPONENT_LIB)
|
||||||
idf_component_get_property(include_dirs ${name} INCLUDE_DIRS)
|
__idf_component_get_property_unchecked(reqs ${interface} REQUIRES)
|
||||||
idf_component_get_property(priv_reqs ${name} PRIV_REQUIRES)
|
__idf_component_get_property_unchecked(include_dirs ${interface} INCLUDE_DIRS)
|
||||||
idf_component_get_property(managed_reqs ${name} MANAGED_REQUIRES)
|
__idf_component_get_property_unchecked(priv_reqs ${interface} PRIV_REQUIRES)
|
||||||
idf_component_get_property(managed_priv_reqs ${name} MANAGED_PRIV_REQUIRES)
|
__idf_component_get_property_unchecked(managed_reqs ${interface} MANAGED_REQUIRES)
|
||||||
idf_component_get_property(component_source ${name} COMPONENT_SOURCE)
|
__idf_component_get_property_unchecked(managed_priv_reqs ${interface} MANAGED_PRIV_REQUIRES)
|
||||||
|
__idf_component_get_property_unchecked(component_source ${interface} COMPONENT_SOURCE)
|
||||||
if("${type}" STREQUAL "LIBRARY")
|
if("${type}" STREQUAL "LIBRARY")
|
||||||
set(file "$<TARGET_LINKER_FILE:${lib}>")
|
set(file "$<TARGET_LINKER_FILE:${lib}>")
|
||||||
|
|
||||||
@@ -774,16 +775,18 @@ function(idf_build_generate_metadata binary)
|
|||||||
__make_json_list("${common_component_reqs}" OUTPUT common_component_reqs_json)
|
__make_json_list("${common_component_reqs}" OUTPUT common_component_reqs_json)
|
||||||
|
|
||||||
idf_library_get_property(build_components "${library}" LIBRARY_COMPONENTS_LINKED)
|
idf_library_get_property(build_components "${library}" LIBRARY_COMPONENTS_LINKED)
|
||||||
|
idf_library_get_property(build_component_interfaces "${library}" LIBRARY_COMPONENT_INTERFACES_LINKED)
|
||||||
list(SORT build_components)
|
list(SORT build_components)
|
||||||
|
list(SORT build_component_interfaces)
|
||||||
__make_json_list("${build_components}" OUTPUT build_components_json)
|
__make_json_list("${build_components}" OUTPUT build_components_json)
|
||||||
|
|
||||||
set(build_component_paths)
|
set(build_component_paths)
|
||||||
set(COMPONENT_KCONFIGS)
|
set(COMPONENT_KCONFIGS)
|
||||||
set(COMPONENT_KCONFIGS_PROJBUILD)
|
set(COMPONENT_KCONFIGS_PROJBUILD)
|
||||||
foreach(component_name IN LISTS build_components)
|
foreach(component_interface IN LISTS build_component_interfaces)
|
||||||
idf_component_get_property(component_dir "${component_name}" COMPONENT_DIR)
|
__idf_component_get_property_unchecked(component_dir "${component_interface}" COMPONENT_DIR)
|
||||||
idf_component_get_property(component_kconfig "${component_name}" __KCONFIG)
|
__idf_component_get_property_unchecked(component_kconfig "${component_interface}" __KCONFIG)
|
||||||
idf_component_get_property(component_kconfig_projbuild "${component_name}" __KCONFIG_PROJBUILD)
|
__idf_component_get_property_unchecked(component_kconfig_projbuild "${component_interface}" __KCONFIG_PROJBUILD)
|
||||||
list(APPEND build_component_paths "${component_dir}")
|
list(APPEND build_component_paths "${component_dir}")
|
||||||
if(component_kconfig)
|
if(component_kconfig)
|
||||||
list(APPEND COMPONENT_KCONFIGS "${component_kconfig}")
|
list(APPEND COMPONENT_KCONFIGS "${component_kconfig}")
|
||||||
@@ -794,10 +797,10 @@ function(idf_build_generate_metadata binary)
|
|||||||
endforeach()
|
endforeach()
|
||||||
__make_json_list("${build_component_paths}" OUTPUT build_component_paths_json)
|
__make_json_list("${build_component_paths}" OUTPUT build_component_paths_json)
|
||||||
|
|
||||||
__get_components_metadata(COMPONENTS "${build_components}" OUTPUT build_component_info_json)
|
__get_components_metadata(COMPONENTS "${build_component_interfaces}" OUTPUT build_component_info_json)
|
||||||
|
|
||||||
idf_build_get_property(components_discovered COMPONENTS_DISCOVERED)
|
idf_build_get_property(component_interfaces COMPONENT_INTERFACES)
|
||||||
__get_components_metadata(COMPONENTS "${components_discovered}" OUTPUT all_component_info_json)
|
__get_components_metadata(COMPONENTS "${component_interfaces}" OUTPUT all_component_info_json)
|
||||||
|
|
||||||
__generate_gdbinit()
|
__generate_gdbinit()
|
||||||
idf_build_get_property(gdbinit_files_prefix_map GDBINIT_FILES_PREFIX_MAP)
|
idf_build_get_property(gdbinit_files_prefix_map GDBINIT_FILES_PREFIX_MAP)
|
||||||
|
|||||||
+16
-15
@@ -173,14 +173,14 @@ endfunction()
|
|||||||
__consolidate_component_kconfig_files()
|
__consolidate_component_kconfig_files()
|
||||||
|
|
||||||
Consolidate Kconfig files from discovered components into global build
|
Consolidate Kconfig files from discovered components into global build
|
||||||
properties. This scans the COMPONENTS_DISCOVERED build property and for
|
properties. This scans the COMPONENT_INTERFACES build property and for
|
||||||
each component, retrieves its Kconfig files from component properties and
|
each component, retrieves its Kconfig files from component properties and
|
||||||
adds them to the global __KCONFIGS, __KCONFIG_PROJBUILDS, and
|
adds them to the global __KCONFIGS, __KCONFIG_PROJBUILDS, and
|
||||||
__SDKCONFIG_RENAMES build properties.
|
__SDKCONFIG_RENAMES build properties.
|
||||||
#]]
|
#]]
|
||||||
function(__consolidate_component_kconfig_files)
|
function(__consolidate_component_kconfig_files)
|
||||||
idf_build_get_property(components_discovered COMPONENTS_DISCOVERED)
|
idf_build_get_property(component_interfaces COMPONENT_INTERFACES)
|
||||||
if(NOT components_discovered)
|
if(NOT component_interfaces)
|
||||||
idf_die("No components discovered. This must be run after component discovery.")
|
idf_die("No components discovered. This must be run after component discovery.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -190,12 +190,13 @@ function(__consolidate_component_kconfig_files)
|
|||||||
idf_build_set_property(__KCONFIG_PROJBUILDS "")
|
idf_build_set_property(__KCONFIG_PROJBUILDS "")
|
||||||
idf_build_set_property(__SDKCONFIG_RENAMES "")
|
idf_build_set_property(__SDKCONFIG_RENAMES "")
|
||||||
|
|
||||||
# Iterate through all discovered components and consolidate their Kconfig files
|
# Iterate through all interfaces of discovered components and consolidate
|
||||||
foreach(component_name IN LISTS components_discovered)
|
# their Kconfig files
|
||||||
|
foreach(component_interface IN LISTS component_interfaces)
|
||||||
# Get Kconfig files from component properties
|
# Get Kconfig files from component properties
|
||||||
idf_component_get_property(component_kconfig "${component_name}" __KCONFIG)
|
__idf_component_get_property_unchecked(component_kconfig "${component_interface}" __KCONFIG)
|
||||||
idf_component_get_property(component_projbuild "${component_name}" __KCONFIG_PROJBUILD)
|
__idf_component_get_property_unchecked(component_projbuild "${component_interface}" __KCONFIG_PROJBUILD)
|
||||||
idf_component_get_property(component_rename "${component_name}" __SDKCONFIG_RENAME)
|
__idf_component_get_property_unchecked(component_rename "${component_interface}" __SDKCONFIG_RENAME)
|
||||||
|
|
||||||
if(component_kconfig)
|
if(component_kconfig)
|
||||||
idf_build_set_property(__KCONFIGS "${component_kconfig}" APPEND)
|
idf_build_set_property(__KCONFIGS "${component_kconfig}" APPEND)
|
||||||
@@ -395,20 +396,20 @@ function(__create_executable_config_env_file executable)
|
|||||||
|
|
||||||
__get_executable_library_or_die(TARGET "${executable}" OUTPUT library)
|
__get_executable_library_or_die(TARGET "${executable}" OUTPUT library)
|
||||||
|
|
||||||
idf_library_get_property(components_linked "${library}" LIBRARY_COMPONENTS_LINKED)
|
idf_library_get_property(component_interfaces_linked "${library}" LIBRARY_COMPONENT_INTERFACES_LINKED)
|
||||||
|
|
||||||
set(kconfigs "")
|
set(kconfigs "")
|
||||||
set(kconfigs_projbuild "")
|
set(kconfigs_projbuild "")
|
||||||
set(kconfigs_excluded "")
|
set(kconfigs_excluded "")
|
||||||
set(kconfigs_projbuild_excluded "")
|
set(kconfigs_projbuild_excluded "")
|
||||||
|
|
||||||
idf_build_get_property(components_discovered COMPONENTS_DISCOVERED)
|
idf_build_get_property(component_interfaces COMPONENT_INTERFACES)
|
||||||
foreach(component_name IN LISTS components_discovered)
|
foreach(component_interface IN LISTS component_interfaces)
|
||||||
idf_component_get_property(component_kconfig "${component_name}" __KCONFIG)
|
__idf_component_get_property_unchecked(component_kconfig "${component_interface}" __KCONFIG)
|
||||||
idf_component_get_property(component_projbuild "${component_name}" __KCONFIG_PROJBUILD)
|
__idf_component_get_property_unchecked(component_projbuild "${component_interface}" __KCONFIG_PROJBUILD)
|
||||||
|
|
||||||
if(component_kconfig)
|
if(component_kconfig)
|
||||||
if("${component_name}" IN_LIST components_linked)
|
if("${component_interface}" IN_LIST component_interfaces_linked)
|
||||||
list(APPEND kconfigs "${component_kconfig}")
|
list(APPEND kconfigs "${component_kconfig}")
|
||||||
else()
|
else()
|
||||||
list(APPEND kconfigs_excluded "${component_kconfig}")
|
list(APPEND kconfigs_excluded "${component_kconfig}")
|
||||||
@@ -416,7 +417,7 @@ function(__create_executable_config_env_file executable)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(component_projbuild)
|
if(component_projbuild)
|
||||||
if("${component_name}" IN_LIST components_linked)
|
if("${component_interface}" IN_LIST component_interfaces_linked)
|
||||||
list(APPEND kconfigs_projbuild "${component_projbuild}")
|
list(APPEND kconfigs_projbuild "${component_projbuild}")
|
||||||
else()
|
else()
|
||||||
list(APPEND kconfigs_projbuild_excluded "${component_projbuild}")
|
list(APPEND kconfigs_projbuild_excluded "${component_projbuild}")
|
||||||
|
|||||||
@@ -184,9 +184,10 @@ function(__download_component_level_managed_components)
|
|||||||
|
|
||||||
# Build local components list from discovered components
|
# Build local components list from discovered components
|
||||||
set(__contents "components:\n")
|
set(__contents "components:\n")
|
||||||
idf_build_get_property(component_names COMPONENTS_DISCOVERED)
|
idf_build_get_property(component_interfaces COMPONENT_INTERFACES)
|
||||||
foreach(name ${component_names})
|
foreach(interface ${component_interfaces})
|
||||||
idf_component_get_property(dir ${name} COMPONENT_DIR)
|
__idf_component_get_property_unchecked(name ${interface} COMPONENT_NAME)
|
||||||
|
__idf_component_get_property_unchecked(dir ${interface} COMPONENT_DIR)
|
||||||
set(__contents "${__contents} - name: \"${name}\"\n path: \"${dir}\"\n")
|
set(__contents "${__contents} - name: \"${name}\"\n path: \"${dir}\"\n")
|
||||||
endforeach()
|
endforeach()
|
||||||
file(WRITE ${local_components_list_file} "${__contents}")
|
file(WRITE ${local_components_list_file} "${__contents}")
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ function(__init_project_configuration)
|
|||||||
|
|
||||||
idf_build_get_property(idf_ver IDF_VER)
|
idf_build_get_property(idf_ver IDF_VER)
|
||||||
idf_build_get_property(idf_target IDF_TARGET)
|
idf_build_get_property(idf_target IDF_TARGET)
|
||||||
idf_build_get_property(components_discovered COMPONENTS_DISCOVERED)
|
idf_build_get_property(component_interfaces COMPONENT_INTERFACES)
|
||||||
idf_build_get_property(build_dir BUILD_DIR)
|
idf_build_get_property(build_dir BUILD_DIR)
|
||||||
idf_build_get_property(project_dir PROJECT_DIR)
|
idf_build_get_property(project_dir PROJECT_DIR)
|
||||||
idf_build_get_property(project_name PROJECT_NAME)
|
idf_build_get_property(project_name PROJECT_NAME)
|
||||||
@@ -457,8 +457,9 @@ function(__init_project_configuration)
|
|||||||
|
|
||||||
# Generate mapping for component paths
|
# Generate mapping for component paths
|
||||||
set(gdbinit_file_lines)
|
set(gdbinit_file_lines)
|
||||||
foreach(component_name ${components_discovered})
|
foreach(component_interface ${component_interfaces})
|
||||||
idf_component_get_property(component_dir ${component_name} COMPONENT_DIR)
|
__idf_component_get_property_unchecked(component_name ${component_interface} COMPONENT_NAME)
|
||||||
|
__idf_component_get_property_unchecked(component_dir ${component_interface} COMPONENT_DIR)
|
||||||
|
|
||||||
string(TOUPPER ${component_name} component_name_uppercase)
|
string(TOUPPER ${component_name} component_name_uppercase)
|
||||||
set(substituted_path "/COMPONENT_${component_name_uppercase}_DIR")
|
set(substituted_path "/COMPONENT_${component_name_uppercase}_DIR")
|
||||||
@@ -599,10 +600,11 @@ macro(idf_project_init)
|
|||||||
|
|
||||||
# Include all project_include.cmake files for the components that have
|
# Include all project_include.cmake files for the components that have
|
||||||
# been discovered.
|
# been discovered.
|
||||||
idf_build_get_property(component_names COMPONENTS_DISCOVERED)
|
idf_build_get_property(component_interfaces COMPONENT_INTERFACES)
|
||||||
foreach(component_name IN LISTS component_names)
|
foreach(component_interface IN LISTS component_interfaces)
|
||||||
idf_component_get_property(project_include ${component_name} __PROJECT_INCLUDE)
|
__idf_component_get_property_unchecked(project_include ${component_interface} __PROJECT_INCLUDE)
|
||||||
idf_component_get_property(component_dir ${component_name} COMPONENT_DIR)
|
__idf_component_get_property_unchecked(component_dir ${component_interface} COMPONENT_DIR)
|
||||||
|
__idf_component_get_property_unchecked(component_name ${component_interface} COMPONENT_NAME)
|
||||||
if(project_include)
|
if(project_include)
|
||||||
set(COMPONENT_NAME ${component_name})
|
set(COMPONENT_NAME ${component_name})
|
||||||
set(COMPONENT_DIR ${component_dir})
|
set(COMPONENT_DIR ${component_dir})
|
||||||
|
|||||||
Reference in New Issue
Block a user