Skip to content

Commit

Permalink
set QGC version from git
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Aug 26, 2015
1 parent 26a6fd7 commit fcdee75
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ ui_*
*.so*
*.moc
*.prl
git_version.cpp
git_version.obj
3 changes: 2 additions & 1 deletion QGCApplication.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
# -------------------------------------------------

include(QGCCommon.pri)
include(git_version.pri)

TARGET = qgroundcontrol
TEMPLATE = app
TEMPLATE = app

# Load additional config flags from user_config.pri
exists(user_config.pri):infile(user_config.pri, CONFIG) {
Expand Down
26 changes: 26 additions & 0 deletions git_version.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# set the QGC version from git

exists ($$PWD/.git) {
GIT_DESCRIBE = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
WindowsBuild {
QGC_GIT_VER = echo extern \"C\" { const char *git_version() { return \"$$GIT_DESCRIBE\"; } } > git_version.cpp
LIBS += git_version.obj
} else {
QGC_GIT_VER = echo \"extern \\\"C\\\" { const char *git_version() { return \\\"$$GIT_DESCRIBE\\\"; } }\" > git_version.cpp
LIBS += git_version.o
}
}

WindowsBuild {
LIBS += git_version.obj
} else {
LIBS += git_version.o
}

CONFIG(debug) {
GIT_VERSION_CXXFLAGS = $$QMAKE_CXXFLAGS_DEBUG
} else {
GIT_VERSION_CXXFLAGS = $$QMAKE_CXXFLAGS_RELEASE
}

QMAKE_PRE_LINK += $$QGC_GIT_VER && $$QMAKE_CXX -c $$GIT_VERSION_CXXFLAGS git_version.cpp
5 changes: 5 additions & 0 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ CONFIG += ordered
SUBDIRS = ./QGCLocationPlugin.pro
SUBDIRS += ./QGCApplication.pro

include(git_version.pri)

QGCApplication.depends = QGCLocationPlugin

message(Qt version $$[QT_VERSION])
Expand All @@ -30,3 +32,6 @@ message(Qt version $$[QT_VERSION])
error("Unsupported Qt version, 5.4+ is required")
}

message(QGroundControl version $${GIT_DESCRIBE})
git_ver.commands = $$QGC_GIT_VER
QMAKE_EXTRA_TARGETS += git_ver
11 changes: 7 additions & 4 deletions src/QGCApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ GST_PLUGIN_STATIC_DECLARE(QTVIDEOSINK_NAME);
G_END_DECLS
#endif

#include "git_version.h"
#include "configuration.h"
#include "QGC.h"
#include "QGCApplication.h"
Expand Down Expand Up @@ -251,10 +252,12 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
setOrganizationName(QGC_ORG_NAME);
setOrganizationDomain(QGC_ORG_DOMAIN);

// Version string is build from component parts. Format is:
// vMajor.Minor.BuildNumber BuildType
QString versionString("v%1.%2.%3 %4");
versionString = versionString.arg(QGC_APPLICATION_VERSION_MAJOR).arg(QGC_APPLICATION_VERSION_MINOR).arg(QGC_APPLICATION_VERSION_BUILDNUMBER).arg(QGC_APPLICATION_VERSION_BUILDTYPE);
QString versionString(git_version());
// 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);

// Set settings format
Expand Down
17 changes: 0 additions & 17 deletions src/QGCConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,4 @@
#define QGC_ORG_NAME "QGroundControl.org"
#define QGC_ORG_DOMAIN "org.qgroundcontrol"

#define QGC_APPLICATION_VERSION_MAJOR 2
#define QGC_APPLICATION_VERSION_MINOR 7

// The following #definess can be overriden from the command line so that automated build systems can
// add additional build identification.

// Only comes from command line
//#define QGC_APPLICATION_VERSION_COMMIT "..."

#ifndef QGC_APPLICATION_VERSION_BUILDNUMBER
#define QGC_APPLICATION_VERSION_BUILDNUMBER 1
#endif

#ifndef QGC_APPLICATION_VERSION_BUILDTYPE
#define QGC_APPLICATION_VERSION_BUILDTYPE "(Stable)"
#endif

#endif // QGC_CONFIGURATION_H
3 changes: 3 additions & 0 deletions src/git_version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extern "C" {
const char *git_version();
}

0 comments on commit fcdee75

Please sign in to comment.