mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +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; }
|
||||
|
||||
Reference in New Issue
Block a user