cmake: support generator expressions in build_info()

This patch enables support for genexes in the 'build_info()' function by
identifying when arguments contain them and passing the GENEX flag to
'yaml_set()'.

Genexes are not supported in tag lists; using them will immediately
trigger an error by the schema checks.

They are also not currently supported with PATH entries, because the
actual contents of the list (whose paths are to be converted) are not
known until after the CMake code has been processed.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This commit is contained in:
Luca Burelli 2025-02-06 16:09:33 +01:00 committed by Benjamin Cabé
commit 7fa1fb7181

View file

@ -3679,11 +3679,11 @@ function(topological_sort)
endfunction()
# Usage:
# build_info(<tag>... VALUE <value>... )
# build_info(<tag>... PATH <path>... )
# build_info(<tag>... VALUE <value>...)
# build_info(<tag>... PATH <path>...)
#
# This function populates updates the build_info.yml info file with exchangable build information
# related to the current build.
# This function populates the build_info.yml info file with exchangable build
# information related to the current build.
#
# Example:
# build_info(devicetree files VALUE file1.dts file2.dts file3.dts)
@ -3713,6 +3713,14 @@ function(build_info)
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}(...) missing a required argument: VALUE or PATH")
endif()
string(GENEX_STRIP "${arg_list}" arg_list_no_genexes)
if (NOT "${arg_list}" STREQUAL "${arg_list_no_genexes}")
if (convert_path)
message(FATAL_ERROR "build_info: generator expressions unsupported on PATH entries")
endif()
set(genex_flag GENEX)
endif()
yaml_context(EXISTS NAME build_info result)
if(NOT result)
yaml_load(FILE ${ZEPHYR_BASE}/scripts/schemas/build-schema.yml NAME build_info_schema)
@ -3755,7 +3763,7 @@ function(build_info)
endif()
endif()
yaml_set(NAME build_info KEY cmake ${keys} ${type} "${values}")
yaml_set(NAME build_info KEY cmake ${keys} ${type} "${values}" ${genex_flag})
endfunction()
########################################################