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>
This commit is contained in:
parent
643084de0b
commit
91709778a4
6 changed files with 61 additions and 42 deletions
|
@ -15,6 +15,7 @@ with the parser to decode binary log messages.
|
|||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import struct
|
||||
import sys
|
||||
|
||||
|
@ -47,6 +48,8 @@ def parse_args():
|
|||
argparser.add_argument("elffile", help="Zephyr ELF binary")
|
||||
argparser.add_argument("dbfile", help="Dictionary Logging Database file")
|
||||
argparser.add_argument("--build", help="Build ID")
|
||||
argparser.add_argument("--build-header",
|
||||
help="Header file containing BUILD_VERSION define")
|
||||
argparser.add_argument("--debug", action="store_true",
|
||||
help="Print extra debugging information")
|
||||
argparser.add_argument("-v", "--verbose", action="store_true",
|
||||
|
@ -264,6 +267,14 @@ def main():
|
|||
|
||||
database = LogDatabase()
|
||||
|
||||
if args.build_header:
|
||||
with open(args.build_header) as f:
|
||||
for l in f:
|
||||
match = re.match(r'\s*#define\s+BUILD_VERSION\s+(.*)', l)
|
||||
if match:
|
||||
database.set_build_id(match.group(1))
|
||||
break
|
||||
|
||||
if args.build:
|
||||
database.set_build_id(args.build)
|
||||
logger.info("Build ID: %s", args.build)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue