mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Align the full version schema across all artifacts
Summary: The version number used for packaging symbols and xswiftbus was not the full one including the timestamp. This change adds the last commit timestamp (in contrast to the build timestamp used before) as regular part of the version number. This helps us to also keep the version number consistent with the content across all installers. The version number will change only, if the last commit was modified and not with each different build. In the end, all jenkins jobs building from the same commit should produce artifacts with the same version everywhere. ref T204 Reviewers: #swift_pilot_client, kbasan Reviewed By: #swift_pilot_client, kbasan Subscribers: jenkins Maniphest Tasks: T204 Differential Revision: https://dev.swift-project.org/D68
This commit is contained in:
@@ -22,8 +22,10 @@ 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)
|
||||
}
|
||||
|
||||
load(common_post)
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace BlackConfig
|
||||
|
||||
const QVersionNumber &CBuildConfig::getVersion()
|
||||
{
|
||||
static const QVersionNumber v { versionMajor(), versionMinor(), versionMicro(), buildTimestampAsVersionSegment(buildTimestamp()) };
|
||||
static const QVersionNumber v { versionMajor(), versionMinor(), versionMicro(), lastCommitTimestampAsVersionSegment(lastCommitTimestamp()) };
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -220,20 +220,20 @@ namespace BlackConfig
|
||||
return dt;
|
||||
}
|
||||
|
||||
int CBuildConfig::buildTimestampAsVersionSegment(const QDateTime &buildTimestamp)
|
||||
int CBuildConfig::lastCommitTimestampAsVersionSegment(const QDateTime &lastCommitTimestamp)
|
||||
{
|
||||
if (buildTimestamp.isValid())
|
||||
if (lastCommitTimestamp.isValid())
|
||||
{
|
||||
const QString bts = buildTimestamp.toString("yyyyMMddHHmm");
|
||||
const QString bts = lastCommitTimestamp.toString("yyyyMMddHHmm");
|
||||
bool ok;
|
||||
const long long btsll = bts.toLongLong(&ok); // at least 64bit
|
||||
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 btsInt = btsll - yearOffset;
|
||||
return btsInt;
|
||||
const int lctsInt = lctsll - yearOffset;
|
||||
return lctsInt;
|
||||
}
|
||||
return 0; // intentionally 0 => 0.7.3.0 <-
|
||||
}
|
||||
|
||||
@@ -119,6 +119,9 @@ 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();
|
||||
|
||||
@@ -131,8 +134,8 @@ namespace BlackConfig
|
||||
//! Version as QVersionNumber
|
||||
static const QString &getVersionString();
|
||||
|
||||
//! Turns build timestamp into a version number
|
||||
static int buildTimestampAsVersionSegment(const QDateTime &buildTimestamp);
|
||||
//! 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();
|
||||
|
||||
@@ -161,6 +161,22 @@ 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::versionMajor() { return $$BLACK_VER_MAJ; }
|
||||
int BlackConfig::CBuildConfig::versionMinor() { return $$BLACK_VER_MIN; }
|
||||
int BlackConfig::CBuildConfig::versionMicro() { return $$BLACK_VER_MIC; }
|
||||
|
||||
@@ -253,10 +253,7 @@ namespace BlackMisc
|
||||
return QVersionNumber::fromString(v);
|
||||
}
|
||||
|
||||
const QString versionTimestampString = BlackMisc::digitOnlyString(ts1Match.captured(0));
|
||||
const QDateTime versionTimestamp = QDateTime::fromString(versionTimestampString, "yyyyMMddHHmmss");
|
||||
const QString lastSegment = QString::number(CBuildConfig::buildTimestampAsVersionSegment(versionTimestamp));
|
||||
|
||||
const QString lastSegment = BlackMisc::digitOnlyString(ts1Match.captured(0));
|
||||
v += lastSegment;
|
||||
return QVersionNumber::fromString(v);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user