* [PATCH] trace-cmd: Make the version defines part of tc-version.h
@ 2019-06-12 12:51 Steven Rostedt
2019-06-12 14:28 ` Slavomir Kaslev
0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2019-06-12 12:51 UTC (permalink / raw)
To: Slavomir Kaslev; +Cc: Linux Trace Devel
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
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.
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
Makefile | 4 ----
scripts/utils.mk | 9 +++++++++
tracecmd/trace-record.c | 3 ++-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 2062d976..6df1f07b 100644
--- a/Makefile
+++ b/Makefile
@@ -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;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] trace-cmd: Make the version defines part of tc-version.h
2019-06-12 12:51 [PATCH] trace-cmd: Make the version defines part of tc-version.h Steven Rostedt
@ 2019-06-12 14:28 ` Slavomir Kaslev
0 siblings, 0 replies; 2+ messages in thread
From: Slavomir Kaslev @ 2019-06-12 14:28 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel
On Wed, 2019-06-12 at 08:51 -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> 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.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Thanks, Steven. I completely missed tc-version.h header's existence in
the initial patch.
Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com>
Cheers,
--Slavi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-12 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12 12:51 [PATCH] trace-cmd: Make the version defines part of tc-version.h Steven Rostedt
2019-06-12 14:28 ` Slavomir Kaslev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.