From 1071310c5c72439d7fd522d0b6af9a6b0c6359ab Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Mon, 17 Nov 2014 12:17:57 +0100 Subject: b2qt-flashing-wizard: Show version on startup Change-Id: Id6c125a24d1f8e64a9c442632600c3715c3ab546 Reviewed-by: Rainer Keller --- src/b2qt-flashing-wizard/b2qt-flashing-wizard.pro | 19 +++++++++++++++++++ src/b2qt-flashing-wizard/main.cpp | 1 + 2 files changed, 20 insertions(+) (limited to 'src/b2qt-flashing-wizard') diff --git a/src/b2qt-flashing-wizard/b2qt-flashing-wizard.pro b/src/b2qt-flashing-wizard/b2qt-flashing-wizard.pro index 05403b9..31c734d 100644 --- a/src/b2qt-flashing-wizard/b2qt-flashing-wizard.pro +++ b/src/b2qt-flashing-wizard/b2qt-flashing-wizard.pro @@ -33,3 +33,22 @@ HEADERS += \ RESOURCES += b2qt-flashing-wizard.qrc INSTALLS += target target.path = /bin + +# Find out git hash +unix:system(which git):HAS_GIT=TRUE +win32:system(where git.exe):HAS_GIT=TRUE +contains(HAS_GIT, TRUE) { + GIT_HASH=$$system(git log -1 --format=%H) + !system(git diff-index --quiet HEAD): GIT_HASH="$$GIT_HASH-dirty" + GIT_VERSION=$$system(git describe --tags --exact-match) + isEmpty(GIT_VERSION) : GIT_VERSION="unknown" +} else { + GIT_HASH="unknown" + GIT_VERSION="unknown" +} + +isEmpty(GIT_VERSION) : error("No suitable tag found") +isEmpty(GIT_HASH) : error("No hash available") + +DEFINES+="GIT_HASH=\\\"$$GIT_HASH\\\"" +DEFINES+="GIT_VERSION=\\\"$$GIT_VERSION\\\"" diff --git a/src/b2qt-flashing-wizard/main.cpp b/src/b2qt-flashing-wizard/main.cpp index 0321e3e..25ab9d1 100644 --- a/src/b2qt-flashing-wizard/main.cpp +++ b/src/b2qt-flashing-wizard/main.cpp @@ -26,6 +26,7 @@ int main(int argc, char **argv) { + printf("Version %s, SHA1 %s\n", GIT_VERSION, GIT_HASH); QApplication app(argc, argv); // qDebug() << QStyleFactory::keys(); QStyle *style = QStyleFactory::create("Fusion"); -- cgit v1.2.3