|
1 | | -//===--------------- Triple+Platforms.swift - Swift Platform Triples ------===// |
| 1 | +//===----------------------------------------------------------------------===// |
2 | 2 | // |
3 | | -// This source file is part of the Swift.org open source project |
| 3 | +// This source file is part of the Swift open source project |
4 | 4 | // |
5 | | -// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors |
| 5 | +// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors |
6 | 6 | // Licensed under Apache License v2.0 with Runtime Library Exception |
7 | 7 | // |
8 | | -// See https://swift.org/LICENSE.txt for license information |
9 | | -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 8 | +// See http://swift.org/LICENSE.txt for license information |
| 9 | +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
10 | 10 | // |
11 | 11 | //===----------------------------------------------------------------------===// |
12 | 12 |
|
@@ -199,7 +199,7 @@ extension Triple { |
199 | 199 | /// Not all combinations are valid; in particular, you cannot fetch a watchOS version |
200 | 200 | /// from an iOS/tvOS triple or vice versa. |
201 | 201 | public func version(for compatibilityPlatform: DarwinPlatform? = nil) |
202 | | - -> Triple.Version |
| 202 | + -> Triple.Version? |
203 | 203 | { |
204 | 204 | switch compatibilityPlatform ?? darwinPlatform! { |
205 | 205 | case .macOS: |
@@ -239,53 +239,6 @@ extension Triple { |
239 | 239 | } |
240 | 240 | } |
241 | 241 |
|
242 | | - // The Darwin platform version used for linking. |
243 | | - public var darwinLinkerPlatformVersion: Version { |
244 | | - precondition(self.os?.isDarwin ?? false) |
245 | | - switch darwinPlatform! { |
246 | | - case .macOS: |
247 | | - // The integrated driver falls back to `osVersion` for ivalid macOS |
248 | | - // versions, this decision might be worth revisiting. |
249 | | - let macVersion = _macOSVersion ?? osVersion |
250 | | - // The first deployment of arm64 for macOS is version 11 |
251 | | - if macVersion.major < 11 && arch == .aarch64 { |
252 | | - return Version(11, 0, 0) |
253 | | - } |
254 | | - |
255 | | - return macVersion |
256 | | - case .iOS(.catalyst): |
257 | | - // Mac Catalyst on arm was introduced with an iOS deployment target of |
258 | | - // 14.0; the linker doesn't want to see a deployment target before that. |
259 | | - if _iOSVersion.major < 14 && arch == .aarch64 { |
260 | | - return Version(14, 0, 0) |
261 | | - } |
262 | | - |
263 | | - // Mac Catalyst was introduced with an iOS deployment target of 13.1; |
264 | | - // the linker doesn't want to see a deployment target before that. |
265 | | - if _iOSVersion.major < 13 { |
266 | | - return Version(13, 1, 0) |
267 | | - } |
268 | | - |
269 | | - return _iOSVersion |
270 | | - case .iOS(.device), .iOS(.simulator), .tvOS(_): |
271 | | - // The first deployment of arm64 simulators is iOS/tvOS 14.0; |
272 | | - // the linker doesn't want to see a deployment target before that. |
273 | | - if _isSimulatorEnvironment && _iOSVersion.major < 14 && arch == .aarch64 { |
274 | | - return Version(14, 0, 0) |
275 | | - } |
276 | | - |
277 | | - return _iOSVersion |
278 | | - case .watchOS(_): |
279 | | - // The first deployment of arm64 simulators is watchOS 7; |
280 | | - // the linker doesn't want to see a deployment target before that. |
281 | | - if _isSimulatorEnvironment && osVersion.major < 7 && arch == .aarch64 { |
282 | | - return Version(7, 0, 0) |
283 | | - } |
284 | | - |
285 | | - return osVersion |
286 | | - } |
287 | | - } |
288 | | - |
289 | 242 | /// The platform name, i.e. the name clang uses to identify this target in its |
290 | 243 | /// resource directory. |
291 | 244 | /// |
@@ -409,7 +362,8 @@ extension Triple { |
409 | 362 | case .unavailable: |
410 | 363 | return false |
411 | 364 | case .available(let introducedVersion): |
412 | | - return version(for: darwinPlatform) >= introducedVersion |
| 365 | + guard let tripleVersion = version(for: darwinPlatform) else { return false } |
| 366 | + return tripleVersion >= introducedVersion |
413 | 367 | case .availableInAllVersions: |
414 | 368 | return true |
415 | 369 | } |
|
0 commit comments