Skip to content

Commit 20e841f

Browse files
gmittertaciidgh
authored andcommitted
Add .exe to Windows binaries
1 parent b548d70 commit 20e841f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Sources/Workspace/UserToolchain.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ private let whichArgs: [String] = ["xcrun", "--find"]
1919
#else
2020
private let whichArgs = ["which"]
2121
#endif
22+
#if os(Windows)
23+
private let hostExecutableSuffix = ".exe"
24+
#else
25+
private let hostExecutableSuffix = ""
26+
#endif
2227

2328
/// Concrete object for manifest resource provider.
2429
public struct UserManifestResources: ManifestResourceProvider {
@@ -56,7 +61,7 @@ public final class UserToolchain: Toolchain {
5661

5762
/// Path of the `swift` interpreter.
5863
public var swiftInterpreter: AbsolutePath {
59-
return swiftCompiler.parentDirectory.appending(component: "swift")
64+
return swiftCompiler.parentDirectory.appending(component: "swift" + hostExecutableSuffix)
6065
}
6166

6267
/// Path to the xctest utility.
@@ -97,7 +102,7 @@ public final class UserToolchain: Toolchain {
97102
func validateCompiler(at path: AbsolutePath?) throws {
98103
guard let path = path else { return }
99104
guard localFileSystem.isExecutableFile(path) else {
100-
throw InvalidToolchainDiagnostic("could not find the `swiftc` at expected path \(path)")
105+
throw InvalidToolchainDiagnostic("could not find the `swiftc\(hostExecutableSuffix)` at expected path \(path)")
101106
}
102107
}
103108

@@ -112,13 +117,13 @@ public final class UserToolchain: Toolchain {
112117
// We require there is at least one valid swift compiler, either in the
113118
// bin dir or SWIFT_EXEC.
114119
let resolvedBinDirCompiler: AbsolutePath
115-
let binDirCompiler = binDir.appending(component: "swiftc")
120+
let binDirCompiler = binDir.appending(component: "swiftc" + hostExecutableSuffix)
116121
if localFileSystem.isExecutableFile(binDirCompiler) {
117122
resolvedBinDirCompiler = binDirCompiler
118123
} else if let SWIFT_EXEC = SWIFT_EXEC {
119124
resolvedBinDirCompiler = SWIFT_EXEC
120125
} else {
121-
throw InvalidToolchainDiagnostic("could not find the `swiftc` at expected path \(binDirCompiler)")
126+
throw InvalidToolchainDiagnostic("could not find the `swiftc\(hostExecutableSuffix)` at expected path \(binDirCompiler)")
122127
}
123128

124129
// The compiler for compilation tasks is SWIFT_EXEC or the bin dir compiler.
@@ -207,7 +212,7 @@ public final class UserToolchain: Toolchain {
207212
self.swiftCompiler = swiftCompilers.compile
208213

209214
// Look for llbuild in bin dir.
210-
llbuild = binDir.appending(component: "swift-build-tool")
215+
llbuild = binDir.appending(component: "swift-build-tool" + hostExecutableSuffix)
211216
guard localFileSystem.exists(llbuild) else {
212217
throw InvalidToolchainDiagnostic("could not find `llbuild` at expected path \(llbuild)")
213218
}

0 commit comments

Comments
 (0)