mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
feat(cmakev2/ldgen): provide ldgen with a list of mutable libraries
The build system keeps track of each component source. Currently there are four types of sources: 1. "project_components" - project components 2. "project_extra_components" - components from EXTRA_COMPONENT_DIRS 3. "project_managed_components" - custom project dependencies managed by the IDF Component Manager 4. "idf_components" - ESP-IDF built-in components, typically under /components This can be used to identify the component libraries that are likely to change during application development and pass them to ldgen as mutable libraries. Add all components with "project_components" as their source as mutable. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -364,6 +364,29 @@ function(idf_build_library library)
|
||||
idf_library_set_property("${library}" __LDGEN_FRAGMENT_FILES "${ldfragments}" APPEND)
|
||||
endforeach()
|
||||
|
||||
# Collect the filenames of project component archives, which are considered
|
||||
# mutable, in the __LDGEN_MUTABLE_LIBS library property. These libraries
|
||||
# are placed by ldgen into a separate location in the linker script,
|
||||
# enabling the fast reflashing feature.
|
||||
foreach(component_interface IN LISTS component_interfaces_linked)
|
||||
idf_component_get_property(component_source "${component_interface}" COMPONENT_SOURCE)
|
||||
idf_component_get_property(component_target "${component_interface}" COMPONENT_TARGET)
|
||||
idf_component_get_property(component_type "${component_interface}" COMPONENT_TYPE)
|
||||
|
||||
if("${component_type}" STREQUAL "CONFIG_ONLY")
|
||||
# Configuration only component interface target without a library.
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(NOT "${component_source}" STREQUAL "project_components")
|
||||
# Add only project components as mutable.
|
||||
continue()
|
||||
endif()
|
||||
|
||||
idf_library_set_property("${library}" __LDGEN_MUTABLE_LIBS
|
||||
"$<TARGET_LINKER_FILE_NAME:${component_target}>" APPEND)
|
||||
endforeach()
|
||||
|
||||
# Collect archive files from all targets linked to the library interface
|
||||
# and store them in the __LDGEN_DEPENDS and __LDGEN_LIBRARIES library
|
||||
# properties. These properties are used by ldgen to generate linker scripts
|
||||
|
||||
@@ -83,6 +83,17 @@ function(__ldgen_process_template)
|
||||
idf_msg("Mapping check enabled in ldgen")
|
||||
endif()
|
||||
|
||||
if(CONFIG_ESPTOOLPY_FAST_REFLASHING)
|
||||
# Create a file containing a list of mutable libraries used by ldgen
|
||||
# for fast reflashing.
|
||||
idf_library_get_property(ldgen_mutable_libs "${ARG_LIBRARY}" __LDGEN_MUTABLE_LIBS)
|
||||
set(mutable_libs_path "${build_dir}/ldgen_mutable_libraries${ARG_SUFFIX}")
|
||||
list(JOIN ldgen_mutable_libs "\n" ldgen_mutable_libs_str)
|
||||
file(GENERATE OUTPUT "${mutable_libs_path}"
|
||||
CONTENT "${ldgen_mutable_libs_str}")
|
||||
set(mutable_libs_option "--mutable-libraries-file" "${mutable_libs_path}")
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${ARG_OUTPUT}"
|
||||
COMMAND ${python} "${idf_path}/tools/ldgen/ldgen.py"
|
||||
@@ -96,6 +107,7 @@ function(__ldgen_process_template)
|
||||
--libraries-file "${build_dir}/ldgen_libraries${ARG_SUFFIX}"
|
||||
--objdump "${CMAKE_OBJDUMP}"
|
||||
${ldgen_check}
|
||||
${mutable_libs_option}
|
||||
DEPENDS ${ARG_TEMPLATE} ${ldgen_fragment_files} ${ldgen_depends} ${sdkconfig}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user