zephyr/version.h.in
Torsten Rasmussen 91709778a4 cmake: version.h generation performed at build time
Fixes: #39503
Fixes: #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 <Torsten.Rasmussen@nordicsemi.no>
2022-02-08 07:50:24 -05:00

21 lines
748 B
C

#ifndef _KERNEL_VERSION_H_
#define _KERNEL_VERSION_H_
/* KERNEL and ZEPHYR_VERSION @templates@ values come from cmake/version.cmake
* BUILD_VERSION @template@ will be 'git describe', alternatively user defined BUILD_VERSION.
*/
#cmakedefine ZEPHYR_VERSION_CODE @ZEPHYR_VERSION_CODE@
#define ZEPHYR_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#define KERNELVERSION @KERNELVERSION@
#define KERNEL_VERSION_NUMBER @KERNEL_VERSION_NUMBER@
#define KERNEL_VERSION_MAJOR @KERNEL_VERSION_MAJOR@
#define KERNEL_VERSION_MINOR @KERNEL_VERSION_MINOR@
#define KERNEL_PATCHLEVEL @KERNEL_PATCHLEVEL@
#define KERNEL_VERSION_STRING @KERNEL_VERSION_STRING@
#define BUILD_VERSION @BUILD_VERSION@
#endif /* _KERNEL_VERSION_H_ */