Skip to content

Commit

Permalink
update version from git
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Jul 9, 2016
1 parent 0949383 commit 57b381c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
25 changes: 18 additions & 7 deletions QGCCommon.pri
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,38 @@ MobileBuild {

exists ($$PWD/.git) {
GIT_DESCRIBE = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
GIT_HASH = $$system(git rev-parse HEAD)
GIT_BRANCH = $$system(git --git-dir $$PWD/.git --work-tree $$PWD rev-parse --abbrev-ref HEAD)
GIT_HASH = $$system(git --git-dir $$PWD/.git --work-tree $$PWD rev-parse --short HEAD)
GIT_TIME = $$system(git --git-dir $$PWD/.git --work-tree $$PWD show --oneline --format=\"%ci\" -s HEAD)

# determine if we're on a tag matching vX.Y.Z (stable release)
GIT_TAG = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --exact-match --tags HEAD)
contains(GIT_TAG, v[0-9].[0-9].[0-9]) {
# release version "vX.Y.Z"
GIT_VERSION = $${GIT_DESCRIBE}
} else {
# development version "Development branch:sha date"
GIT_VERSION = "Development $${GIT_BRANCH}:$${GIT_HASH} $${GIT_TIME}"
}

VERSION = $$replace(GIT_DESCRIBE, "v", "")
VERSION = $$replace(VERSION, "-", ".")
VERSION = $$section(VERSION, ".", 0, 3)
MacBuild {
MAC_VERSION = $$section(VERSION, ".", 0, 2)
MAC_BUILD = $$section(VERSION, ".", 3, 3)
message(QGroundControl version $${MAC_VERSION} build $${MAC_BUILD} describe $${GIT_DESCRIBE} hash $${GIT_HASH})
message(QGroundControl version $${MAC_VERSION} build $${MAC_BUILD} describe $${GIT_VERSION})
} else {
message(QGroundControl version $${VERSION} describe $${GIT_DESCRIBE} hash $${GIT_HASH})
message(QGroundControl version $${VERSION} describe $${GIT_VERSION})
}
} else {
GIT_DESCRIBE = None
GIT_HASH = None
GIT_VERSION = None
VERSION = 0.0.0 # Marker to indicate out-of-tree build
MAC_VERSION = 0.0.0
MAC_BUILD = 0
}

DEFINES += GIT_TAG=\"\\\"$$GIT_DESCRIBE\\\"\"
DEFINES += GIT_HASH=\"\\\"$$GIT_HASH\\\"\"
DEFINES += GIT_VERSION=\"\\\"$$GIT_VERSION\\\"\"
DEFINES += EIGEN_MPL2_ONLY

# Installer configuration
Expand Down
8 changes: 1 addition & 7 deletions src/QGCApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,7 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
setOrganizationName(QGC_ORG_NAME);
setOrganizationDomain(QGC_ORG_DOMAIN);

QString versionString(GIT_TAG);
// stable versions are on tags (v1.2.3)
// development versions are full git describe versions (v1.2.3-18-g879e8b3)
if (versionString.length() > 8) {
versionString.append(" (Development)");
}
this->setApplicationVersion(versionString);
this->setApplicationVersion(QString(GIT_VERSION));

// Set settings format
QSettings::setDefaultFormat(QSettings::IniFormat);
Expand Down

0 comments on commit 57b381c

Please sign in to comment.