Skip to content

Commit 7db55e6

Browse files
tejlmandjukkar
authored andcommitted
[nrf fromtree] cmake: support build info in Zephyr
Store informations regarding the current Zephyr build. The following informations are stored during CMake configure: - Board information - Application source directory - Application configuration directory - Toolchain information - Devicetree files - Kconfig config files - Zephyr version Signed-off-by: Torsten Rasmussen <[email protected]> (cherry picked from commit 09faf53) (cherry picked from commit a9ba90a)
1 parent 4362657 commit 7db55e6

File tree

7 files changed

+32
-0
lines changed

7 files changed

+32
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,3 +2234,10 @@ add_subdirectory_ifdef(
22342234
)
22352235

22362236
toolchain_linker_finalize()
2237+
2238+
yaml_context(EXISTS NAME build_info result)
2239+
if(result)
2240+
build_info(zephyr version VALUE ${PROJECT_VERSION_STR})
2241+
build_info(zephyr zephyr-base VALUE ${ZEPHYR_BASE})
2242+
yaml_save(NAME build_info)
2243+
endif()

cmake/modules/FindHostTools.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,6 @@ set_ifndef(TOOLCHAIN_KCONFIG_DIR ${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOL
114114

115115
set(HostTools_FOUND TRUE)
116116
set(HOSTTOOLS_FOUND TRUE)
117+
build_info(toolchain name VALUE ${ZEPHYR_TOOLCHAIN_VARIANT})
118+
string(TOUPPER ${ZEPHYR_TOOLCHAIN_VARIANT} zephyr_toolchain_variant_upper)
119+
build_info(toolchain path VALUE "${${zephyr_toolchain_variant_upper}_TOOLCHAIN_PATH}")

cmake/modules/boards.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,7 @@ if(BOARD_EXTENSIONS)
353353
list(APPEND BOARD_EXTENSION_DIRS ${board_extension_dir})
354354
endforeach()
355355
endif()
356+
build_info(board name VALUE ${BOARD})
357+
string(REGEX REPLACE "^/" "" qualifiers "${BOARD_QUALIFIERS}")
358+
build_info(board qualifiers VALUE ${qualifiers})
359+
build_info(board revision VALUE ${BOARD_REVISION})

cmake/modules/configuration_files.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,5 @@ zephyr_boilerplate_watch(DTC_OVERLAY_FILE)
9999
zephyr_get(EXTRA_CONF_FILE SYSBUILD LOCAL VAR EXTRA_CONF_FILE OVERLAY_CONFIG MERGE REVERSE)
100100
zephyr_get(EXTRA_DTC_OVERLAY_FILE SYSBUILD LOCAL MERGE REVERSE)
101101
zephyr_get(DTS_EXTRA_CPPFLAGS SYSBUILD LOCAL MERGE REVERSE)
102+
build_info(application source-dir VALUE ${APPLICATION_SOURCE_DIR})
103+
build_info(application configuration-dir VALUE ${APPLICATION_CONFIG_DIR})

cmake/modules/dts.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ set(dts_files
182182
if(DTC_OVERLAY_FILE)
183183
zephyr_list(TRANSFORM DTC_OVERLAY_FILE NORMALIZE_PATHS
184184
OUTPUT_VARIABLE DTC_OVERLAY_FILE_AS_LIST)
185+
build_info(devicetree user-files VALUE ${DTC_OVERLAY_FILE_AS_LIST})
185186
list(APPEND
186187
dts_files
187188
${DTC_OVERLAY_FILE_AS_LIST}
@@ -191,6 +192,7 @@ endif()
191192
if(EXTRA_DTC_OVERLAY_FILE)
192193
zephyr_list(TRANSFORM EXTRA_DTC_OVERLAY_FILE NORMALIZE_PATHS
193194
OUTPUT_VARIABLE EXTRA_DTC_OVERLAY_FILE_AS_LIST)
195+
build_info(devicetree extra-user-files VALUE ${EXTRA_DTC_OVERLAY_FILE_AS_LIST})
194196
list(APPEND
195197
dts_files
196198
${EXTRA_DTC_OVERLAY_FILE_AS_LIST}
@@ -396,3 +398,7 @@ elseif(stderr)
396398
message(WARNING "dtc raised one or more warnings:\n${stderr}")
397399
endif()
398400
endif(DTC)
401+
402+
build_info(devicetree files VALUE ${dts_files})
403+
build_info(devicetree include-dirs VALUE ${DTS_ROOT_SYSTEM_INCLUDE_DIRS})
404+
build_info(devicetree bindings-dirs VALUE ${DTS_ROOT_BINDINGS})

cmake/modules/kconfig.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ set(PARSED_KCONFIG_SOURCES_TXT ${PROJECT_BINARY_DIR}/kconfig/sources.txt)
9898
if(CONF_FILE)
9999
string(CONFIGURE "${CONF_FILE}" CONF_FILE_EXPANDED)
100100
string(REPLACE " " ";" CONF_FILE_AS_LIST "${CONF_FILE_EXPANDED}")
101+
build_info(kconfig user-files VALUE ${CONF_FILE_AS_LIST})
101102
endif()
102103

103104
if(EXTRA_CONF_FILE)
104105
string(CONFIGURE "${EXTRA_CONF_FILE}" EXTRA_CONF_FILE_EXPANDED)
105106
string(REPLACE " " ";" EXTRA_CONF_FILE_AS_LIST "${EXTRA_CONF_FILE_EXPANDED}")
107+
build_info(kconfig extra-user-files VALUE ${EXTRA_CONF_FILE_AS_LIST})
106108
endif()
107109

108110
zephyr_file(CONF_FILES ${BOARD_EXTENSION_DIRS} KCONF board_extension_conf_files SUFFIX ${FILE_SUFFIX})
@@ -358,6 +360,7 @@ endif()
358360
if(CREATE_NEW_DOTCONFIG)
359361
set(input_configs_flags --handwritten-input-configs)
360362
set(input_configs ${merge_config_files} ${FORCED_CONF_FILE})
363+
build_info(kconfig files VALUE ${input_configs})
361364
else()
362365
set(input_configs ${DOTCONFIG} ${FORCED_CONF_FILE})
363366
endif()

share/sysbuild/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ if(EXISTS ${APP_DIR}/sysbuild/CMakeLists.txt)
2525
else()
2626
add_subdirectory(template _sysbuild)
2727
endif()
28+
29+
build_info(sysbuild VALUE true)
30+
build_info(application source-dir VALUE ${CMAKE_CURRENT_SOURCE_DIR})
31+
yaml_context(EXISTS NAME build_info result)
32+
if(result)
33+
yaml_save(NAME build_info)
34+
endif()

0 commit comments

Comments
 (0)