mirror of
https://github.com/espressif/esp-idf.git
synced 2026-05-28 16:46:31 +03:00
fix(cmakev2/utilities): resolve embed file path in idf_component_include
Commitf62f45cf5cchanged target_add_binary_data to resolve the embedded file path relative to the component directory by using idf_component_get_property to obtain the COMPONENT_DIR. This fixed the path resolution when target_add_binary_data is called from idf_component_include, which runs outside the component's directory context. However, target_add_binary_data can also be called directly from a project's CMakeLists.txt with a non-component target, e.g. target_add_binary_data(app.elf ...) as done in examples/security/security_features_app. In this case, idf_component_get_property fails because the target is not a component. Fix this by moving the path resolution to idf_component_include, where the embed file paths from EMBED_FILES and EMBED_TXTFILES component properties are resolved to absolute paths relative to COMPONENT_DIR before being passed to target_add_binary_data. This way, target_add_binary_data receives already absolute paths from idf_component_include and can use plain get_filename_component(ABSOLUTE) for direct calls, which correctly resolves relative to CMAKE_CURRENT_SOURCE_DIR. Fixes:f62f45cf5c("fix(cmakev2/utilities): add a dependency target for the embedded file") Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -963,13 +963,17 @@ function(idf_component_include name)
|
||||
idf_die("Unsupported target type '${component_real_target_type}' in component '${component_name}'")
|
||||
endif()
|
||||
|
||||
idf_component_get_property(component_dir "${component_name}" COMPONENT_DIR)
|
||||
|
||||
idf_component_get_property(embed_files "${component_name}" EMBED_FILES)
|
||||
foreach(file IN LISTS embed_files)
|
||||
get_filename_component(file "${file}" ABSOLUTE BASE_DIR "${component_dir}")
|
||||
target_add_binary_data(${COMPONENT_TARGET} "${file}" "BINARY")
|
||||
endforeach()
|
||||
|
||||
idf_component_get_property(embed_txtfiles "${component_name}" EMBED_TXTFILES)
|
||||
foreach(file IN LISTS embed_txtfiles)
|
||||
get_filename_component(file "${file}" ABSOLUTE BASE_DIR "${component_dir}")
|
||||
target_add_binary_data(${COMPONENT_TARGET} "${file}" "TEXT")
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -837,12 +837,7 @@ function(target_add_binary_data target embed_file embed_type)
|
||||
idf_build_get_property(build_dir BUILD_DIR)
|
||||
idf_build_get_property(idf_path IDF_PATH)
|
||||
|
||||
# The target_add_binary_data function is also called within the
|
||||
# idf_component_include function, which is not executed in the component
|
||||
# directory context. Therefore, ensure that the absolute path of the
|
||||
# embedded file is resolved relative to the component directory.
|
||||
idf_component_get_property(component_directory "${target}" COMPONENT_DIR)
|
||||
get_filename_component(embed_file "${embed_file}" ABSOLUTE BASE_DIR "${component_directory}")
|
||||
get_filename_component(embed_file "${embed_file}" ABSOLUTE)
|
||||
|
||||
get_filename_component(name "${embed_file}" NAME)
|
||||
set(embed_srcfile "${build_dir}/${name}.S")
|
||||
|
||||
Reference in New Issue
Block a user