diff options
author | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-06-12 08:48:21 -0400 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-06-12 10:45:45 -0400 |
commit | d74f3845ddebf0b93f86c832385431a5e7dfa14c (patch) | |
tree | 840bba6716dbfeedfa216fcab5528398fd8daf70 | |
parent | 355108bf9429b4f1ccc801f9b34d98abf8af63b5 (diff) | |
download | trace-cmd-d74f3845ddebf0b93f86c832385431a5e7dfa14c.tar.gz |
trace-cmd: Make the version defines part of tc-version.h
Move the version string creations as part of the tc-version.h file, and have
trace-record.c include and use that. The VERSION_STRING is already defined
and obsoletes TRACECMD_VERSION. For consistency, use VERSION_GIT to define
the git sha1. Also, add logic to detect if the source file is a git repo,
and use "not-a-git-repo" as the sha1 if it is not found. Add a "+" to the
end of the git sha1 if the repo has modifications in it.
Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | scripts/utils.mk | 9 | ||||
-rw-r--r-- | tracecmd/trace-record.c | 3 |
3 files changed, 11 insertions, 5 deletions
@@ -238,10 +238,6 @@ endif override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR) override CFLAGS += $(udis86-flags) $(blk-flags) -# Append version define -override CFLAGS += -DTRACECMD_VERSION=\"$(TRACECMD_VERSION)\" -override CFLAGS += -DTRACECMD_VERSION_GIT=\"$(shell git log -1 --pretty=format:"%H")\" - CMD_TARGETS = trace-cmd $(BUILD_PYTHON) ### diff --git a/scripts/utils.mk b/scripts/utils.mk index f5feeca0..260023a1 100644 --- a/scripts/utils.mk +++ b/scripts/utils.mk @@ -79,6 +79,15 @@ define make_version.h echo '#define EXTRAVERSION ' $(EXTRAVERSION); \ echo '#define VERSION_STRING "'$(VERSION).$(PATCHLEVEL).$(EXTRAVERSION)'"'; \ echo '#define FILE_VERSION '$(FILE_VERSION); \ + if [ -d $(src)/.git ]; then \ + d=`git diff`; \ + x=""; \ + if [ ! -z "$$d" ]; then x="+"; fi; \ + echo '#define VERSION_GIT "'$(shell \ + git log -1 --pretty=format:"%H" 2>/dev/null)$$x'"'; \ + else \ + echo '#define VERSION_GIT "not-a-git-repo"'; \ + fi \ ) > $1 endef diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 8aa83455..ee35ada1 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -34,6 +34,7 @@ #include <limits.h> #include <libgen.h> +#include "version.h" #include "trace-local.h" #include "trace-msg.h" @@ -3149,7 +3150,7 @@ static void add_version(struct tracecmd_output *handle) char *str; int len; - len = asprintf(&str, "%s %s", TRACECMD_VERSION, TRACECMD_VERSION_GIT); + len = asprintf(&str, "%s %s", VERSION_STRING, VERSION_GIT); if (len < 0) return; |