feat(cmakev2/build): add idf_build_generate_metadata function

The `idf_build_generate_metadata()` function is used to generate project
metadata, specifically the `project_description.json` file, for a given
executable target. The output file path can be specified as an argument
to the function, allowing metadata generation for multiple executables.
It identifies the library, created by the `idf_build_library` function,
that is linked to the executable based on the `LINK_LIBRARIES`
executable target property. The `LIBRARY_INTERFACES` build property
tracks all library interfaces created with the `idf_build_library`
function, so the targets in the `LINK_LIBRARIES` executable property are
checked against this list to find the library. The library contains
information about components linked to it in the
`LIBRARY_COMPONENTS_LINKED` library property. These components are
processed and added to the `build_component_info` dictionary in the
`project_description.json` along with other information.

Note that, compared to cmakev1, the `all_component_info` dictionary in
`project_description` does not include some information by default, such
as included directories. This information is available in cmakev1 due to
early component evaluation, which is not done in cmakev2. This will
likely require some adjustments on the hints side.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2025-11-04 07:48:14 +01:00
parent e87205592a
commit aad467b5d1
4 changed files with 200 additions and 29 deletions
+3 -1
View File
@@ -208,8 +208,11 @@ endfunction()
# cmake --build build/ --target hello_world_example
# cmake --build build/ --target fatfs_example
function(test_executable)
idf_build_get_property(build_dir BUILD_DIR)
idf_build_executable(fatfs_example COMPONENTS fatfs_example)
idf_build_generate_metadata(fatfs_example FILE "${build_dir}/project_description_fatfs.json")
idf_build_executable(hello_world_example COMPONENTS hello_world_example)
idf_build_generate_metadata(hello_world_example FILE "${build_dir}/project_description_hello_world.json")
endfunction()
# Run tests
@@ -229,6 +232,5 @@ idf_project_default()
test_component_priority()
__dump_all_properties()
__generate_project_info()
message("ALL TESTS PASSED")