new: add various PATCH_VERSION processing options

master
KoynovStas 2 years ago
parent 35c4463357
commit 8c600cdcef

@ -1,7 +1,12 @@
DAEMON_NAME = wsdd
DAEMON_MAJOR_VERSION = 2
DAEMON_MINOR_VERSION = 1
DAEMON_PATCH_VERSION = 0
DAEMON_PATCH_VERSION = patch
#variants: hash - set PATCH_VERSION == commit hash (12 digits)
#variants: *hash - set PATCH_VERSION == * + commit hash (12 digits),
# * will be set if files in repo are changed
#variants: patch - set PATCH_VERSION == number of commits(patches) between head and last tag
#variants: xxx - set PATCH_VERSION == xxx (your variant)
DAEMON_PID_FILE_NAME = $(DAEMON_NAME).pid
DAEMON_LOG_FILE_NAME = $(DAEMON_NAME).log
DAEMON_NO_CHDIR = 1
@ -9,6 +14,40 @@ DAEMON_NO_CLOSE_STDIO = 0
COMMIT_HASH = $(shell git rev-parse --short=12 HEAD 2>/dev/null)
ifeq ($(strip $(shell git status --short --untracked-files=no 2>/dev/null)),)
COMMIT_ISDIRTY = 0
else
COMMIT_ISDIRTY = 1
endif
# process PATCH_VERSION
ifeq ($(strip $(DAEMON_PATCH_VERSION)), *hash)
ifeq ($(strip $(COMMIT_ISDIRTY)), 0)
DAEMON_PATCH_VERSION = $(COMMIT_HASH)
else
DAEMON_PATCH_VERSION = *$(COMMIT_HASH)
endif
endif
ifeq ($(strip $(DAEMON_PATCH_VERSION)), hash)
DAEMON_PATCH_VERSION = $(COMMIT_HASH)
endif
ifeq ($(strip $(DAEMON_PATCH_VERSION)), patch)
LAST_TAG = $(shell git describe --tags --first-parent --abbrev=0 2>/dev/null)
DAEMON_PATCH_VERSION = $(shell git rev-list HEAD...$(LAST_TAG) --count 2>/dev/null)
endif
ifeq ($(strip $(DAEMON_PATCH_VERSION)),)
DAEMON_PATCH_VERSION = 0
endif
GSOAP_VERSION = 2.8.66
GSOAP_INSTALL_DIR = ./gsoap-2.8
@ -34,6 +73,8 @@ CFLAGS += -DDAEMON_PID_FILE_NAME='"$(DAEMON_PID_FILE_NAME)"'
CFLAGS += -DDAEMON_LOG_FILE_NAME='"$(DAEMON_LOG_FILE_NAME)"'
CFLAGS += -DDAEMON_NO_CHDIR=$(DAEMON_NO_CHDIR)
CFLAGS += -DDAEMON_NO_CLOSE_STDIO=$(DAEMON_NO_CLOSE_STDIO)
CFLAGS += -DCOMMIT_ISDIRTY=$(COMMIT_ISDIRTY)
CFLAGS += -DCOMMIT_HASH='"$(COMMIT_HASH)"'
CFLAGS += -I$(COMMON_DIR)
CFLAGS += -I$(GENERATED_DIR)

@ -58,16 +58,20 @@
static const char *help_str =
" =============== Help ===============\n"
" Daemon name: " DAEMON_NAME "\n"
" Daemon ver: " DAEMON_VERSION_STR "\n"
" Daemon name: " DAEMON_NAME "\n"
" Daemon ver: " DAEMON_VERSION_STR "\n\n"
#ifdef DEBUG
" Build mode: debug\n"
#else
" Build mode: release\n"
#endif
" Build date: " __DATE__ "\n"
" Build time: " __TIME__ "\n\n"
" Build time: " __TIME__ "\n"
#if COMMIT_ISDIRTY == 0
" Build hash: " COMMIT_HASH "\n\n"
#else
" Build hash: *" COMMIT_HASH "\n\n"
#endif
"Options: description:\n\n"
" --no_chdir Don't change the directory to '/'\n"
" --no_fork Don't do fork\n"

Loading…
Cancel
Save