[med-svn] [cnrun] 02/25: print_version() using git describe --tags

andrei zavada hmmr-guest at moszumanska.debian.org
Thu Nov 6 22:08:29 UTC 2014


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch WIP
in repository cnrun.

commit c3b3ada718c203c9730c72b097489b07c3a98e4c
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Sat Mar 22 21:55:50 2014 +0200

    print_version() using git describe --tags
---
 upstream/make_vesrion         | 17 +++++++++++++++++
 upstream/src/Makefile.am      | 11 +++++++++--
 upstream/src/print_version.cc | 26 ++++++++++++++++++++++++++
 upstream/src/runner-main.cc   |  7 +++++--
 4 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/upstream/make_vesrion b/upstream/make_vesrion
new file mode 100755
index 0000000..f4fb669
--- /dev/null
+++ b/upstream/make_vesrion
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+V=$(git describe --tags)
+if [ $? = 0 ]; then
+   echo $V | awk -F"-" '{ print $1"."$2; }'
+   exit 0
+fi
+
+# if git is not installed or we are building from a tarball smuggled
+# from a git repo, fall back to ./VERSION
+if test -r VERSION; then
+   V=$(<VERSION)
+   if test -n $V; then echo $V; exit 0; fi
+fi
+
+# whatever
+echo "0.0.0"
diff --git a/upstream/src/Makefile.am b/upstream/src/Makefile.am
index 9b52409..55fb135 100644
--- a/upstream/src/Makefile.am
+++ b/upstream/src/Makefile.am
@@ -3,14 +3,19 @@ if DO_TOOLS
 SUBDIRS += tools
 endif
 
-AM_CXXFLAGS = -Wall -std=c++0x -fno-rtti \
+git_describe_tags := `git describe --tags`
+
+
+AM_CXXFLAGS := -Wall -std=c++0x -fno-rtti \
 	-I$(top_srcdir)/src \
 	$(LIBCN_CFLAGS) \
-	-DBUILT_BY=\"@user@\"
+	-DBUILT_BY=\"@user@\" \
+	-DGIT_DESCRIBE_TAGS=\"$(git_describe_tags)\"
 
 bin_PROGRAMS = \
 	cnrun
 cnrun_SOURCES = \
+	print_version.cc \
 	runner-main.cc runner-interpreter.cc runner-interpreter-completions.cc runner.hh
 cnrun_LDADD = \
 	libcn/libcn.la \
@@ -19,6 +24,8 @@ cnrun_LDADD = \
 cnrun_LDFLAAGS = \
 	-shared
 
+print_version.o: FORCE
+FORCE:
 
 CLEANFILES = \
 	*/*.la lib*/*.hh.gch
diff --git a/upstream/src/print_version.cc b/upstream/src/print_version.cc
new file mode 100644
index 0000000..aea64cc
--- /dev/null
+++ b/upstream/src/print_version.cc
@@ -0,0 +1,26 @@
+/*
+ *       File name:  print_version.cc
+ *         Project:  cnrun
+ *          Author:  Andrei Zavada <johnhommer at gmail.com>
+ * Initial version:  2014-03-22
+ *
+ *         Purpose:  print version (separate file for every make to always touch it)
+ *
+ *         License:  GPL
+ */
+
+#include <cstdio>
+#include "config.h"
+
+void
+print_version( const char* this_program)
+{
+        printf(  "%s %s built " __DATE__ " " __TIME__ " by %s\n", this_program, GIT_DESCRIBE_TAGS, BUILT_BY);
+}
+
+// Local Variables:
+// Mode: c++
+// indent-tabs-mode: nil
+// tab-width: nil
+// c-basic-offset: 8
+// End:
diff --git a/upstream/src/runner-main.cc b/upstream/src/runner-main.cc
index fa16b61..4044521 100644
--- a/upstream/src/runner-main.cc
+++ b/upstream/src/runner-main.cc
@@ -56,9 +56,14 @@ void LOG( int vrb, const char* fmt, ...)
 }
 }
 
+
+void print_version( const char* appname);
+
 int
 main( int argc, char *argv[])
 {
+	print_version( "cnrun");
+
 	int retval = 0;
 
 	Log = new CLogFacility( nullptr, 0, Options.verbosely, 0, 0|STILTON_LOG_NOLOCK);
@@ -75,8 +80,6 @@ main( int argc, char *argv[])
 
 	Log->log_threshold = Options.verbosely;
 
-	printf( "CNRun ver. " VERSION " compiled " __DATE__ "  " __TIME__ "\n");
-
       // purely informational, requires no model
 	if ( Options.list_units ) {
 		cnmodel_dump_available_units();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/cnrun.git



More information about the debian-med-commit mailing list