Skip to content

Commit

Permalink
Deduce APP_FW_VER from git tag
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Sep 25, 2023
1 parent 2b4e8b2 commit 963d4d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion firmware/Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions firmware/application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions firmware/application/src/app_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 963d4d6

Please sign in to comment.