Skip to content

Commit 64d4b57

Browse files
committed
Add visionOS to test support code
Add some missing visionOS entries to generic test support code. Also, remove other platforms instead of adding visionOS in another place, since it can simply be looked up dynamically.
1 parent 2eafd3b commit 64d4b57

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

Sources/SWBCore/Settings/BuiltinMacros.swift

+3-8
Original file line numberDiff line numberDiff line change
@@ -2793,21 +2793,16 @@ extension Diagnostic.Location {
27932793

27942794
extension BuildVersion.Platform {
27952795
public func deploymentTargetSettingName(infoLookup: (any PlatformInfoLookup)?) -> String {
2796+
// We need to special-case MACOSX_DEPLOYMENT_TARGET/IPHONEOS_DEPLOYMENT_TARGET because of zippering (see ``CommandProducer/lookupPlatformInfo(platform:)``)
27962797
switch self {
27972798
case .macOS:
27982799
return BuiltinMacros.MACOSX_DEPLOYMENT_TARGET.name
2799-
case .iOS, .iOSSimulator, .macCatalyst:
2800+
case .macCatalyst:
28002801
return BuiltinMacros.IPHONEOS_DEPLOYMENT_TARGET.name
2801-
case .tvOS, .tvOSSimulator:
2802-
return BuiltinMacros.TVOS_DEPLOYMENT_TARGET.name
2803-
case .watchOS, .watchOSSimulator:
2804-
return BuiltinMacros.WATCHOS_DEPLOYMENT_TARGET.name
2805-
case .driverKit:
2806-
return BuiltinMacros.DRIVERKIT_DEPLOYMENT_TARGET.name
28072802
default:
28082803
guard let infoProvider = infoLookup?.lookupPlatformInfo(platform: self),
28092804
let dtsn = infoProvider.deploymentTargetSettingName else {
2810-
fatalError("external Mach-O based platforms must provide a deployment target setting name")
2805+
fatalError("Mach-O based platforms must provide a deployment target setting name")
28112806
}
28122807
return dtsn
28132808
}

Sources/SWBCore/TaskGeneration.swift

+2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ extension CommandProducer {
315315
}
316316

317317
/// Lookup the platform info for this producer
318+
///
319+
/// - warning: Because this implementation doesn't actually inspect the platform that's passed in, it can provide the "wrong" answer in cases of zippering on macOS.
318320
public func lookupPlatformInfo(platform: BuildVersion.Platform) -> (any PlatformInfoProvider)? {
319321
return sdkVariant
320322
}

Sources/SWBTestSupport/LibraryGeneration.swift

+6
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,16 @@ extension BuildVersion.Platform {
397397
return "appletvos"
398398
case .watchOS:
399399
return "watchos"
400+
case .xrOS:
401+
return "xros"
400402
case .iOSSimulator:
401403
return "iphonesimulator"
402404
case .tvOSSimulator:
403405
return "appletvsimulator"
404406
case .watchOSSimulator:
405407
return "watchsimulator"
408+
case .xrOSSimulator:
409+
return "xrsimulator"
406410
case .driverKit:
407411
return "driverkit"
408412
default:
@@ -423,6 +427,8 @@ extension BuildVersion.Platform {
423427
return targetTripleString(arch: arch, deploymentTarget: Version(13), infoLookup: infoLookup)
424428
case .watchOS, .watchOSSimulator:
425429
return targetTripleString(arch: arch, deploymentTarget: Version(6), infoLookup: infoLookup)
430+
case .xrOS, .xrOSSimulator:
431+
return targetTripleString(arch: arch, deploymentTarget: Version(1), infoLookup: infoLookup)
426432
case .driverKit:
427433
return targetTripleString(arch: arch, deploymentTarget: Version(19), infoLookup: infoLookup)
428434
default:

Sources/SWBTestSupport/MachO.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extension BuildVersion.Platform {
3333
/// The vendor of the platform, suitable for use as the OS field of an LLVM target triple.
3434
package func vendor(infoLookup: any PlatformInfoLookup) -> String {
3535
switch self {
36-
case .macOS, .iOS, .iOSSimulator, .macCatalyst, .tvOS, .tvOSSimulator, .watchOS, .watchOSSimulator, .driverKit:
36+
case .macOS, .iOS, .iOSSimulator, .macCatalyst, .tvOS, .tvOSSimulator, .watchOS, .watchOSSimulator, .xrOS, .xrOSSimulator, .driverKit:
3737
return "apple"
3838
default:
3939
return infoLookup.lookupPlatformInfo(platform: self)?.llvmTargetTripleVendor ?? "unknown"
@@ -51,6 +51,8 @@ extension BuildVersion.Platform {
5151
return "tvos"
5252
case .watchOS, .watchOSSimulator:
5353
return "watchos"
54+
case .xrOS, .xrOSSimulator:
55+
return "xros"
5456
case .driverKit:
5557
return "driverkit"
5658
default:
@@ -68,7 +70,7 @@ extension BuildVersion.Platform {
6870
switch self {
6971
case .macCatalyst:
7072
return "macabi"
71-
case .iOSSimulator, .tvOSSimulator, .watchOSSimulator:
73+
case .iOSSimulator, .tvOSSimulator, .watchOSSimulator, .xrOSSimulator:
7274
return "simulator"
7375
default:
7476
guard let environment = infoLookup.lookupPlatformInfo(platform: self)?.llvmTargetTripleEnvironment, !environment.isEmpty else {

0 commit comments

Comments
 (0)