Fix 1797745: show the correct SVN revision id in the about dialog
authorpabs <pabs@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Wed, 6 Feb 2008 09:11:32 +0000 (09:11 +0000)
committerpabs <pabs@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Wed, 6 Feb 2008 09:11:32 +0000 (09:11 +0000)
* Run a script each time we build to see if we have updated
* The script currently supports svn and git-svn
* The about dialog will only be rebuilt if you update
* No need to rebuild configure after updating

git-svn-id: http://svn.voria.com/code@1600 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/Makefile.am
synfig-studio/trunk/build_tools/Makefile.am [new file with mode: 0644]
synfig-studio/trunk/build_tools/autorevision.sh [new file with mode: 0644]
synfig-studio/trunk/configure.ac
synfig-studio/trunk/src/gtkmm/about.cpp

index 2c43d70..5d017f6 100644 (file)
@@ -2,7 +2,7 @@
 
 MAINTAINERCLEANFILES=COPYING INSTALL config/ltmain.sh doxygen.cfg config/config.guess config/config.sub config/ltmain.sh config/install-sh config/mkinstalldirs config/aclocal.m4 config/missing config/texinfo.tex config/depcomp aclocal.m4 config.h.in configure stamp-h.in Makefile.in config.log config.status .doc_stamp .DS_Store
 
-SUBDIRS=src images po
+SUBDIRS=build_tools src images po
 
 EXTRA_DIST=COPYING TODO m4/subs.m4 doxygen.cfg.in doxygen.cfg macosxbuild.sh win32build.sh win32inst.nsi.in config/package config/depcomp m4/cxx_macros.m4 m4/ETL.m4 ChangeLog.old synfigstudio.xml.in synfigstudio-thumbnailer.schemas.in
 
diff --git a/synfig-studio/trunk/build_tools/Makefile.am b/synfig-studio/trunk/build_tools/Makefile.am
new file mode 100644 (file)
index 0000000..23a1201
--- /dev/null
@@ -0,0 +1,8 @@
+dist_noinst_SCRIPTS=autorevision.sh
+
+all-local:
+       sh $(srcdir)/autorevision.sh "$(top_srcdir)" "$(top_builddir)"
+
+clean-local:
+       -rm -f $(top_builddir)/autorevision.h
+
diff --git a/synfig-studio/trunk/build_tools/autorevision.sh b/synfig-studio/trunk/build_tools/autorevision.sh
new file mode 100644 (file)
index 0000000..ec7ec8d
--- /dev/null
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+# Copyright 2008 Paul Wise
+#
+# This package is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This package is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+
+get_git_svn_id(){
+       export SCM=git-svn
+       export REVISION=`cd "$1"; git svn find-rev HEAD`
+       export COMPARE="$1/.git/svn"
+       if [ x = "x$REVISION" ] ; then
+               # The extra M at the end is for Modified
+               export REVISION=`cd "$1"; git svn find-rev \`git rev-list --max-count=1 --grep='git-svn-id: ' HEAD\``M
+       fi
+}
+
+get_svn_id(){
+       export SCM=svn
+       export REVISION=`cd "$1"; svnversion || svn info | sed -n 's/^Revision: \(.*\)/\1/p'`
+}
+
+
+HEADER="$2/autorevision.h"
+SCM=none
+
+
+if [ ! -f "$HEADER" ] ; then
+       touch -t 197001010101 "$HEADER"
+fi
+
+
+# Extract the revision from SVN/git/etc
+if [ -d "$1/.git/svn" ] ; then
+       get_git_svn_id "$1"
+elif [ -d "$1/../.git/svn" ] ; then
+       get_git_svn_id "$1/.."
+elif [ -d "$1/../../.git/svn" ] ; then
+       get_git_svn_id "$1/../.."
+elif [ -d "$1/.svn" ] ; then
+       COMPARE="$1/.svn"
+       get_svn_id "$1"
+elif [ -d "$1/_svn" ] ; then
+       COMPARE="$1/_svn"
+       get_svn_id "$1"
+fi
+
+
+# Allow overriding both REVISION and DEVEL_VERSION
+if [ -f "$2/autorevision.conf" ] ; then
+       SCM=manual
+       . "$2/autorevision.conf"
+fi
+
+
+# Abort if the header is newer
+if [ "$COMPARE" -ot "$HEADER" ] ; then return; fi
+
+
+# Set the development version string
+if [ x = "x$DEVEL_VERSION" ] ; then
+       if [ x != "x$REVISION" ] ; then
+               if [ $SCM = svn ] ; then
+                       DEVEL_VERSION="SVN r$REVISION"
+               elif [ $SCM = git-svn ] ; then
+                       DEVEL_VERSION="SVN r$REVISION (via git)"
+               elif [ $SCM = manual ] ; then
+                       DEVEL_VERSION="$REVISION (manually configured)"
+               fi
+       fi
+fi
+
+
+# Output the header
+if [ x != "x$DEVEL_VERSION" ] ; then
+       echo "#define SHOW_EXTRA_INFO" > "$HEADER"
+       echo "#define DEVEL_VERSION \"$DEVEL_VERSION\"" >> "$HEADER"
+fi
index b11c841..986df9a 100755 (executable)
@@ -32,6 +32,13 @@ AC_LANG_CPLUSPLUS
 
 
 AC_ARG_DEBUG
+
+case "$debug" in
+       yes)
+               AC_DEFINE(SHOW_EXTRA_INFO,[],[Show extra info in the about dialog])
+       ;;
+esac
+
 AC_ARG_OPTIMIZATION
 AC_ARG_WARNINGS
 AC_ARG_PROFILE_ARCS
@@ -218,6 +225,7 @@ AC_SUBST(imagedir)
 
 AC_OUTPUT(
 Makefile
+build_tools/Makefile
 doxygen.cfg
 po/Makefile.in
 synfigstudio.desktop
index 3d255ad..698f4c3 100644 (file)
@@ -39,6 +39,9 @@
 
 #include <synfig/general.h>
 
+// This is generated at make time from .svn or .git/svn or autorevision.conf
+#include <autorevision.h>
+
 #include "about.h"
 #include "app.h"
 
@@ -179,7 +182,7 @@ About::About()
        string extra_info = get_comments() + "\n";
        
        #ifdef DEVEL_VERSION
-               extra_info += strprintf(_("\nDevelopment version %s %s\n"),VERSION,DEVEL_VERSION);
+               extra_info += strprintf(_("\nDevelopment version:\n%s\n"),DEVEL_VERSION);
        #endif
        
        extra_info += "\n";