mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Merge branch 'feat/add_merged_hints_to_build' into 'master'
Build & Config: Create a merged hints database in the build directory Closes IDF-15480 See merge request espressif/esp-idf!46861
This commit is contained in:
@@ -754,7 +754,8 @@ endfunction()
|
||||
|
||||
idf_build_generate_metadata([BINARY <binary>]
|
||||
[EXECUTABLE <executable>]
|
||||
[OUTPUT_FILE <file>])
|
||||
[OUTPUT_FILE <file>]
|
||||
[HINTS_OUTPUT_FILE <file>])
|
||||
|
||||
*BINARY[in,opt]*
|
||||
|
||||
@@ -769,6 +770,13 @@ endfunction()
|
||||
Optional output file path for storing the metadata. If not provided,
|
||||
the default path ``<build>/project_description.json`` is used.
|
||||
|
||||
*HINTS_OUTPUT_FILE[in,opt]*
|
||||
|
||||
Optional output file path for storing the merged hints YAML file. If
|
||||
not provided, hints generation is skipped entirely. This opt-in
|
||||
behaviour prevents hint files from different binaries overwriting each
|
||||
other in multi-binary projects.
|
||||
|
||||
Generate metadata for the specified ``binary`` or ``executable`` target and
|
||||
store it in the specified ``OUTPUT_FILE``. If no ``OUTPUT_FILE`` is
|
||||
provided, the default location ``<build>/project_description.json`` will be
|
||||
@@ -776,7 +784,7 @@ endfunction()
|
||||
#]]
|
||||
function(idf_build_generate_metadata)
|
||||
set(options)
|
||||
set(one_value OUTPUT_FILE BINARY EXECUTABLE)
|
||||
set(one_value OUTPUT_FILE BINARY EXECUTABLE HINTS_OUTPUT_FILE)
|
||||
set(multi_value)
|
||||
cmake_parse_arguments(ARG "${options}" "${one_value}" "${multi_value}" ${ARGN})
|
||||
|
||||
@@ -865,11 +873,37 @@ function(idf_build_generate_metadata)
|
||||
|
||||
get_filename_component(ARG_OUTPUT_FILE "${ARG_OUTPUT_FILE}" ABSOLUTE BASE_DIR "${BUILD_DIR}")
|
||||
|
||||
if(DEFINED ARG_HINTS_OUTPUT_FILE)
|
||||
set(HINTS_FILE "${ARG_HINTS_OUTPUT_FILE}")
|
||||
else()
|
||||
set(HINTS_FILE "")
|
||||
endif()
|
||||
configure_file("${IDF_PATH}/tools/cmake/project_description.json.in" "${ARG_OUTPUT_FILE}.templ")
|
||||
file(READ "${ARG_OUTPUT_FILE}.templ" project_description_json_templ)
|
||||
file(REMOVE "${ARG_OUTPUT_FILE}.templ")
|
||||
file(GENERATE OUTPUT "${ARG_OUTPUT_FILE}"
|
||||
CONTENT "${project_description_json_templ}")
|
||||
|
||||
# Assumption: all hints.yml files are bare YAML lists (no "---" document
|
||||
# separators). Plain string concatenation is safe under this assumption.
|
||||
# Note for consumers: yaml.safe_load() only parses the first YAML document,
|
||||
# so document separators in source files would cause data loss.
|
||||
if(DEFINED ARG_HINTS_OUTPUT_FILE)
|
||||
set(_merged_hints "")
|
||||
set(_global_hints_file "${IDF_PATH}/tools/idf_py_actions/hints.yml")
|
||||
if(EXISTS "${_global_hints_file}")
|
||||
file(READ "${_global_hints_file}" _hints_content)
|
||||
string(APPEND _merged_hints "${_hints_content}\n")
|
||||
endif()
|
||||
foreach(_comp_dir ${build_component_paths})
|
||||
set(_hints_file "${_comp_dir}/hints.yml")
|
||||
if(EXISTS "${_hints_file}")
|
||||
file(READ "${_hints_file}" _hints_content)
|
||||
string(APPEND _merged_hints "${_hints_content}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
file(WRITE "${ARG_HINTS_OUTPUT_FILE}" "${_merged_hints}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
|
||||
@@ -747,7 +747,8 @@ function(__project_default)
|
||||
TARGET app-flash
|
||||
NAME "app"
|
||||
FLASH)
|
||||
idf_build_generate_metadata(BINARY "${executable}_binary_signed")
|
||||
idf_build_generate_metadata(BINARY "${executable}_binary_signed"
|
||||
HINTS_OUTPUT_FILE "${BUILD_DIR}/hints.yml")
|
||||
else()
|
||||
idf_build_binary("${executable}"
|
||||
OUTPUT_FILE "${build_dir}/${executable}.bin"
|
||||
@@ -764,12 +765,14 @@ function(__project_default)
|
||||
|
||||
idf_create_dfu("${executable}_binary"
|
||||
TARGET dfu)
|
||||
idf_build_generate_metadata(BINARY "${executable}_binary")
|
||||
idf_build_generate_metadata(BINARY "${executable}_binary"
|
||||
HINTS_OUTPUT_FILE "${BUILD_DIR}/hints.yml")
|
||||
endif()
|
||||
|
||||
idf_build_generate_flasher_args()
|
||||
else()
|
||||
idf_build_generate_metadata(EXECUTABLE "${executable}")
|
||||
idf_build_generate_metadata(EXECUTABLE "${executable}"
|
||||
HINTS_OUTPUT_FILE "${BUILD_DIR}/hints.yml")
|
||||
endif()
|
||||
|
||||
idf_create_menuconfig("${executable}"
|
||||
|
||||
Reference in New Issue
Block a user