From 963d4d62f1bc6da5a079ab7c67317c2530d2af95 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 25 Sep 2023 23:32:01 +0200 Subject: [PATCH] Deduce APP_FW_VER from git tag --- firmware/Makefile.defs | 5 ++++- firmware/application/Makefile | 7 +++++++ firmware/application/src/app_config.h | 7 +++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/firmware/Makefile.defs b/firmware/Makefile.defs index d345c8f..7f7314d 100644 --- a/firmware/Makefile.defs +++ b/firmware/Makefile.defs @@ -26,7 +26,10 @@ CHAMELEON_LITE := lite CURRENT_DEVICE_TYPE ?= ${CHAMELEON_ULTRA} # Versioning information -GIT_VERSION := "$(shell git describe --abbrev=7 --dirty --always --tags)" +GIT_VERSION := $(shell git describe --abbrev=7 --dirty --always --tags) +APP_FW_SEMVER := $(subst v,,$(shell git describe --tags --abbrev=0 --match "v*.*")) +APP_FW_VER_MAJOR := $(word 1,$(subst ., ,$(APP_FW_SEMVER))) +APP_FW_VER_MINOR := $(word 2,$(subst ., ,$(APP_FW_SEMVER))) # Enable NRF_LOG on SWO pin as UART TX NRF_LOG_UART_ON_SWO_ENABLED := 0 diff --git a/firmware/application/Makefile b/firmware/application/Makefile index 9e02889..632b3e2 100644 --- a/firmware/application/Makefile +++ b/firmware/application/Makefile @@ -401,6 +401,13 @@ CFLAGS += -fno-builtin -fshort-enums # Versioning flags CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" +ifndef APP_FW_VER_MAJOR +$(error APP_FW_VER_MAJOR is not defined, please define it) +endif +ifndef APP_FW_VER_MINOR +$(error APP_FW_VER_MINOR is not defined, please define it) +endif +CFLAGS += -DAPP_FW_VER_MAJOR=$(APP_FW_VER_MAJOR) -DAPP_FW_VER_MINOR=$(APP_FW_VER_MINOR) # C++ flags common to all targets CXXFLAGS += $(OPT) diff --git a/firmware/application/src/app_config.h b/firmware/application/src/app_config.h index 0d981ad..5dc7023 100644 --- a/firmware/application/src/app_config.h +++ b/firmware/application/src/app_config.h @@ -2,8 +2,11 @@ // version code, 1byte, max = 0 -> 255 -#define APP_FW_VER_MAJOR 2 -#define APP_FW_VER_MINOR 0 +//#define APP_FW_VER_MAJOR 2 +//#define APP_FW_VER_MINOR 0 +#if !(defined APP_FW_VER_MAJOR && defined APP_FW_VER_MINOR) + #error You need to define APP_FW_VER_MAJOR and APP_FW_VER_MINOR +#endif // Merge major and minor version code to U16 value. #define FW_VER_NUM VER_CODE_TO_NUM(APP_FW_VER_MAJOR, APP_FW_VER_MINOR)