From 340dad19a336e540eb56d65737f1937964ca6798 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 9 Dec 2017 19:35:03 +0100 Subject: [PATCH] Ref T203, platform guessing no longer required here (=> CPlatform) Timestamp conversion to 4th segment can be used from elsewhere --- src/blackconfig/buildconfig.cpp | 36 +++++++++++++++++---------------- src/blackconfig/buildconfig.h | 7 +++---- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/blackconfig/buildconfig.cpp b/src/blackconfig/buildconfig.cpp index c22012daf..b6f621070 100644 --- a/src/blackconfig/buildconfig.cpp +++ b/src/blackconfig/buildconfig.cpp @@ -238,6 +238,25 @@ namespace BlackConfig 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 converto int + // max 2147483647 (2^31 - 1) + // 1MMddHHmm (years since 2010) + // yyyyMMddHHmm + const long long yearOffset = 201000000000; + const int btsInt = btsll - yearOffset; + return btsInt; + } + return 0; // intentionally 0 => 0.7.3.0 <- + } + const QStringList &CBuildConfig::getBuildAbiParts() { static const QStringList parts = QSysInfo::buildAbi().split('-'); @@ -258,23 +277,6 @@ namespace BlackConfig static const int bws = buildWordSizeImpl(); return bws; } - - QString CBuildConfig::guessMyPlatformString() - { - // 32/64 only matters on Windows - // 64 is default - QString p; - QString ws = (buildWordSize() == 32) ? "32" : "64"; - if (BlackConfig::CBuildConfig::isRunningOnWindowsNtPlatform()) - { - p = "win-" + ws; - } - else if (BlackConfig::CBuildConfig::isRunningOnMacOSPlatform()) { p = "macos-64"; } - else if (BlackConfig::CBuildConfig::isRunningOnLinuxPlatform()) { p = "linux-64"; } - - if (!p.isEmpty() && BlackConfig::CBuildConfig::isVatsimVersion()) { p += "-vatsim"; } - return p; - } } // ns //! \endcond diff --git a/src/blackconfig/buildconfig.h b/src/blackconfig/buildconfig.h index d7e6a7b0d..3af2a8fa5 100644 --- a/src/blackconfig/buildconfig.h +++ b/src/blackconfig/buildconfig.h @@ -140,14 +140,13 @@ namespace BlackConfig //! 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(); - //! The platform string used for updates etc. - //! \remark ideally no such guess would be needed, but it is used as default value - static QString guessMyPlatformString(); - private: //! Major version static int versionMajor(); // defined in buildconfig_gen.cpp.in