[PATCH v2] Print git describe output into the log file.

Peter Hutterer peter.hutterer at who-t.net
Thu Apr 15 23:04:21 PDT 2010


Run git describe on build and push the output into xorg-git-version.h. Then
print that out in the logfile.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to first version:
- target is PHONY to always regenerate
- script reshuffled, no == anymore
- don't print anything if no git version could be found.

I think those were all suggested changes for the first round, right?
Given how simple the script is, I also wonder if we should just add the commands
to the makefile target directly instead of adding a script.

Cheers,
  Peter

 GIT-GENERATE-VERSION         |   26 ++++++++++++++++++++++++++
 Makefile.am                  |    2 +-
 hw/xfree86/common/xf86Init.c |    5 +++++
 include/Makefile.am          |    9 +++++++++
 4 files changed, 41 insertions(+), 1 deletions(-)
 create mode 100755 GIT-GENERATE-VERSION

diff --git a/GIT-GENERATE-VERSION b/GIT-GENERATE-VERSION
new file mode 100755
index 0000000..84896bd
--- /dev/null
+++ b/GIT-GENERATE-VERSION
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Get the git version if possible and store it in $GITFILE if it differs to
+# the one contained already.
+
+GITFILE="xorg-git-version.h"
+VER=""
+OUTSTR=""
+
+if which git > /dev/null; then
+    VER=`git describe HEAD 2>/dev/null`
+fi
+
+if test -z "$VER"; then
+    OUTSTR="#undef XORG_GIT_VERSION"
+else
+    OUTSTR="#define XORG_GIT_VERSION \"$VER\""
+fi
+
+if test -e "$GITFILE"; then
+    FILE_VER=`cat $GITFILE`
+    if test "$FILE_VER" = "$VER"; then
+        exit 0
+    fi
+fi
+
+echo "$OUTSTR" > $GITFILE
diff --git a/Makefile.am b/Makefile.am
index 8b7a2c8..cce5f23 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,7 +49,7 @@ pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = xorg-server.pc
 endif
 
-EXTRA_DIST = xorg-server.pc.in xorg-server.m4 autogen.sh
+EXTRA_DIST = xorg-server.pc.in xorg-server.m4 autogen.sh GIT-GENERATE-VERSION
 
 DISTCHECK_CONFIGURE_FLAGS=\
 	--with-xkb-path=$(XKB_BASE_DIRECTORY) \
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 71ac9a9..d37a292 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -34,6 +34,8 @@
 #include <xorg-config.h>
 #endif
 
+#include <xorg-git-version.h>
+
 #include <stdlib.h>
 #include <errno.h>
 
@@ -242,6 +244,9 @@ xf86PrintBanner(void)
   xf86ErrorFVerb(0, "\tBefore reporting problems, check "
                  ""__VENDORDWEBSUPPORT__"\n"
                  "\tto make sure that you have the latest version.\n");
+#ifdef XORG_GIT_VERSION
+  xf86ErrorFVerb(0, "git version: " XORG_GIT_VERSION "\n");
+#endif
 }
 
 static void
diff --git a/include/Makefile.am b/include/Makefile.am
index eddc86c..d0f4a53 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -62,6 +62,13 @@ sdk_HEADERS =		\
 nodist_sdk_HEADERS = xorg-server.h
 endif
 
+BUILT_SOURCES = xorg-git-version.h
+
+xorg-git-version.h:
+	sh $(top_srcdir)/GIT-GENERATE-VERSION
+
+.PHONY: xorg-git-version.h
+
 AM_CFLAGS = $(DIX_CFLAGS)
 
 EXTRA_DIST = 	\
@@ -69,3 +76,5 @@ EXTRA_DIST = 	\
 	eventconvert.h eventstr.h \
 	protocol-versions.h \
 	xsha1.h
+
+DISTCLEANFILES = xorg-git-version.h
-- 
1.6.6.1



More information about the xorg-devel mailing list