forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: version.h generation performed at build time
Fixes: zephyrproject-rtos#39503 Fixes: zephyrproject-rtos#40167 This commit moves `BUILD_VERSION` CMake variable from a compile definition to be a define inside version.h. Besides the benefit of having related settings grouped in a common header, it also means that an updated `BUILD_VERSION` value does not need to trigger re-compilation of all source files. When using compile definitions, CMake cannot tell whether a given source files uses the definition or not, and hence all sources must be recompiled to be sure they are up-to-date. Placing `BUILD_VERSION` in version.h, the source dependencies ensures that only source files including `version.h` gets recompiled. As part of this, version.h generation is moved so that it is now done at build time. This means that re-generation of version.h is no longer depending on a CMake re-run but can have it's own dependency in `.git/index` when git described is used to obtain `BUILD_VERSION` information. Generation of logging dictionary database has been updated to support BUILD_VERSION from header file instead of CMake configure time variable. Signed-off-by: Torsten Rasmussen <[email protected]>
- Loading branch information
Showing
6 changed files
with
61 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
if(NOT DEFINED BUILD_VERSION) | ||
find_package(Git QUIET) | ||
if(GIT_FOUND) | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} describe --abbrev=12 --always | ||
WORKING_DIRECTORY ${ZEPHYR_BASE} | ||
OUTPUT_VARIABLE BUILD_VERSION | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_STRIP_TRAILING_WHITESPACE | ||
ERROR_VARIABLE stderr | ||
RESULT_VARIABLE return_code | ||
) | ||
if(return_code) | ||
message(STATUS "git describe failed: ${stderr}") | ||
elseif(NOT "${stderr}" STREQUAL "") | ||
message(STATUS "git describe warned: ${stderr}") | ||
endif() | ||
endif() | ||
endif() | ||
|
||
include(${ZEPHYR_BASE}/cmake/version.cmake) | ||
configure_file(${ZEPHYR_BASE}/version.h.in ${OUT_FILE}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters