summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author杨威 <[email protected]>2019-02-24 15:46:10 +0800
committer杨威 <[email protected]>2019-02-24 15:46:10 +0800
commit4a0f6fae912a9e3ebbab5c8558b5548cc2ef1447 (patch)
tree44ddf29223d396d367b9b7dd9f8888fde8fd3606
parent5001fdee287b2e559131aae5ed9cf045fd5d6c61 (diff)
parent94cacc5874271de76a0bebae6f81ab520c83c765 (diff)
Merge branch 'Feature-auto-version' into 'master'
新增根据git记录自动生成GIT_VERSION变量的代码 See merge request MESA_framework/MESA_handle_logger!3
-rw-r--r--src/MESA_handle_logger.c24
-rw-r--r--src/Makefile8
2 files changed, 31 insertions, 1 deletions
diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c
index 21e18e2..c9cc54b 100644
--- a/src/MESA_handle_logger.c
+++ b/src/MESA_handle_logger.c
@@ -17,7 +17,29 @@ typedef struct log_handle_t
#define LOGMSG_MAX_LEN 4096
-const int HANDLE_LOGGER_VERSION_20190218 = 1;
+//const int HANDLE_LOGGER_VERSION_20190218 = 1;
+
+#define GIT_VERSION_CATTER(v) __attribute__((__used__)) const char * GIT_VERSION_##v = NULL
+#define GIT_VERSION_EXPEND(v) GIT_VERSION_CATTER(v)
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* VERSION TAG */
+#ifdef GIT_VERSION
+GIT_VERSION_EXPEND(GIT_VERSION);
+#else
+static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
+#endif
+#undef GIT_VERSION_CATTER
+#undef GIT_VERSION_EXPEND
+
+#ifdef __cplusplus
+}
+#endif
+
static unsigned char weekday_str[7][4] =
{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
diff --git a/src/Makefile b/src/Makefile
index 16fbe8c..c2d8fb1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,6 +3,14 @@ VPATH=../inc
CFLAGS= -g3 -Wall -fPIC -O -Werror
CFLAGS+=-I../inc/
+GIT_BRANCH=$(shell git symbolic-ref --short -q HEAD)
+GIT_SHA1=$(shell git rev-parse HEAD)
+MAKE_TIME=$(shell date "+%Y_%m_%d_%H")
+VERSION_FLAGS += -DGIT_VERSION=1_0_0_$(GIT_BRANCH)_$(GIT_SHA1)_$(MAKE_TIME)
+
+CFLAGS += ${VERSION_FLAGS}
+CXXFLAGS += ${VERSION_FLAGS}
+
ifdef ASAN
CFLAGS_+= -fsanitize=address -fno-omit-frame-pointer
LIB+=-lasan