Skip to content

Commit

Permalink
[nrf fromtree] version: cmake: kconfig: introduce extra <type>_VERSIO…
Browse files Browse the repository at this point in the history
…N_<x>_STRING

Fixes: #68360

This commit introduces <type>_VERSION_TWEAK_STRING which includes
the tweak field in the string, but without the extra version.
This format is used by MCUboot / imgtool, and thus makes it easier to
align code to the format used by MCUboot.

This commit also introduces <type>_VERSION_EXTENDED_STRING which
includes the tweak field in the string in addition to the extra version
field.

The new defines / variables is available in code, CMake, and Kconfig,
and it defined for KERNEL, APP, and custom types, such as MCUBOOT.

Signed-off-by: Torsten Rasmussen <[email protected]>
Signed-off-by: Jamie McCrae <[email protected]>
(cherry picked from commit a306397)
  • Loading branch information
tejlmand authored and jfischer-no committed Feb 26, 2024
1 parent 51cdc6d commit ed9ae51
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 83 deletions.
2 changes: 2 additions & 0 deletions cmake/modules/kconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ set(COMMON_KCONFIG_ENV_SETTINGS
srctree=${ZEPHYR_BASE}
KERNELVERSION=${KERNELVERSION}
APPVERSION=${APP_VERSION_STRING}
APP_VERSION_EXTENDED_STRING=${APP_VERSION_EXTENDED_STRING}
APP_VERSION_TWEAK_STRING=${APP_VERSION_TWEAK_STRING}
CONFIG_=${KCONFIG_NAMESPACE}_
KCONFIG_CONFIG=${DOTCONFIG}
# Set environment variables so that Kconfig can prune Kconfig source
Expand Down
14 changes: 10 additions & 4 deletions cmake/modules/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#
# Outputs with examples::
#
# PROJECT_VERSION 1.14.99.07
# KERNEL_VERSION_STRING "1.14.99-extraver"
# PROJECT_VERSION 1.14.99.07
# KERNEL_VERSION_STRING "1.14.99-extraver"
# KERNEL_VERSION_EXTENDED_STRING "1.14.99-extraver+7"
# KERNEL_VERSION_TWEAK_STRING "1.14.99+7"
#
# KERNEL_VERSION_MAJOR 1
# KERNEL_VERSION_MINOR 14
Expand Down Expand Up @@ -62,9 +64,9 @@ foreach(type file IN ZIP_LISTS VERSION_TYPE VERSION_FILE)
string(REGEX MATCH "EXTRAVERSION = ([a-z0-9]*)" _ ${ver})
set(${type}_VERSION_EXTRA ${CMAKE_MATCH_1})

# Temporary convenience variable
# Temporary convenience variables
set(${type}_VERSION_WITHOUT_TWEAK ${${type}_VERSION_MAJOR}.${${type}_VERSION_MINOR}.${${type}_PATCHLEVEL})

set(${type}_VERSION_WITH_TWEAK ${${type}_VERSION_MAJOR}.${${type}_VERSION_MINOR}.${${type}_PATCHLEVEL}+${${type}_VERSION_TWEAK})

set(MAJOR ${${type}_VERSION_MAJOR}) # Temporary convenience variable
set(MINOR ${${type}_VERSION_MINOR}) # Temporary convenience variable
Expand All @@ -82,6 +84,8 @@ foreach(type file IN ZIP_LISTS VERSION_TYPE VERSION_FILE)
else()
set(${type}_VERSION_STRING "${${type}_VERSION_WITHOUT_TWEAK}")
endif()
set(${type}_VERSION_TWEAK_STRING "${${type}_VERSION_WITH_TWEAK}")
set(${type}_VERSION_EXTENDED_STRING "${${type}_VERSION_STRING}+${${type}_VERSION_TWEAK}")

if(type STREQUAL KERNEL)
set(PROJECT_VERSION_MAJOR ${${type}_VERSION_MAJOR})
Expand Down Expand Up @@ -118,5 +122,7 @@ foreach(type file IN ZIP_LISTS VERSION_TYPE VERSION_FILE)
unset(MAJOR)
unset(MINOR)
unset(PATCH)
unset(TWEAK)
unset(${type}_VERSION_WITHOUT_TWEAK)
unset(${type}_VERSION_WITH_TWEAK)
endforeach()
Loading

0 comments on commit ed9ae51

Please sign in to comment.