From 3624aac2a6e2dc3824ae22e99e2608f93f285e61 Mon Sep 17 00:00:00 2001 From: pabs Date: Wed, 6 Feb 2008 09:11:32 +0000 Subject: [PATCH] Fix 1797745: show the correct SVN revision id in the about dialog * 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 | 2 +- synfig-studio/trunk/build_tools/Makefile.am | 8 +++ synfig-studio/trunk/build_tools/autorevision.sh | 86 +++++++++++++++++++++++++ synfig-studio/trunk/configure.ac | 8 +++ synfig-studio/trunk/src/gtkmm/about.cpp | 5 +- 5 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 synfig-studio/trunk/build_tools/Makefile.am create mode 100644 synfig-studio/trunk/build_tools/autorevision.sh diff --git a/synfig-studio/trunk/Makefile.am b/synfig-studio/trunk/Makefile.am index 2c43d70..5d017f6 100644 --- a/synfig-studio/trunk/Makefile.am +++ b/synfig-studio/trunk/Makefile.am @@ -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 index 0000000..23a1201 --- /dev/null +++ b/synfig-studio/trunk/build_tools/Makefile.am @@ -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 index 0000000..ec7ec8d --- /dev/null +++ b/synfig-studio/trunk/build_tools/autorevision.sh @@ -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 diff --git a/synfig-studio/trunk/configure.ac b/synfig-studio/trunk/configure.ac index b11c841..986df9a 100755 --- a/synfig-studio/trunk/configure.ac +++ b/synfig-studio/trunk/configure.ac @@ -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 diff --git a/synfig-studio/trunk/src/gtkmm/about.cpp b/synfig-studio/trunk/src/gtkmm/about.cpp index 3d255ad..698f4c3 100644 --- a/synfig-studio/trunk/src/gtkmm/about.cpp +++ b/synfig-studio/trunk/src/gtkmm/about.cpp @@ -39,6 +39,9 @@ #include +// This is generated at make time from .svn or .git/svn or autorevision.conf +#include + #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"; -- 2.7.4