2019-04-06 21:08:09 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2019-05-04 09:29:08 +08:00
|
|
|
#.rst:
|
|
|
|
# version.cmake
|
|
|
|
# -------------
|
|
|
|
#
|
|
|
|
# Inputs:
|
|
|
|
#
|
|
|
|
# ``*VERSION*`` and other constants set by
|
|
|
|
# maintainers in ``${ZEPHYR_BASE}/VERSION``
|
|
|
|
#
|
|
|
|
# Outputs with examples::
|
|
|
|
#
|
|
|
|
# PROJECT_VERSION 1.14.99.07
|
|
|
|
# KERNEL_VERSION_STRING "1.14.99-extraver"
|
|
|
|
#
|
|
|
|
# KERNEL_VERSION_MAJOR 1
|
|
|
|
# KERNEL_VERSION_MINOR 14
|
|
|
|
# KERNEL_PATCHLEVEL 99
|
|
|
|
# KERNELVERSION 0x10E6307
|
|
|
|
# KERNEL_VERSION_NUMBER 0x10E63
|
|
|
|
# ZEPHYR_VERSION_CODE 69219
|
|
|
|
#
|
|
|
|
# Most outputs are converted to C macros, see ``version.h.in``
|
|
|
|
#
|
|
|
|
# See also: independent and more dynamic ``BUILD_VERSION`` in
|
|
|
|
# ``git.cmake``.
|
|
|
|
|
|
|
|
|
2018-01-11 22:46:44 +08:00
|
|
|
include(${ZEPHYR_BASE}/cmake/hex.cmake)
|
|
|
|
file(READ ${ZEPHYR_BASE}/VERSION ver)
|
2017-11-08 08:32:47 +08:00
|
|
|
|
|
|
|
string(REGEX MATCH "VERSION_MAJOR = ([0-9]*)" _ ${ver})
|
|
|
|
set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
|
|
|
|
string(REGEX MATCH "VERSION_MINOR = ([0-9]*)" _ ${ver})
|
|
|
|
set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_1})
|
|
|
|
|
|
|
|
string(REGEX MATCH "PATCHLEVEL = ([0-9]*)" _ ${ver})
|
|
|
|
set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_1})
|
|
|
|
|
|
|
|
string(REGEX MATCH "VERSION_TWEAK = ([0-9]*)" _ ${ver})
|
|
|
|
set(PROJECT_VERSION_TWEAK ${CMAKE_MATCH_1})
|
|
|
|
|
2017-11-20 11:42:19 +08:00
|
|
|
string(REGEX MATCH "EXTRAVERSION = ([a-z0-9]*)" _ ${ver})
|
2017-11-08 08:32:47 +08:00
|
|
|
set(PROJECT_VERSION_EXTRA ${CMAKE_MATCH_1})
|
|
|
|
|
2018-09-28 19:22:17 +08:00
|
|
|
# Temporary convenience variable
|
|
|
|
set(PROJECT_VERSION_WITHOUT_TWEAK ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
2017-11-08 08:32:47 +08:00
|
|
|
|
2017-10-27 21:43:34 +08:00
|
|
|
if(PROJECT_VERSION_TWEAK)
|
2018-09-28 19:22:17 +08:00
|
|
|
set(PROJECT_VERSION ${PROJECT_VERSION_WITHOUT_TWEAK}.${PROJECT_VERSION_TWEAK})
|
|
|
|
else()
|
|
|
|
set(PROJECT_VERSION ${PROJECT_VERSION_WITHOUT_TWEAK})
|
2017-10-27 21:43:34 +08:00
|
|
|
endif()
|
|
|
|
|
2018-09-28 19:22:17 +08:00
|
|
|
message("Zephyr version: ${PROJECT_VERSION}")
|
|
|
|
|
2017-10-27 21:43:34 +08:00
|
|
|
set(MAJOR ${PROJECT_VERSION_MAJOR}) # Temporary convenience variable
|
2017-11-08 08:32:47 +08:00
|
|
|
set(MINOR ${PROJECT_VERSION_MINOR}) # Temporary convenience variable
|
|
|
|
set(PATCH ${PROJECT_VERSION_PATCH}) # Temporary convenience variable
|
|
|
|
|
2018-09-28 19:22:17 +08:00
|
|
|
math(EXPR KERNEL_VERSION_NUMBER_INT "(${MAJOR} << 16) + (${MINOR} << 8) + (${PATCH})")
|
|
|
|
math(EXPR KERNELVERSION_INT "(${MAJOR} << 24) + (${MINOR} << 16) + (${PATCH} << 8) + (${PROJECT_VERSION_TWEAK})")
|
2017-10-27 21:43:34 +08:00
|
|
|
|
2017-11-08 08:32:47 +08:00
|
|
|
to_hex(${KERNEL_VERSION_NUMBER_INT} KERNEL_VERSION_NUMBER)
|
2018-09-28 19:22:17 +08:00
|
|
|
to_hex(${KERNELVERSION_INT} KERNELVERSION)
|
2017-10-27 21:43:34 +08:00
|
|
|
|
|
|
|
set(KERNEL_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
|
|
|
set(KERNEL_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
|
|
|
set(KERNEL_PATCHLEVEL ${PROJECT_VERSION_PATCH})
|
2018-09-28 19:22:17 +08:00
|
|
|
|
2018-01-07 09:48:57 +08:00
|
|
|
if(PROJECT_VERSION_EXTRA)
|
2018-09-28 19:22:17 +08:00
|
|
|
set(KERNEL_VERSION_STRING "\"${PROJECT_VERSION_WITHOUT_TWEAK}-${PROJECT_VERSION_EXTRA}\"")
|
2018-01-07 09:48:57 +08:00
|
|
|
else()
|
2018-09-28 19:22:17 +08:00
|
|
|
set(KERNEL_VERSION_STRING "\"${PROJECT_VERSION_WITHOUT_TWEAK}\"")
|
2018-01-07 09:48:57 +08:00
|
|
|
endif()
|
2017-10-27 21:43:34 +08:00
|
|
|
|
2018-09-28 19:22:17 +08:00
|
|
|
set(ZEPHYR_VERSION_CODE ${KERNEL_VERSION_NUMBER_INT})
|
|
|
|
|
|
|
|
# Cleanup convenience variables
|
|
|
|
unset(MAJOR)
|
|
|
|
unset(MINOR)
|
|
|
|
unset(PATCH)
|
|
|
|
unset(PROJECT_VERSION_WITHOUT_TWEAK)
|