From: Michal H. <ms...@gm...> - 2008-08-20 22:31:14
|
This patch changes implementation of version handling in gui. We don't rely on hardcoded version in src/gui/version.h, but we use the output from getversion script instead. The second big change is that we don't have version defined as a macro in the header file. Macro approach has one big disadvantage that we have to rebuild all sources which use it each time when the version is changed. In this patch we have changed VERSION to the extern variable defined in the version.cc module which is generated on demand by Makefile.gui. TARGET binary depends on this cc module and Makefile.gui takes care that it contains the current full version value (from getversion -v -r). File is generated during first compilation and whenever some of the version important files (getversion -f) is modified. Implementation of cc module doesn't have above macro (rebuild all sources including version.h) problem because the real value of extern variable for version is used in the link time. So only necessary minimum is recompiled. * dist-exclude, version_exclude - version.cc is generated and shouldn't be distributed * version.cc.tmpl - template for version.cc added - this file is used by Makefile.gui to generate version.cc - currently only defines PDFEDIT_VERSION extern variable * Makefile.gui - generates version.cc - simply substitute version with the current FULL_VERSION (./getversion -v -r). Generation target depends on all version important files * pdfedit.pro - TARGET depends on version.cc * version.h - VERSION -> PDFEDIT_VERSION (for disambiguate) - PDFEDIT_VERSION is variable rather than macro * gui/aboutwindow.cc, gui/args.cc, gui/base.cc, gui/main.cc - sync with above changes Index: pdfedit-patches/src/gui/Makefile.gui =================================================================== --- pdfedit-patches.orig/src/gui/Makefile.gui 2008-08-20 16:05:24.000000000 -0600 +++ pdfedit-patches/src/gui/Makefile.gui 2008-08-20 16:05:38.000000000 -0600 @@ -17,3 +17,16 @@ include ../../Makefile.flags QTMAKEFILE = Makefile.qt include $(QTMAKEFILE) + +# Full version including revision +# Variable is defined here, because it is used only here +FULL_VERSION=$(shell $(ROOT)/getversion -v -r) + +# version.cc is auto-generated file which holds currently up-to-date +# full version of the package. It depedns on all files which may have +# influence on FULL_VERSION (returned by getversion -f). +# TARGET binary is linked with this file, so we don't have to recompile +# all files which include version.h header and rather regenerate this +# module, compile and link it. +version.cc: version.cc.tmpl $(shell $(ROOT)/getversion -f) + @sed 's@\(^ *extern.*VERSION *=\).*@\1"$(FULL_VERSION)";@' version.cc.tmpl > version.cc Index: pdfedit-patches/src/gui/pdfedit.pro =================================================================== --- pdfedit-patches.orig/src/gui/pdfedit.pro 2008-08-20 16:05:24.000000000 -0600 +++ pdfedit-patches/src/gui/pdfedit.pro 2008-08-20 16:05:38.000000000 -0600 @@ -141,6 +141,7 @@ SOURCES += annotdialog.cc HEADERS += annotdialog.h HEADERS += mergeform.h selectpagesdialog.h SOURCES += mergeform.cc selectpagesdialog.cc +SOURCES += version.cc # Help window HEADERS += helpwindow.h Index: pdfedit-patches/src/gui/version.h =================================================================== --- pdfedit-patches.orig/src/gui/version.h 2008-08-20 16:05:24.000000000 -0600 +++ pdfedit-patches/src/gui/version.h 2008-08-20 16:05:38.000000000 -0600 @@ -29,10 +29,18 @@ #ifndef __VERSION_H__ #define __VERSION_H__ +// WARNING: DO NOT INCLUDE from header files visible outside gui code!!! + /** Application name shown in various About boxes, window titles, etc .... */ #define APP_NAME "PDFedit" -/** Version of application. */ -#define VERSION "0.4.1-CVS" + +// It is not a macro, because we want to provide this information only +// during link time to preve +/** Version of application. + * This will also include release (if defined). + */ +extern const char *PDFEDIT_VERSION; + /** Compile time of this program */ #define COMPILE_TIME (__DATE__ ", " __TIME__) Index: pdfedit-patches/dist-exclude =================================================================== --- pdfedit-patches.orig/dist-exclude 2008-08-20 16:05:24.000000000 -0600 +++ pdfedit-patches/dist-exclude 2008-08-20 16:05:38.000000000 -0600 @@ -24,6 +24,7 @@ src/gui/pdfedit src/gui/run-pdfedit-nd src/gui/ulab-fix src/gui/Makefile.qt +src/gui/version.cc src/kpdf-kde-3.3.2/*.a src/kpdf-kde-3.3.2/*.o src/kpdf-kde-3.3.2/Makefile.qt Index: pdfedit-patches/src/gui/aboutwindow.cc =================================================================== --- pdfedit-patches.orig/src/gui/aboutwindow.cc 2008-08-20 16:05:24.000000000 -0600 +++ pdfedit-patches/src/gui/aboutwindow.cc 2008-08-20 16:05:38.000000000 -0600 @@ -43,7 +43,7 @@ namespace gui { using namespace std; /** Version of program */ -QString app=APP_NAME " " VERSION; +QString app=QString(APP_NAME) +" "+ QString(PDFEDIT_VERSION); /** About Dialog flags */ const Qt::WFlags aboutDialogFlags=Qt::WDestructiveClose | Qt::WType_Dialog; Index: pdfedit-patches/src/gui/args.cc =================================================================== --- pdfedit-patches.orig/src/gui/args.cc 2008-08-20 16:05:24.000000000 -0600 +++ pdfedit-patches/src/gui/args.cc 2008-08-20 16:05:38.000000000 -0600 @@ -81,14 +81,14 @@ const QString nextParam(const QString &p Print out application header (name and version) to stdout */ void printHeader() { - cout << APP_NAME << " " << VERSION << endl; + cout << APP_NAME << " " << PDFEDIT_VERSION << endl; } /** Print out application header (name and version) to stderr */ void printHeaderErr() { - cerr << APP_NAME << " " << VERSION << endl; + cerr << APP_NAME << " " << PDFEDIT_VERSION << endl; } /** Index: pdfedit-patches/src/gui/base.cc =================================================================== --- pdfedit-patches.orig/src/gui/base.cc 2008-08-20 16:05:24.000000000 -0600 +++ pdfedit-patches/src/gui/base.cc 2008-08-20 16:05:38.000000000 -0600 @@ -712,7 +712,7 @@ QStringList Base::variables() { /** Return version of editor as string @return Version of editor (major.minor.release or major.minor.relase-suffix) */ QString Base::version() { - return VERSION; + return PDFEDIT_VERSION; } Index: pdfedit-patches/src/gui/main.cc =================================================================== --- pdfedit-patches.orig/src/gui/main.cc 2008-08-20 16:05:24.000000000 -0600 +++ pdfedit-patches/src/gui/main.cc 2008-08-20 16:05:38.000000000 -0600 @@ -86,7 +86,7 @@ void handleHelp(){ Print version to STDOUT and exit */ void handleVersion(){ - cout << VERSION << endl; + cout << PDFEDIT_VERSION << endl; exit(0); } Index: pdfedit-patches/src/gui/version.cc.tmpl =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ pdfedit-patches/src/gui/version.cc.tmpl 2008-08-20 16:05:38.000000000 -0600 @@ -0,0 +1,2 @@ + +extern const char * PDFEDIT_VERSION = ""; Index: pdfedit-patches/version_exclude =================================================================== --- pdfedit-patches.orig/version_exclude 2008-08-20 16:05:41.000000000 -0600 +++ pdfedit-patches/version_exclude 2008-08-20 16:05:56.000000000 -0600 @@ -2,3 +2,4 @@ src/tests/ aconf\.h \.menu-trans.h src/qsa +src/gui/version.cc -- Michal Hocko |