From patchwork Wed Jun 12 12:51:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 10989955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F08AB18A6 for ; Wed, 12 Jun 2019 12:51:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD128289C6 for ; Wed, 12 Jun 2019 12:51:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D15F228A2E; Wed, 12 Jun 2019 12:51:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F1A5289F0 for ; Wed, 12 Jun 2019 12:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728774AbfFLMvj (ORCPT ); Wed, 12 Jun 2019 08:51:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:42088 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726778AbfFLMvi (ORCPT ); Wed, 12 Jun 2019 08:51:38 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 40E5A20684; Wed, 12 Jun 2019 12:51:38 +0000 (UTC) Date: Wed, 12 Jun 2019 08:51:36 -0400 From: Steven Rostedt To: Slavomir Kaslev Cc: Linux Trace Devel Subject: [PATCH] trace-cmd: Make the version defines part of tc-version.h Message-ID: <20190612085136.248a4a0e@gandalf.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Steven Rostedt (VMware)" 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) Reviewed-by: Slavomir Kaslev --- 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 #include +#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;