diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2015-02-15 20:25:18 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-15 13:26:51 -0800 |
commit | c45768a09ffcc6393912b74ed3661b5a110041e8 (patch) | |
tree | e0f322e344a337abd4d9aa40e85e21a58c65af5e | |
parent | f6dbed1fc6c71251e1937cb1b63e96ff7a8251c3 (diff) | |
download | subsurface-c45768a09ffcc6393912b74ed3661b5a110041e8.tar.gz |
add and use a version.c / version.h pair
version.c is now object code which is recompiled each time
ssrf-version.h changes, while the interface file version.h
remains that same at all times and files which include it
will not need to be recompiled.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/about.cpp | 4 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 4 | ||||
-rw-r--r-- | qt-ui/updatemanager.cpp | 10 | ||||
-rw-r--r-- | qt-ui/usersurvey.cpp | 8 | ||||
-rw-r--r-- | save-git.c | 4 | ||||
-rw-r--r-- | subsurface.pro | 2 | ||||
-rw-r--r-- | subsurfacestartup.c | 4 | ||||
-rw-r--r-- | version.c | 16 | ||||
-rw-r--r-- | version.h | 16 |
9 files changed, 51 insertions, 17 deletions
diff --git a/qt-ui/about.cpp b/qt-ui/about.cpp index 361031599..203357010 100644 --- a/qt-ui/about.cpp +++ b/qt-ui/about.cpp @@ -1,5 +1,5 @@ #include "about.h" -#include "ssrf-version.h" +#include "version.h" #include <QDesktopServices> #include <QUrl> #include <QShortcut> @@ -9,7 +9,7 @@ SubsurfaceAbout::SubsurfaceAbout(QWidget *parent, Qt::WindowFlags f) : QDialog(p ui.setupUi(this); setWindowModality(Qt::ApplicationModal); - QString versionString(GIT_VERSION_STRING); + QString versionString(subsurface_git_version()); QStringList readableVersions = QStringList() << "4.3.950" << "4.4 Beta 1" << "4.3.960" << "4.4 Beta 2" << "4.3.970" << "4.4 Beta 3"; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 9a528e97f..d7f520f18 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -11,7 +11,7 @@ #include <QSettings> #include <QShortcut> #include <QToolBar> -#include "ssrf-version.h" +#include "version.h" #include "divelistview.h" #include "downloadfromdivecomputer.h" #include "preferences.h" @@ -999,7 +999,7 @@ void MainWindow::checkSurvey(QSettings *s) s->setValue("FirstUse42", value); } // wait a week for production versions, but not at all for non-tagged builds - QString ver(VERSION_STRING); + QString ver(subsurface_version()); int waitTime = 7; QDate firstUse42 = s->value("FirstUse42").toDate(); if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && !s->contains("SurveyDone"))) { diff --git a/qt-ui/updatemanager.cpp b/qt-ui/updatemanager.cpp index 3fff8b45d..fbaa6ba3c 100644 --- a/qt-ui/updatemanager.cpp +++ b/qt-ui/updatemanager.cpp @@ -4,7 +4,7 @@ #include <QMessageBox> #include <QUuid> #include "subsurfacewebservices.h" -#include "ssrf-version.h" +#include "version.h" #include "mainwindow.h" UpdateManager::UpdateManager(QObject *parent) : QObject(parent) @@ -16,9 +16,9 @@ UpdateManager::UpdateManager(QObject *parent) : QObject(parent) return; if (settings.contains("LastVersionUsed")) { // we have checked at least once before - if (settings.value("LastVersionUsed").toString() != GIT_VERSION_STRING) { + if (settings.value("LastVersionUsed").toString() != subsurface_git_version()) { // we have just updated - wait two weeks before you check again - settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING)); + settings.setValue("LastVersionUsed", QString(subsurface_git_version())); settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate)); } else { // is it time to check again? @@ -28,7 +28,7 @@ UpdateManager::UpdateManager(QObject *parent) : QObject(parent) return; } } - settings.setValue("LastVersionUsed", QString(GIT_VERSION_STRING)); + settings.setValue("LastVersionUsed", QString(subsurface_git_version())); settings.setValue("NextCheck", QDateTime::currentDateTime().addDays(14).toString(Qt::ISODate)); checkForUpdates(true); } @@ -47,7 +47,7 @@ void UpdateManager::checkForUpdates(bool automatic) os = "unknown"; #endif isAutomaticCheck = automatic; - QString version = CANONICAL_VERSION_STRING; + QString version = subsurface_canonical_version(); QString uuidString = getUUID(); QString url = QString("http://subsurface-divelog.org/updatecheck.html?os=%1&version=%2&uuid=%3").arg(os, version, uuidString); QNetworkRequest request; diff --git a/qt-ui/usersurvey.cpp b/qt-ui/usersurvey.cpp index ac8486988..a2b47e4d0 100644 --- a/qt-ui/usersurvey.cpp +++ b/qt-ui/usersurvey.cpp @@ -4,7 +4,7 @@ #include "usersurvey.h" #include "ui_usersurvey.h" -#include "ssrf-version.h" +#include "version.h" #include "subsurfacewebservices.h" #include "updatemanager.h" @@ -22,7 +22,7 @@ UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); connect(quitKey, SIGNAL(activated()), parent, SLOT(close())); - os = QString("ssrfVers=%1").arg(VERSION_STRING); + os = QString("ssrfVers=%1").arg(subsurface_version()); os.append(QString("&prettyOsName=%1").arg(SubsurfaceSysInfo::prettyOsName())); QString arch = SubsurfaceSysInfo::buildCpuArchitecture(); os.append(QString("&appCpuArch=%1").arg(arch)); @@ -39,7 +39,7 @@ QString UserSurvey::getVersion() { QString arch; // fill in the system data - QString sysInfo = QString("Subsurface %1").arg(VERSION_STRING); + QString sysInfo = QString("Subsurface %1").arg(subsurface_version()); sysInfo.append(tr("\nOperating system: %1").arg(SubsurfaceSysInfo::prettyOsName())); arch = SubsurfaceSysInfo::buildCpuArchitecture(); sysInfo.append(tr("\nCPU architecture: %1").arg(arch)); @@ -54,7 +54,7 @@ QString UserSurvey::getUserAgent() QString arch; // fill in the system data - use ':' as separator // replace all other ':' with ' ' so that this is easy to parse - QString userAgent = QString("Subsurface:%1:").arg(VERSION_STRING); + QString userAgent = QString("Subsurface:%1:").arg(subsurface_version()); userAgent.append(SubsurfaceSysInfo::prettyOsName().replace(':', ' ') + ":"); arch = SubsurfaceSysInfo::buildCpuArchitecture().replace(':', ' '); userAgent.append(arch); diff --git a/save-git.c b/save-git.c index 0aef48f0b..0125f64d7 100644 --- a/save-git.c +++ b/save-git.c @@ -13,7 +13,7 @@ #include "dive.h" #include "device.h" #include "membuffer.h" -#include "ssrf-version.h" +#include "version.h" /* * handle libgit2 revision 0.20 and earlier @@ -990,7 +990,7 @@ static void create_commit_message(struct membuffer *msg) } while ((dc = dc->next) != NULL); put_format(msg, "\n"); } - put_format(msg, "Created by subsurface %s\n", VERSION_STRING); + put_format(msg, "Created by subsurface %s\n", subsurface_version()); } static int create_new_commit(git_repository *repo, const char *branch, git_oid *tree_id) diff --git a/subsurface.pro b/subsurface.pro index a34bc091a..cc8fd1795 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -26,6 +26,7 @@ system(cat $$VERSION_FILE > /dev/null 2>&1 || touch $$VERSION_FILE) HEADERS = \ $$VERSION_FILE \ + version.h \ cochran.h \ color.h \ deco.h \ @@ -119,6 +120,7 @@ android: HEADERS -= \ qt-ui/printoptions.h SOURCES = \ + version.c \ cochran.c \ deco.c \ device.c \ diff --git a/subsurfacestartup.c b/subsurfacestartup.c index 0722e954e..62e37f932 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -1,5 +1,5 @@ #include "subsurfacestartup.h" -#include "ssrf-version.h" +#include "version.h" #include <stdbool.h> #include <string.h> #include "gettext.h" @@ -110,7 +110,7 @@ bool imported = false; static void print_version() { - printf("Subsurface v%s, ", GIT_VERSION_STRING); + printf("Subsurface v%s, ", subsurface_git_version()); printf("built with libdivecomputer v%s\n", dc_version(NULL)); } diff --git a/version.c b/version.c new file mode 100644 index 000000000..5b54bf4c7 --- /dev/null +++ b/version.c @@ -0,0 +1,16 @@ +#include "ssrf-version.h" + +const char *subsurface_version(void) +{ + return VERSION_STRING; +} + +const char *subsurface_git_version(void) +{ + return GIT_VERSION_STRING; +} + +const char *subsurface_canonical_version(void) +{ + return CANONICAL_VERSION_STRING; +} diff --git a/version.h b/version.h new file mode 100644 index 000000000..bc0aac00d --- /dev/null +++ b/version.h @@ -0,0 +1,16 @@ +#ifndef VERSION_H +#define VERSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +const char *subsurface_version(void); +const char *subsurface_git_version(void); +const char *subsurface_canonical_version(void); + +#ifdef __cplusplus +} +#endif + +#endif |