@@ -84,32 +84,35 @@ CFLAGS += $(CARCH_FLAG) $(CPU_FLAG) $(OPT_FLAGS) $(BUILDOPTS) $(shell pkg
8484APPNAME = $(shell sed -n 's/^[ \t]* \#define[ \t]* APP_NAME[ \t]* "\([^"]* \) ".*$$/\1/p' app.h)
8585BINNAME = $(shell sed -n 's/^[ \t]* \#define[ \t]* BIN_NAME[ \t]* "\([^"]* \) ".*$$/\1/p' app.h)
8686
87- # Retrieve version
87+ # Retrieve version from git
8888# This is something like:
89- # 1.10.5-3-g6ab5527-dirty
89+ # 1.10.5-3-g6ab5527-dirty-ft-cool
9090# Where:
91- # 1.10.5 == tag
92- # -3 == 3 commits ahead of tag
93- # -g6ab5527 == commit starting with g6ab5527
94- # -dirty == some files are not in the repository
95- # APPVER="$(shell grep _APP_VERSION app.h|head -1|cut -d'"' -f2)"
91+ # 1.10.5 == tag / major version
92+ # -3 == 3 commits ahead of tag
93+ # -g6ab5527 == 'g'it commit starting with 6ab5527
94+ # -dirty == some files here changed or not in repository
95+ # -ft-cool == ft-cool branch
96+ MAJVER = $(shell bash -c \
97+ '\
98+ echo -n "$$(git describe --always --tags --match="*" --dirty ) " \
99+ ')
100+
96101APPBRANCH = $(shell bash -c \
97102 '\
98- ( \
99- n="$$(git name-rev --always --name-only --no-undefined HEAD ) "; \
100- [ "$${n}" != "master" ] && echo -n "$${n}" || true \
101- ) \
103+ git name-rev --always --name-only --no-undefined HEAD|sed "s@feature/@ft-@;s@hotfix/\(.* \) @\1.HF@;s@release/\(.*\)@\1.PRE@"\
102104 ')
105+ # APPVER="$(shell grep _APP_VERSION app.h|head -1|cut -d'"' -f2)"
103106APPVER = $(shell bash -c \
104- '\
105- git describe --tags --match="* " --dirty &>/dev/null \
106- && git describe --always --tags --match="* " --dirty \
107- || (echo -n "$(APPBRANCH ) -"; git describe --always --tags --dirty) \
108- ')
107+ '\
108+ echo -n "$(MAJVER ) "; \
109+ [ ! -z "$(APPBRANCH ) " ] && [ "$(APPBRANCH ) " != "master" ] && [ "$(APPBRANCH ) " != "$(MAJVER ) " ] && echo -n "-$(APPBRANCH ) " \
110+ ')
109111
110112BUILD_DATE = $(shell date +'% Y-% m-% d % H:% M:% S% z')
111113BUILD_MONTH = $(shell date +'% B')
112114BUILD_YEAR = $(shell date +'% Y')
115+ BUILD_COMMIT = $(shell git rev-parse --verify 'HEAD^{commit}')
113116
114117ARCHIVE_NAME = $(BINNAME ) -$(APPVER )
115118ARCHIVE_FILE = $(ARCHIVE_NAME ) .$(ARCHIVE_EXT )
@@ -151,6 +154,7 @@ git.h: gitup git.h.TEMPLATE
151154 @sed -i ' s#//SOURCE//#// WARNING // Auto-generated file, DO NOT MODIFY //#' git.h
152155 @sed -i ' s#\%\%APP_VERSION\%\%#$(APPVER)#' git.h
153156 @sed -i ' s#\%\%BUILD_DATE\%\%#$(BUILD_DATE)#' git.h
157+ @sed -i ' s#\%\%BUILD_COMMIT\%\%#$(BUILD_COMMIT)#' git.h
154158
155159log.h : log.h.TEMPLATE
156160 @# Generating log header
0 commit comments