[gimp/soc-2010-cage] app: Include git commit hash in verbose version output
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage] app: Include git commit hash in verbose version output
- Date: Wed, 30 Jun 2010 22:11:39 +0000 (UTC)
commit f92b8e5f6f7eccaf720e0b3474ec786d5d19903c
Author: Martin Nordholts <martinn src gnome org>
Date: Sat Jan 30 08:10:41 2010 +0100
app: Include git commit hash in verbose version output
Note:
* Passes make distcheck
* The git commit hash is shipped with tarballs
* Build handles if git-version.h is removed from a tarball
app/.gitignore | 9 +++++----
app/Makefile.am | 26 +++++++++++++++++++++++++-
app/version.c | 4 ++++
3 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/app/.gitignore b/app/.gitignore
index 41eacc5..e573136 100644
--- a/app/.gitignore
+++ b/app/.gitignore
@@ -1,9 +1,10 @@
-/Makefile
-/Makefile.in
-/makefile.mingw
/.deps
/.libs
+/Makefile
+/Makefile.in
/gimp-2.*
/gimp-console-2.*
-/libapp.a
/gimp.rc
+/git-version.h
+/libapp.a
+/makefile.mingw
diff --git a/app/Makefile.am b/app/Makefile.am
index dd5ef21..1431c00 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -70,7 +70,12 @@ libapp_sources = \
gimp-log.h \
gimp-intl.h
-libapp_a_SOURCES = $(libapp_sources)
+libapp_generated_sources = \
+ git-version.h
+
+$(srcdir)/version.c: git-version.h
+
+libapp_a_SOURCES = $(libapp_sources) $(libapp_generated_sources)
gimp_2_7_SOURCES = $(libapp_sources) main.c
@@ -264,3 +269,22 @@ gimp-console.rc.o: gimp.rc
$(WINDRES) --define ORIGINALFILENAME_STR="gimp-console-2.7$(EXEEXT)" \
--define INTERNALNAME_STR="gimp-console-2.7" \
gimp.rc gimp-console.rc.o
+
+# If git is available, always check if git-version.h should be
+# updated. If git is not avaialbe, don't do anything if git-version.h
+# already exists because then we are probably working with a tarball
+# in which case the git-version.h we ship is correct.
+git-version.h: update-git-version-header
+ @if test -d "$(top_srcdir)/.git"; then \
+ echo "#define GIMP_GIT_VERSION \"`git log HEAD^..HEAD --pretty=format:%H`\"" > "$ tmp"; \
+ elif test ! -f "$@"; then \
+ echo "#define GIMP_GIT_VERSION \"Unknown, shouldn't happen\"" > "$ tmp"; \
+ fi
+ @if ( test -f "$@" && cmp "$ tmp" "$@" > /dev/null); then \
+ rm -f "$ tmp"; \
+ elif test -f "$ tmp"; then \
+ mv "$ tmp" "$@"; \
+ echo " git HEAD changed: git-version.h regenerated"; \
+ fi
+
+.PHONY: update-git-version-header
diff --git a/app/version.c b/app/version.c
index 6546c71..0766603 100644
--- a/app/version.c
+++ b/app/version.c
@@ -34,6 +34,7 @@
#include "about.h"
#include "version.h"
+#include "git-version.h"
#include "gimp-intl.h"
@@ -128,6 +129,9 @@ gimp_version_show (gboolean be_verbose)
if (be_verbose)
{
+ g_print (_("git commit %s"), GIMP_GIT_VERSION);
+ g_print ("\n");
+
g_print ("\n");
gimp_show_library_versions ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]