Smart xswiftbus compatibility check based on git commit SHA-1

This is more tolerant that the simple check based on version numbers.
Different versions can be compatible if they have the same SHA-1 when
considering only those files that can influence xswiftbus.
This commit is contained in:
Mat Sutcliffe
2019-12-31 22:51:17 +00:00
parent 48d1521d3a
commit 836eb107a3
9 changed files with 49 additions and 2 deletions

View File

@@ -77,11 +77,16 @@ using namespace BlackCore;
namespace
{
inline const QString &xswiftbusServiceName()
const QString &xswiftbusServiceName()
{
static const QString name("org.swift-project.xswiftbus");
return name;
}
const QString &commitHash()
{
static const QString hash(XSWIFTBUS_COMMIT);
return hash;
}
}
namespace BlackSimPlugin
@@ -1362,11 +1367,12 @@ namespace BlackSimPlugin
const QString swiftVersion = CBuildConfig::getVersionString();
const QString xswiftbusVersion = service.getVersionNumber();
const QString xswiftbusCommitHash = service.getCommitHash();
if (xswiftbusVersion.isEmpty())
{
CLogMessage(this).warning(u"Could not determine which version of XSwiftBus is running. Mismatched versions might cause instability.");
}
else if (swiftVersion != xswiftbusVersion)
else if (commitHash() != xswiftbusCommitHash)
{
CLogMessage(this).error(u"You are using an incorrect version of XSwiftBus. The version of XSwiftBus (%1) should match the version of swift (%2). Consider upgrading!") << xswiftbusVersion << swiftVersion;
}

View File

@@ -21,6 +21,9 @@ HEADERS += *.h
DISTFILES += simulatorxplane.json
DESTDIR = $$DestRoot/bin/plugins/simulator
isEmpty(XSWIFTBUS_COMMIT): error(Missing XSWIFTBUS_COMMIT variable)
DEFINES += XSWIFTBUS_COMMIT=\\\"$$XSWIFTBUS_COMMIT\\\"
win32 {
dlltarget.path = $$PREFIX/bin/plugins/simulator
INSTALLS += dlltarget

View File

@@ -43,6 +43,11 @@ namespace BlackSimPlugin
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getVersionNumber"));
}
QString CXSwiftBusServiceProxy::getCommitHash()
{
return m_dbusInterface->callDBusRet<QString>(QLatin1String("getCommitHash"));
}
void CXSwiftBusServiceProxy::getOwnAircraftSituationDataAsync(XPlaneData *o_xplaneData)
{
if (!o_xplaneData) { return; }

View File

@@ -100,6 +100,9 @@ namespace BlackSimPlugin
//! Get XSwiftBus version number
QString getVersionNumber();
//! Get SHA1 of the last commit that could influence xswiftbus
QString getCommitHash();
//! Get own aircraft situation data
void getOwnAircraftSituationDataAsync(BlackSimPlugin::XPlane::XPlaneData *o_xplaneData);