diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-08-03 18:03:12 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-08-04 13:28:33 +0200 |
commit | 4e74bb48234f41c9d6306c7a3cd6835c2cd42348 (patch) | |
tree | e6c28569b7b501734e56b4817ab2b35ade7e0021 /src/corelib/kernel | |
parent | c580a5cdd452cd1a0ef4ebd7f618df72ef67a230 (diff) |
Resolve SDK and deployment target OS from load command
Pick-to: 5.15
Pick-to: 5.12
Change-Id: Icce79186645f173b7f9be8ee6da0abed25cf3da0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcore_mac.mm | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/corelib/kernel/qcore_mac.mm b/src/corelib/kernel/qcore_mac.mm index b94b06adb4..692c9fa6b5 100644 --- a/src/corelib/kernel/qcore_mac.mm +++ b/src/corelib/kernel/qcore_mac.mm @@ -566,12 +566,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) ); }; @@ -581,11 +599,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; |