From 56f05dc8eac612efc92ec155744a04e2505a2829 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Wed, 5 Aug 2015 16:33:30 -0400 Subject: [PATCH] set QGC version from git --- .gitignore | 5 +++-- QGCApplication.pro | 3 ++- git_version.pri | 26 ++++++++++++++++++++++++++ qgroundcontrol.pro | 5 +++++ src/QGCApplication.cc | 11 +++++++---- src/QGCConfig.h | 17 ----------------- src/git_version.h | 3 +++ 7 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 git_version.pri create mode 100644 src/git_version.h diff --git a/.gitignore b/.gitignore index 1b687aae1..cbd02f56a 100644 --- a/.gitignore +++ b/.gitignore @@ -68,7 +68,8 @@ ui_* *.so* *.moc *.prl +git_version.cpp +git_version.obj # android -android/local.properties -android/gradle.properties +android/local.properties \ No newline at end of file diff --git a/QGCApplication.pro b/QGCApplication.pro index 12fc55ae6..4c398718c 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -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) { diff --git a/git_version.pri b/git_version.pri new file mode 100644 index 000000000..229fcbe47 --- /dev/null +++ b/git_version.pri @@ -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 diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 6928aadf9..d577d25b7 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -22,6 +22,8 @@ CONFIG += ordered SUBDIRS = ./QGCLocationPlugin.pro SUBDIRS += ./QGCApplication.pro +include(git_version.pri) + QGCApplication.depends = QGCLocationPlugin message(Qt version $$[QT_VERSION]) @@ -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 diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 4230ee0f1..a322e3017 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -42,6 +42,7 @@ #include "VideoStreaming.h" +#include "git_version.h" #include "QGC.h" #include "QGCApplication.h" #include "MainWindow.h" @@ -276,10 +277,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 diff --git a/src/QGCConfig.h b/src/QGCConfig.h index 485c4cb18..517ec2112 100644 --- a/src/QGCConfig.h +++ b/src/QGCConfig.h @@ -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 8 - -// 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 0 -#endif - -#ifndef QGC_APPLICATION_VERSION_BUILDTYPE -#define QGC_APPLICATION_VERSION_BUILDTYPE "(Development)" -#endif - #endif // QGC_CONFIGURATION_H diff --git a/src/git_version.h b/src/git_version.h new file mode 100644 index 000000000..84dd2fbb5 --- /dev/null +++ b/src/git_version.h @@ -0,0 +1,3 @@ +extern "C" { + const char *git_version(); +} -- 2.22.0