@@ -138,6 +138,9 @@ public struct SwiftSDK: Equatable {
138
138
/// The architectures to build for. We build for host architecture if this is empty.
139
139
public var architectures : [ String ] ? = nil
140
140
141
+ /// Whether or not the receiver supports testing.
142
+ public let supportsTesting : Bool
143
+
141
144
/// Root directory path of the SDK used to compile for the target triple.
142
145
@available ( * , deprecated, message: " use `pathsConfiguration.sdkRootPath` instead " )
143
146
public var sdk : AbsolutePath ? {
@@ -411,12 +414,14 @@ public struct SwiftSDK: Equatable {
411
414
hostTriple: Triple ? = nil ,
412
415
targetTriple: Triple ? = nil ,
413
416
toolset: Toolset ,
414
- pathsConfiguration: PathsConfiguration
417
+ pathsConfiguration: PathsConfiguration ,
418
+ supportsTesting: Bool = true
415
419
) {
416
420
self . hostTriple = hostTriple
417
421
self . targetTriple = targetTriple
418
422
self . toolset = toolset
419
423
self . pathsConfiguration = pathsConfiguration
424
+ self . supportsTesting = supportsTesting
420
425
}
421
426
422
427
/// Returns the bin directory for the host.
@@ -447,7 +452,8 @@ public struct SwiftSDK: Equatable {
447
452
public static func hostSwiftSDK(
448
453
_ binDir: AbsolutePath ? = nil ,
449
454
originalWorkingDirectory: AbsolutePath ? = nil ,
450
- environment: [ String : String ] = ProcessEnv . vars
455
+ environment: [ String : String ] = ProcessEnv . vars,
456
+ observabilityScope: ObservabilityScope ? = nil
451
457
) throws -> SwiftSDK {
452
458
let originalWorkingDirectory = originalWorkingDirectory ?? localFileSystem. currentWorkingDirectory
453
459
// Select the correct binDir.
@@ -482,14 +488,23 @@ public struct SwiftSDK: Equatable {
482
488
#endif
483
489
484
490
// Compute common arguments for clang and swift.
491
+ let supportsTesting : Bool
485
492
var extraCCFlags : [ String ] = [ ]
486
493
var extraSwiftCFlags : [ String ] = [ ]
487
494
#if os(macOS)
488
- let sdkPaths = try SwiftSDK . sdkPlatformFrameworkPaths ( environment: environment)
489
- extraCCFlags += [ " -F " , sdkPaths. fwk. pathString]
490
- extraSwiftCFlags += [ " -F " , sdkPaths. fwk. pathString]
491
- extraSwiftCFlags += [ " -I " , sdkPaths. lib. pathString]
492
- extraSwiftCFlags += [ " -L " , sdkPaths. lib. pathString]
495
+ do {
496
+ let sdkPaths = try SwiftSDK . sdkPlatformFrameworkPaths ( environment: environment)
497
+ extraCCFlags += [ " -F " , sdkPaths. fwk. pathString]
498
+ extraSwiftCFlags += [ " -F " , sdkPaths. fwk. pathString]
499
+ extraSwiftCFlags += [ " -I " , sdkPaths. lib. pathString]
500
+ extraSwiftCFlags += [ " -L " , sdkPaths. lib. pathString]
501
+ supportsTesting = true
502
+ } catch {
503
+ supportsTesting = false
504
+ observabilityScope? . emit ( warning: " could not determine XCTest paths: \( error) " )
505
+ }
506
+ #else
507
+ supportsTesting = true
493
508
#endif
494
509
495
510
#if !os(Windows)
@@ -504,7 +519,8 @@ public struct SwiftSDK: Equatable {
504
519
] ,
505
520
rootPaths: [ binDir]
506
521
) ,
507
- pathsConfiguration: . init( sdkRootPath: sdkPath)
522
+ pathsConfiguration: . init( sdkRootPath: sdkPath) ,
523
+ supportsTesting: supportsTesting
508
524
)
509
525
}
510
526
0 commit comments