Skip to content

Commit a116a47

Browse files
committed
[PackageModel] Windows: Make swift-testing configuration optional
This allows us to support older Windows toolchains with newer swift package manager even the project only uses XCTest.
1 parent 47120a0 commit a116a47

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

Sources/PackageModel/UserToolchain.swift

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -546,23 +546,25 @@ public final class UserToolchain: Toolchain {
546546
xctest.append(contentsOf: ["-L", implib.parentDirectory.pathString])
547547
}
548548

549-
let swiftTestingInstallation: AbsolutePath =
550-
platform.appending("Developer")
551-
.appending("Library")
552-
.appending("Testing-\(info.defaults.swiftTestingVersion)")
553-
554-
swiftTesting = try [
555-
"-I",
556-
AbsolutePath(
557-
validating: "usr/lib/swift/windows",
558-
relativeTo: swiftTestingInstallation
559-
).pathString,
560-
"-L",
561-
AbsolutePath(
562-
validating: "usr/lib/swift/windows/\(triple.archName)",
563-
relativeTo: swiftTestingInstallation
564-
).pathString
565-
]
549+
if let swiftTestingVersion = info.defaults.swiftTestingVersion {
550+
let swiftTestingInstallation: AbsolutePath =
551+
platform.appending("Developer")
552+
.appending("Library")
553+
.appending("Testing-\(swiftTestingVersion)")
554+
555+
swiftTesting = try [
556+
"-I",
557+
AbsolutePath(
558+
validating: "usr/lib/swift/windows",
559+
relativeTo: swiftTestingInstallation
560+
).pathString,
561+
"-L",
562+
AbsolutePath(
563+
validating: "usr/lib/swift/windows/\(triple.archName)",
564+
relativeTo: swiftTestingInstallation
565+
).pathString
566+
]
567+
}
566568

567569
extraSwiftCFlags = info.defaults.extraSwiftCFlags ?? []
568570
}
@@ -1019,10 +1021,14 @@ public final class UserToolchain: Toolchain {
10191021
return nil
10201022
}
10211023

1024+
guard let swiftTestingVersion = info.defaults.swiftTestingVersion else {
1025+
return nil
1026+
}
1027+
10221028
let swiftTesting: AbsolutePath =
10231029
platform.appending("Developer")
10241030
.appending("Library")
1025-
.appending("Testing-\(info.defaults.swiftTestingVersion)")
1031+
.appending("Testing-\(swiftTestingVersion)")
10261032

10271033
let binPath: AbsolutePath? = switch triple.arch {
10281034
case .x86_64: // amd64 x86_64 x86_64h

Sources/PackageModel/WindowsToolchainInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public struct WindowsPlatformInfo {
8080

8181
/// SWIFT_TESTING_VERSION
8282
/// specifies the version string of the bundled swift-testing.
83-
public let swiftTestingVersion: String
83+
public let swiftTestingVersion: String?
8484

8585
/// SWIFTC_FLAGS
8686
/// Specifies extra flags to pass to swiftc from Swift Package Manager.

0 commit comments

Comments
 (0)