Skip to content

Commit

Permalink
cmake/extensions: support generator expressions in build_info()
Browse files Browse the repository at this point in the history
This patch enables support for generator expressions in the `build_info()`
function by always initializing the YAML contex with the GENEX flag.

Note that while generator expressions in PATH values are supported, the
conversion to CMake style paths will not be performed, since the
expansion is done after all cmake code has been processed.

Signed-off-by: Luca Burelli <[email protected]>
  • Loading branch information
pillo79 committed Oct 17, 2024
1 parent 3743ebc commit 8375cfd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2240,5 +2240,5 @@ yaml_context(EXISTS NAME build_info result)
if(result)
build_info(zephyr version VALUE ${PROJECT_VERSION_STR})
build_info(zephyr zephyr-base VALUE ${ZEPHYR_BASE})
yaml_save(NAME build_info)
yaml_generate(TARGET ${logical_target_for_zephyr_elf} NAME build_info)
endif()
7 changes: 4 additions & 3 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3661,7 +3661,7 @@ endfunction()
# build_info(<tag>... VALUE <value>... )
# build_info(<tag>... PATH <path>... )
#
# This function populates updates the build_info.yml info file with exchangable build information
# This function populates the build_info.yml info file with exchangable build information
# related to the current build.
#
# Example:
Expand All @@ -3679,6 +3679,7 @@ endfunction()
# PATH <path>... : path(s) to place in the build_info.yml file. All paths are converted to CMake
# style. If no conversion is required, for example when paths are already
# guaranteed to be CMake style, then VALUE can also be used.
# Note that paths expanded by generator expressions are not converted.
function(build_info)
set(convert_path FALSE)
set(arg_list ${ARGV})
Expand All @@ -3696,9 +3697,9 @@ function(build_info)
if(NOT result)
yaml_load(FILE ${ZEPHYR_BASE}/scripts/schemas/build-schema.yml NAME build_info_schema)
if(EXISTS ${CMAKE_BINARY_DIR}/build_info.yml)
yaml_load(FILE ${CMAKE_BINARY_DIR}/build_info.yml NAME build_info)
yaml_load(FILE ${CMAKE_BINARY_DIR}/build_info.yml NAME build_info GENEX)
else()
yaml_create(FILE ${CMAKE_BINARY_DIR}/build_info.yml NAME build_info)
yaml_create(FILE ${CMAKE_BINARY_DIR}/build_info.yml NAME build_info GENEX)
endif()
yaml_set(NAME build_info KEY version VALUE "0.1.0")
endif()
Expand Down

0 comments on commit 8375cfd

Please sign in to comment.