mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:19:26 +08:00
New schema for the 4th segment of the swift version number
Based on a count of the number of commits since any of the first 3 segments were changed.
This commit is contained in:
@@ -27,10 +27,10 @@ else: GIT_BIN = $$system(which git 2> /dev/null)
|
||||
|
||||
isEmpty(GIT_BIN) {
|
||||
GIT_HEAD_SHA1="<unknown>"
|
||||
GIT_COMMIT_TS="0"
|
||||
GIT_REV_COUNT=0
|
||||
} else {
|
||||
GIT_HEAD_SHA1=$$system(git rev-parse --short HEAD)
|
||||
GIT_COMMIT_TS=$$system(git log -1 --date=format:'%Y%m%d%H%M' --pretty=format:%cd)
|
||||
GIT_REV_COUNT=$$VER_REV
|
||||
}
|
||||
|
||||
load(common_post)
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace BlackConfig
|
||||
|
||||
const QVersionNumber &CBuildConfig::getVersion()
|
||||
{
|
||||
static const QVersionNumber v { versionMajor(), versionMinor(), versionMicro(), lastCommitTimestampAsVersionSegment(lastCommitTimestamp()) };
|
||||
static const QVersionNumber v { versionMajor(), versionMinor(), versionMicro(), versionRevision() };
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -176,61 +176,6 @@ namespace BlackConfig
|
||||
return s;
|
||||
}
|
||||
|
||||
namespace Private
|
||||
{
|
||||
const QDateTime buildTimestampImpl()
|
||||
{
|
||||
// Mar 27 2017 20:17:06 (needs to be on english locale, otherwise fails - e.g.
|
||||
QDateTime dt = QLocale(QLocale::English).toDateTime(CBuildConfig::buildDateAndTime().simplified(), "MMM d yyyy hh:mm:ss");
|
||||
dt.setOffsetFromUtc(0);
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
|
||||
const QDateTime &CBuildConfig::buildTimestamp()
|
||||
{
|
||||
// Mar 27 2017 20:17:06
|
||||
static const QDateTime dt = Private::buildTimestampImpl();
|
||||
return dt;
|
||||
}
|
||||
|
||||
int CBuildConfig::lastCommitTimestampAsVersionSegment(const QDateTime &lastCommitTimestamp)
|
||||
{
|
||||
if (lastCommitTimestamp.isValid())
|
||||
{
|
||||
const QString bts = lastCommitTimestamp.toString("yyyyMMddHHmm");
|
||||
bool ok;
|
||||
const long long lctsll = bts.toLongLong(&ok); // at least 64bit
|
||||
if (!ok) { return 0; }
|
||||
// now we have to converto int
|
||||
// max 2147483647 (2^31 - 1)
|
||||
// 1MMddHHmm (years since 2010)
|
||||
const long long yearOffset = 201000000000;
|
||||
const int lctsInt = static_cast<int>(lctsll - yearOffset);
|
||||
return lctsInt;
|
||||
}
|
||||
return 0; // intentionally 0 => 0.7.3.0 <-
|
||||
}
|
||||
|
||||
int CBuildConfig::buildTimestampAsVersionSegment(const QDateTime &buildTimestamp)
|
||||
{
|
||||
if (buildTimestamp.isValid())
|
||||
{
|
||||
const QString bts = buildTimestamp.toString("yyyyMMddHHmm");
|
||||
bool ok;
|
||||
const long long btsll = bts.toLongLong(&ok); // at least 64bit
|
||||
if (!ok) { return 0; }
|
||||
// now we have to convert to int, otherwise we would fail 2021
|
||||
// max 2147483647 (2^31 - 1)
|
||||
// yyMMddHHmm (years since 2010)
|
||||
// yyyyMMddHHmm
|
||||
const long long yearOffset = 201000000000;
|
||||
const int btsInt = static_cast<int>(btsll - yearOffset);
|
||||
return btsInt;
|
||||
}
|
||||
return 0; // intentionally 0 => 0.7.3.0 <-
|
||||
}
|
||||
|
||||
const QStringList &CBuildConfig::getBuildAbiParts()
|
||||
{
|
||||
static const QStringList parts = QSysInfo::buildAbi().split('-');
|
||||
|
||||
@@ -118,12 +118,6 @@ namespace BlackConfig
|
||||
//! Returns SHA-1 of git HEAD at build time
|
||||
static const QString &gitHeadSha1();
|
||||
|
||||
//! Timestamp of the last commit (NOT the authored timestamp)
|
||||
static const QDateTime &lastCommitTimestamp(); // defined in buildconfig_gen.cpp.in
|
||||
|
||||
//! Build timestamp
|
||||
static const QDateTime &buildTimestamp();
|
||||
|
||||
//! Returns the build date and time as string
|
||||
static const QString &buildDateAndTime();
|
||||
|
||||
@@ -139,15 +133,9 @@ namespace BlackConfig
|
||||
//! Version as QVersionNumber plus platform info
|
||||
static const QString &getVersionStringPlatform();
|
||||
|
||||
//! Turns last commit timestamp into a version number
|
||||
static int lastCommitTimestampAsVersionSegment(const QDateTime &lastCommitTimestamp);
|
||||
|
||||
//! Build ABI parts as in http://doc.qt.io/qt-5/qsysinfo.html#buildAbi
|
||||
static const QStringList &getBuildAbiParts();
|
||||
|
||||
//! Turn build timestamp into 4th version segment
|
||||
static int buildTimestampAsVersionSegment(const QDateTime &buildTimestamp);
|
||||
|
||||
//! Whether this swift application is build as 32 or 64bit application
|
||||
//! \returns 32, 64 or -1 (in case no info is possible)
|
||||
static int buildWordSize();
|
||||
@@ -161,6 +149,9 @@ namespace BlackConfig
|
||||
|
||||
//! Patch version
|
||||
static constexpr int versionMicro(); // defined in buildconfig_gen.inc.in
|
||||
|
||||
//! Revision version
|
||||
static int versionRevision(); // defined in buildconfig_gen.cpp.in
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
@@ -37,18 +37,4 @@ const QString &BlackConfig::CBuildConfig::gitHeadSha1()
|
||||
return gitHeadSha1;
|
||||
}
|
||||
|
||||
namespace Private
|
||||
{
|
||||
const QDateTime lastCommitTimestampImpl()
|
||||
{
|
||||
QDateTime dt = QDateTime::fromString(\"$$GIT_COMMIT_TS\", \"yyyyMMddHHmm\");
|
||||
dt.setTimeSpec(Qt::UTC);
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
|
||||
const QDateTime &BlackConfig::CBuildConfig::lastCommitTimestamp()
|
||||
{
|
||||
static const QDateTime dt = Private::lastCommitTimestampImpl();
|
||||
return dt;
|
||||
}
|
||||
int BlackConfig::CBuildConfig::versionRevision() { return $$GIT_REV_COUNT; }
|
||||
|
||||
@@ -223,31 +223,10 @@ namespace BlackMisc
|
||||
{
|
||||
if (filename.isEmpty()) { return {}; }
|
||||
|
||||
// swift-installer-linux-64-0.7.3_2017-03-25_11-24-50.run
|
||||
thread_local const QRegularExpression firstSegments("\\d+\\.\\d+\\.\\d+");
|
||||
const QRegularExpressionMatch firstSegmentsMatch = firstSegments.match(filename);
|
||||
if (!firstSegmentsMatch.hasMatch())
|
||||
{
|
||||
return {}; // no version, invalid
|
||||
}
|
||||
QString v = firstSegmentsMatch.captured(0); // first 3 segments, like 0.9.3
|
||||
if (!v.endsWith('.')) { v += '.'; }
|
||||
|
||||
thread_local const QRegularExpression ts1("\\d{4}.?\\d{2}.?\\d{2}.?\\d{2}.?\\d{2}.?\\d{2}");
|
||||
const QRegularExpressionMatch ts1Match = ts1.match(filename);
|
||||
if (!ts1Match.hasMatch())
|
||||
{
|
||||
// version without timestamp
|
||||
v += "0";
|
||||
return v;
|
||||
}
|
||||
|
||||
const QString versionTimestampString = digitOnlyString(ts1Match.captured(0));
|
||||
const QDateTime versionTimestamp = fromStringUtc(versionTimestampString, "yyyyMMddHHmmss");
|
||||
const QString lastSegment = QString::number(CBuildConfig::buildTimestampAsVersionSegment(versionTimestamp));
|
||||
|
||||
v += lastSegment;
|
||||
return v;
|
||||
// swiftinstaller-linux-64-0.9.2.123.run
|
||||
thread_local const QRegularExpression regex { R"(\d+\.\d+\.\d+\.\d+)" };
|
||||
const QRegularExpressionMatch match = regex.match(filename);
|
||||
return match.captured();
|
||||
}
|
||||
|
||||
CArtifact::ArtifactType CArtifact::stringToType(const QString &str)
|
||||
@@ -273,10 +252,9 @@ namespace BlackMisc
|
||||
|
||||
QString CArtifact::trim4thSegment(const QString &seg)
|
||||
{
|
||||
// yyyyMMddHHmmss (14): offset is 2010xxxxx
|
||||
if (seg.length() <= 13) { return seg; }
|
||||
const int fs = CBuildConfig::buildTimestampAsVersionSegment(fromStringUtc(seg, "yyyyMMddHHmmss"));
|
||||
return QString::number(fs);
|
||||
// old schema: yMMddHHmm (9)
|
||||
if (seg.length() >= 9) { return QStringLiteral("0"); }
|
||||
return seg;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -87,17 +87,7 @@ namespace XSwiftBus
|
||||
|
||||
std::string CService::getVersionNumber() const
|
||||
{
|
||||
std::string version(XSWIFTBUS_VERSION);
|
||||
const std::string lastCommitTs(GIT_COMMIT_TS);
|
||||
|
||||
const long long lctsll = std::stoll(lastCommitTs); // at least 64bit
|
||||
// now we have to converto int
|
||||
// max 2147483647 (2^31 - 1)
|
||||
// 1MMddHHmm (years since 2010)
|
||||
const long long yearOffset = 201000000000;
|
||||
const int lctsInt = static_cast<int>(lctsll - yearOffset);
|
||||
version = version + "." + std::to_string(lctsInt);
|
||||
return version;
|
||||
return XSWIFTBUS_VERSION;
|
||||
}
|
||||
|
||||
std::string CService::getCommitHash() const
|
||||
|
||||
@@ -72,19 +72,7 @@ DEFINES += XPLM210=1
|
||||
DEFINES += XPMP_CLIENT_NAME=\\\"xswiftbus\\\"
|
||||
DEFINES += XPMP_CLIENT_LONGNAME=\\\"xswiftbus\\\"
|
||||
|
||||
win32: GIT_BIN = $$system($$(SYSTEMROOT)\system32\where git 2> nul)
|
||||
else: GIT_BIN = $$system(which git 2> /dev/null)
|
||||
|
||||
isEmpty(GIT_BIN) {
|
||||
GIT_HEAD_SHA1="<unknown>"
|
||||
GIT_COMMIT_TS="0"
|
||||
} else {
|
||||
GIT_HEAD_SHA1=$$system(git rev-parse --short HEAD)
|
||||
GIT_COMMIT_TS=$$system(git log -1 --date=format:'%Y%m%d%H%M' --pretty=format:%cd)
|
||||
}
|
||||
|
||||
DEFINES += XSWIFTBUS_VERSION=\\\"$$swiftConfig(version.full)\\\"
|
||||
DEFINES += GIT_COMMIT_TS=\\\"$$GIT_COMMIT_TS\\\"
|
||||
DEFINES += XSWIFTBUS_VERSION=\\\"$$swiftConfig(version.full).$$VER_REV\\\"
|
||||
|
||||
isEmpty(XSWIFTBUS_COMMIT): error(Missing XSWIFTBUS_COMMIT variable)
|
||||
DEFINES += XSWIFTBUS_COMMIT=\\\"$$XSWIFTBUS_COMMIT\\\"
|
||||
|
||||
Reference in New Issue
Block a user