@@ -191,11 +191,7 @@ extension Toolchain {
191
191
192
192
/// - Returns: String in the form of: `SWIFT_DRIVER_TOOLNAME_EXEC`
193
193
private func envVarName( for toolName: String ) -> String {
194
- var lookupName = toolName
195
- #if os(Windows)
196
- lookupName = lookupName. replacingOccurrences ( of: " .exe " , with: " " )
197
- #endif
198
- lookupName = lookupName. replacingOccurrences ( of: " - " , with: " _ " ) . uppercased ( )
194
+ let lookupName = toolName. replacingOccurrences ( of: " - " , with: " _ " ) . uppercased ( )
199
195
return " SWIFT_DRIVER_ \( lookupName) _EXEC "
200
196
}
201
197
@@ -209,9 +205,9 @@ extension Toolchain {
209
205
210
206
/// Looks for the executable in the `SWIFT_DRIVER_TOOLNAME_EXEC` environment variable, if found nothing,
211
207
/// looks in the `executableDir`, `xcrunFind` or in the `searchPaths`.
212
- /// - Parameter executable: executable to look for [i.e. `swift`].
208
+ /// - Parameter executable: executable to look for [i.e. `swift`]. Executable suffix (eg. `.exe`) should be omitted.
213
209
func lookup( executable: String ) throws -> AbsolutePath {
214
- if let overrideString = envVar ( forExecutable: executableName ( executable) ) {
210
+ if let overrideString = envVar ( forExecutable: executable) {
215
211
return try AbsolutePath ( validating: overrideString)
216
212
} else if let toolDir = toolDirectory,
217
213
let path = lookupExecutablePath ( filename: executableName ( executable) , searchPaths: [ toolDir] ) {
@@ -221,7 +217,7 @@ extension Toolchain {
221
217
return path
222
218
} else if let path = try ? xcrunFind ( executable: executableName ( executable) ) {
223
219
return path
224
- } else if ![ " swift-frontend " , " swift " , " swift-frontend.exe " , " swift.exe " ] . contains ( executable) ,
220
+ } else if ![ " swift-frontend " , " swift " ] . contains ( executable) ,
225
221
let parentDirectory = try ? getToolPath ( . swiftCompiler) . parentDirectory,
226
222
parentDirectory != executableDir,
227
223
let path = lookupExecutablePath ( filename: executableName ( executable) , searchPaths: [ parentDirectory] ) {
@@ -230,14 +226,14 @@ extension Toolchain {
230
226
return path
231
227
} else if let path = lookupExecutablePath ( filename: executableName ( executable) , searchPaths: searchPaths) {
232
228
return path
233
- } else if executable == executableName ( " swift-frontend " ) {
229
+ } else if executable == " swift-frontend " {
234
230
// Temporary shim: fall back to looking for "swift" before failing.
235
- return try lookup ( executable: executableName ( " swift " ) )
231
+ return try lookup ( executable: " swift " )
236
232
} else if fallbackToExecutableDefaultPath {
237
233
if self is WindowsToolchain {
238
234
return try getToolPath ( . swiftCompiler)
239
235
. parentDirectory
240
- . appending ( component: executable)
236
+ . appending ( component: executableName ( executable) )
241
237
} else {
242
238
return AbsolutePath ( " /usr/bin/ " + executable)
243
239
}
0 commit comments