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>
This commit is contained in:
Lubomir I. Ivanov 2015-02-15 20:25:18 +02:00 committed by Dirk Hohndel
parent f6dbed1fc6
commit c45768a09f
9 changed files with 51 additions and 17 deletions

View file

@ -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";

View file

@ -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"))) {

View file

@ -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;

View file

@ -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);

View file

@ -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)

View file

@ -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 \

View file

@ -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));
}

16
version.c Normal file
View file

@ -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;
}

16
version.h Normal file
View file

@ -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