summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <rainer.keller@digia.com>2013-10-18 08:39:17 +0200
committerRainer Keller <rainer.keller@digia.com>2013-10-23 16:32:48 +0300
commitcd18f7dbde04e1a0866598da64b626e4e1cf03e6 (patch)
tree9bfb5ec72542a096b67f22286f6edd5abde24157
parentc7ff23c24a2ee2daf412efb6c4b80a3dd125db6d (diff)
Provide appcontroller with version information
Change-Id: Ibe6c8ddcde55a8055100dbceb146c62bd94f9539 Reviewed-by: Rainer Keller <rainer.keller@digia.com>
-rw-r--r--appcontroller.pro19
-rw-r--r--main.cpp3
2 files changed, 22 insertions, 0 deletions
diff --git a/appcontroller.pro b/appcontroller.pro
index 7ad5acc..ac7eb83 100644
--- a/appcontroller.pro
+++ b/appcontroller.pro
@@ -15,3 +15,22 @@ android {
target.path = $$[INSTALL_ROOT]/usr/bin
}
INSTALLS+=target
+
+# 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/main.cpp b/main.cpp
index 4802ac3..8b69c7f 100644
--- a/main.cpp
+++ b/main.cpp
@@ -254,6 +254,9 @@ int main(int argc, char **argv)
return 1;
} else if (arg == "--print-debug") {
config.flags |= Config::PrintDebugMessages;
+ } else if (arg == "--version") {
+ printf("Appcontroller version: " GIT_VERSION "\nGit revision: " GIT_HASH "\n");
+ return 0;
} else {
args.prepend(arg);
break;