util/genbuild_h/genbuild_h.sh: generate Dasharo version

Change-Id: I656ab30e2d628719a9a68ef48967a1d327e96e05
Upstream-Status: Inappropriate [Dasharo downstream]
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
This commit is contained in:
Michał Żygowski
2021-12-08 13:33:31 +01:00
committed by Sergii Dmytruk
parent a1532790b9
commit d839eb3aa3
3 changed files with 35 additions and 1 deletions

View File

@@ -477,9 +477,20 @@ ifeq ($(CONFIG_COMPRESS_PRERAM_STAGES),y)
CBFS_PRERAM_COMPRESS_FLAG:=LZ4
endif
strip_version = $(strip $(subst v,,$(subst ., ,$(1))))
ifneq ($(CONFIG_LOCALVERSION),"")
COREBOOT_EXTRA_VERSION := -$(call strip_quotes,$(CONFIG_LOCALVERSION))
DASHARO_VERSION := $(call strip_quotes,$(CONFIG_LOCALVERSION))
DASHARO_MAJOR_VERSION := $(word 1,$(call strip_version,$(DASHARO_VERSION)))
DASHARO_MINOR_VERSION := $(word 2,$(call strip_version,$(DASHARO_VERSION)))
DASHARO_PATCH_VERSION := $(word 3,$(call strip_version,$(DASHARO_VERSION)))
COREBOOT_EXPORTS += COREBOOT_EXTRA_VERSION
COREBOOT_EXPORTS += DASHARO_VERSION
COREBOOT_EXPORTS += DASHARO_MAJOR_VERSION
COREBOOT_EXPORTS += DASHARO_MINOR_VERSION
COREBOOT_EXPORTS += DASHARO_PATCH_VERSION
endif
CPPFLAGS_common := -Isrc
@@ -648,7 +659,9 @@ build_h := $(obj)/build.h
# when we call it through the `$(shell)` function. This is fragile
# but as variables newly added to `genbuild_h.sh` would just not
# work, we'd notice that instantly at least.
build_h_exports := BUILD_TIMELESS KERNELVERSION COREBOOT_EXTRA_VERSION
build_h_exports := BUILD_TIMELESS KERNELVERSION COREBOOT_EXTRA_VERSION \
DASHARO_VERSION DASHARO_MAJOR_VERSION DASHARO_MINOR_VERSION \
DASHARO_PATCH_VERSION
# Report new `build.ht` as dependency if `build.h` differs.
build_h_check := \

View File

@@ -18,6 +18,22 @@
#define COREBOOT_EXTRA_VERSION ""
#endif
#ifndef DASHARO_VERSION
#define DASHARO_VERSION "*INVALID*"
#endif
#ifndef DASHARO_MAJOR_VERSION
#define DASHARO_MAJOR_VERSION 0
#endif
#ifndef DASHARO_MINOR_VERSION
#define DASHARO_MINOR_VERSION 0
#endif
#ifndef DASHARO_PATCH_VERSION
#define DASHARO_PATCH_VERSION 0
#endif
const char coreboot_version[] = COREBOOT_VERSION;
const char coreboot_extra_version[] = COREBOOT_EXTRA_VERSION;
const char coreboot_build[] = COREBOOT_BUILD;

View File

@@ -79,6 +79,11 @@ printf "/* timesource: %s */\n" "${TIMESOURCE}"
printf "#define COREBOOT_VERSION_TIMESTAMP %s\n" "${DATE}"
printf "#define COREBOOT_ORIGIN_GIT_REVISION \"%s\"\n" "${GITREV}"
printf "#define DASHARO_VERSION \"%s\"\n" "$DASHARO_VERSION"
printf "#define DASHARO_MAJOR_VERSION %d\\n" "$DASHARO_MAJOR_VERSION"
printf "#define DASHARO_MINOR_VERSION %d\\n" "$DASHARO_MINOR_VERSION"
printf "#define DASHARO_PATCH_VERSION %d\\n" "$DASHARO_PATCH_VERSION"
printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "${COREBOOT_EXTRA_VERSION}"
printf "#define COREBOOT_MAJOR_VERSION %s\n" "${MAJOR_VER:-0}"
printf "#define COREBOOT_MINOR_VERSION %s\n" "${MINOR_VER:-0}"