improve the way the git hash is included in the binary

should be better for use of ccache and so on
This commit is contained in:
Peinthor Rene
2013-04-19 11:54:25 +02:00
parent 0f24972a2c
commit 441d4e79b7
3 changed files with 19 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
#include "AboutDialog.h"
#include "ui_AboutDialog.h"
#include "gen_version.h"
#include <sqlite3.h>
AboutDialog::AboutDialog(QWidget *parent) :

View File

@@ -17,6 +17,18 @@ CONFIG(unittest) {
SOURCES += main.cpp
}
# version reporting
#version.depends = version.sh
# the following line is commented because otherwise qmake would always call
# this build step and would always relink the target
# I assume that is kinda ok for release, but for development we dont care
# about an all time super actual git version number
# so this is disabled for the debug build
#CONFIG(debug,debug|release):version.target = Makefile.Debug
CONFIG(release,debug|release):version.target = Makefile.Release
version.commands = sh $$PWD/version.sh $$PWD
QMAKE_EXTRA_TARGETS += version
HEADERS += \
sqlitedb.h \
MainWindow.h \
@@ -35,7 +47,8 @@ HEADERS += \
grammar/Sqlite3Parser.hpp \
grammar/sqlite3TokenTypes.hpp \
sqlitetablemodel.h \
FilterTableHeader.h
FilterTableHeader.h \
gen_version.h
SOURCES += \
sqlitedb.cpp \
@@ -68,9 +81,6 @@ FORMS += \
ExportCsvDialog.ui \
ImportCsvDialog.ui
QMAKE_CXXFLAGS += -DAPP_VERSION=\\\"`cd $$PWD;git log -n1 --format=%h_git`\\\"
unix {
LIBS += -ldl
}

4
src/version.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
cd $1
echo -n "#define APP_VERSION " > gen_version.h
git log -n1 --format="\"%h_git\"" >> gen_version.h