summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-08-03 18:03:12 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2020-08-19 15:11:44 +0200
commit77a02f18cddc7b7c09cfc49b50de9d5c6fd3c50f (patch)
treefe909d93db5a644c50cd4c6446bc3083d90637ce
parentd721300fe0c4ee45e6dfdea011d436896eba235d (diff)
Resolve SDK and deployment target OS from load command
Change-Id: Icce79186645f173b7f9be8ee6da0abed25cf3da0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 4e74bb48234f41c9d6306c7a3cd6835c2cd42348) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/corelib/kernel/qcore_mac.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp
index bef50d8d9b..9090d87be5 100644
--- a/src/corelib/kernel/qcore_mac.cpp
+++ b/src/corelib/kernel/qcore_mac.cpp
@@ -187,12 +187,30 @@ QOperatingSystemVersion QMacVersion::currentRuntime()
QMacVersion::VersionTuple QMacVersion::versionsForImage(const mach_header *machHeader)
{
- static auto makeVersionTuple = [](uint32_t dt, uint32_t sdk) {
+ static auto osForLoadCommand = [](uint32_t cmd) {
+ switch (cmd) {
+ case LC_VERSION_MIN_MACOSX: return QOperatingSystemVersion::MacOS;
+ case LC_VERSION_MIN_IPHONEOS: return QOperatingSystemVersion::IOS;
+ case LC_VERSION_MIN_TVOS: return QOperatingSystemVersion::TvOS;
+ case LC_VERSION_MIN_WATCHOS: return QOperatingSystemVersion::WatchOS;
+ default: return QOperatingSystemVersion::Unknown;
+ }
+ };
+
+ static auto osForPlatform = [](uint32_t platform) {
+ switch (platform) {
+ case 1: return QOperatingSystemVersion::MacOS;
+ case 2: return QOperatingSystemVersion::IOS;
+ case 3: return QOperatingSystemVersion::TvOS;
+ case 4: return QOperatingSystemVersion::WatchOS;
+ default: return QOperatingSystemVersion::Unknown;
+ }
+ };
+
+ static auto makeVersionTuple = [](uint32_t dt, uint32_t sdk, QOperatingSystemVersion::OSType osType) {
return qMakePair(
- QOperatingSystemVersion(QOperatingSystemVersion::currentType(),
- dt >> 16 & 0xffff, dt >> 8 & 0xff, dt & 0xff),
- QOperatingSystemVersion(QOperatingSystemVersion::currentType(),
- sdk >> 16 & 0xffff, sdk >> 8 & 0xff, sdk & 0xff)
+ QOperatingSystemVersion(osType, dt >> 16 & 0xffff, dt >> 8 & 0xff, dt & 0xff),
+ QOperatingSystemVersion(osType, sdk >> 16 & 0xffff, sdk >> 8 & 0xff, sdk & 0xff)
);
};
@@ -204,11 +222,11 @@ QMacVersion::VersionTuple QMacVersion::versionsForImage(const mach_header *machH
if (loadCommand->cmd == LC_VERSION_MIN_MACOSX || loadCommand->cmd == LC_VERSION_MIN_IPHONEOS
|| loadCommand->cmd == LC_VERSION_MIN_TVOS || loadCommand->cmd == LC_VERSION_MIN_WATCHOS) {
auto versionCommand = reinterpret_cast<version_min_command *>(loadCommand);
- return makeVersionTuple(versionCommand->version, versionCommand->sdk);
+ return makeVersionTuple(versionCommand->version, versionCommand->sdk, osForLoadCommand(loadCommand->cmd));
#if QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_13, __IPHONE_11_0, __TVOS_11_0, __WATCHOS_4_0)
} else if (loadCommand->cmd == LC_BUILD_VERSION) {
auto versionCommand = reinterpret_cast<build_version_command *>(loadCommand);
- return makeVersionTuple(versionCommand->minos, versionCommand->sdk);
+ return makeVersionTuple(versionCommand->minos, versionCommand->sdk, osForPlatform(versionCommand->platform));
#endif
}
commandCursor += loadCommand->cmdsize;