Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2472,4 +2472,4 @@ toolchain_linker_finalize()
build_info(zephyr version VALUE ${PROJECT_VERSION_STR})
build_info(zephyr zephyr-base VALUE ${ZEPHYR_BASE})

yaml_save(NAME build_info)
build_info_save()
10 changes: 3 additions & 7 deletions cmake/modules/dts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function(dts_configuration_files)
${EXTRA_DTC_OVERLAY_FILE_AS_LIST}
)
endif()
build_info(devicetree files PATH ${dts_files})

set(i 0)
foreach(dts_file ${dts_files})
Expand Down Expand Up @@ -234,6 +235,7 @@ function(dts_configuration_files)

set(DTS_ROOT_BINDINGS ${DTS_ROOT_BINDINGS} PARENT_SCOPE)
endforeach()
build_info(devicetree bindings-dirs PATH ${CACHED_DTS_ROOT_BINDINGS})

# Cache the location of the root bindings so they can be used by
# scripts which use the build directory.
Expand Down Expand Up @@ -261,6 +263,7 @@ function(dts_edt_pickle)
else()
set(dts_preprocessor ${CMAKE_C_COMPILER})
endif()
build_info(devicetree include-dirs PATH ${DTS_ROOT_SYSTEM_INCLUDE_DIRS})
zephyr_dt_preprocess(
CPP ${dts_preprocessor}
SOURCE_FILES ${dts_files}
Expand Down Expand Up @@ -427,18 +430,11 @@ function(dts_dtc)
endif(DTC)
endfunction()

function(dts_build_info_output)
build_info(devicetree files PATH ${dts_files})
build_info(devicetree include-dirs PATH ${DTS_ROOT_SYSTEM_INCLUDE_DIRS})
build_info(devicetree bindings-dirs PATH ${CACHED_DTS_ROOT_BINDINGS})
endfunction()

macro(dts_init)
dts_configuration_files()
dts_edt_pickle()
dts_gen_defines()
dts_gen_driver_kconfig()
dts_import()
dts_dtc()
dts_build_info_output()
endmacro()
34 changes: 26 additions & 8 deletions cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3907,6 +3907,32 @@ function(build_info)
endif()

yaml_set(NAME build_info KEY cmake ${keys} ${type} "${values}" ${genex_flag})
if(BUILD_INFO_SYNC STREQUAL "instant")
build_info_save()
endif()
endfunction()

# Usage:
# build_info_save()
#
# This function save the build_info.yml info file with exchangeable build
# information related to the current build.
#
# If no build info context has been created, then the function does nothing.
#
function(build_info_save)
if(DEFINED BUILD_INFO_SYNC AND NOT BUILD_INFO_SYNC MATCHES "(^instant$|^module$|^final$)")
message(WARNING
"BUILD_INFO_SYNC mode '${BUILD_INFO_SYNC}' unknown, valid modes are: "
"<instant|module|final>"
)
endif()
if(COMMAND yaml_context)
yaml_context(EXISTS NAME build_info result)
if(result)
yaml_save(NAME build_info)
endif()
endif()
endfunction()

########################################################
Expand Down Expand Up @@ -6272,12 +6298,4 @@ if(CMAKE_SCRIPT_MODE_FILE)
function(set_target_properties)
# This silence the error: 'set_target_properties command is not scriptable'
endfunction()

# Build info creates a custom target for handling of build info.
# build_info is not needed in script mode but still called by Zephyr CMake
# modules. Therefore disable build_info(...) in when including
# extensions.cmake in script mode.
function(build_info)
# This silence the error: 'Unknown CMake command "yaml_context"'
endfunction()
endif()
5 changes: 5 additions & 0 deletions cmake/modules/zephyr_default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ foreach(module IN LISTS zephyr_cmake_modules)
endif()
endif()

if(BUILD_INFO_SYNC STREQUAL "module" AND COMMAND build_info_save)
build_info_save()
endif()

list(REMOVE_ITEM SUB_COMPONENTS ${module})
if(DEFINED SUB_COMPONENTS AND NOT SUB_COMPONENTS)
# All requested Zephyr CMake modules have been loaded, so let's return.
build_info_save()
return()
endif()
endforeach()
Expand Down
Loading