Skip to content

Commit cd18f7d

Browse files
committed
Provide appcontroller with version information
Change-Id: Ibe6c8ddcde55a8055100dbceb146c62bd94f9539 Reviewed-by: Rainer Keller <[email protected]>
1 parent c7ff23c commit cd18f7d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

appcontroller.pro

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,22 @@ android {
1515
target.path = $$[INSTALL_ROOT]/usr/bin
1616
}
1717
INSTALLS+=target
18+
19+
# Find out git hash
20+
unix:system(which git):HAS_GIT=TRUE
21+
win32:system(where git.exe):HAS_GIT=TRUE
22+
contains(HAS_GIT, TRUE) {
23+
GIT_HASH=$$system(git log -1 --format=%H)
24+
!system(git diff-index --quiet HEAD): GIT_HASH="$$GIT_HASH-dirty"
25+
GIT_VERSION=$$system(git describe --tags --exact-match)
26+
isEmpty(GIT_VERSION) : GIT_VERSION="unknown"
27+
} else {
28+
GIT_HASH="unknown"
29+
GIT_VERSION="unknown"
30+
}
31+
32+
isEmpty(GIT_VERSION) : error("No suitable tag found")
33+
isEmpty(GIT_HASH) : error("No hash available")
34+
35+
DEFINES+="GIT_HASH=\\\"$$GIT_HASH\\\""
36+
DEFINES+="GIT_VERSION=\\\"$$GIT_VERSION\\\""

main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ int main(int argc, char **argv)
254254
return 1;
255255
} else if (arg == "--print-debug") {
256256
config.flags |= Config::PrintDebugMessages;
257+
} else if (arg == "--version") {
258+
printf("Appcontroller version: " GIT_VERSION "\nGit revision: " GIT_HASH "\n");
259+
return 0;
257260
} else {
258261
args.prepend(arg);
259262
break;

0 commit comments

Comments
 (0)