Generate the exact version string via Git.

This commit is contained in:
Konstantin Isakov 2010-07-02 21:07:05 +04:00
parent 71519ff19b
commit be23f54914
3 changed files with 30 additions and 1 deletions

View file

@ -5,6 +5,18 @@ TEMPLATE = app
TARGET = goldendict
VERSION = 0.9.0+git
# Generate version file. We do this here and in a build rule described later.
# The build rule is required since qmake isn't run each time the project is
# rebuilt; and doing it here is required too since any other way the RCC
# compiler would complain if version.txt wouldn't exist (fresh checkouts).
system(git describe --tags --always --dirty > version.txt): hasGit=1
isEmpty( hasGit ) {
message(Failed to precisely describe the version via Git -- using the default version string)
system(echo $$VERSION > version.txt)
}
# DEPENDPATH += . generators
INCLUDEPATH += .
QT += webkit
@ -241,6 +253,13 @@ TRANSLATIONS += locale/ru_RU.ts \
locale/lt_LT.ts \
locale/uk_UA.ts
# Build version file
QMAKE_EXTRA_TARGETS += revtarget
PRE_TARGETDEPS += version.txt
revtarget.target = version.txt
revtarget.commands = git describe --tags --always --dirty > $$revtarget.target
revtarget.depends = $$SOURCES $$HEADERS $$FORMS
# This makes qmake generate translations
win32:# Windows doesn't seem to have *-qt4 symlinks
isEmpty(QMAKE_LRELEASE):QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease

View file

@ -1614,7 +1614,16 @@ void MainWindow::showAbout()
ui.setupUi( &about );
ui.version->setText( PROGRAM_VERSION );
QFile versionFile( ":/version.txt" );
QString version;
if ( !versionFile.open( QFile::ReadOnly ) )
version = tr( "[Unknown]" );
else
version = QString::fromAscii( versionFile.readAll() ).trimmed();
ui.version->setText( version );
about.show();
about.exec();

View file

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/" >
<file>version.txt</file>
<file>icons/print.png</file>
<file>icons/arrow.png</file>
<file>icons/prefix.png</file>