Skip to content

Commit 2d61fdd

Browse files
authored
Merge pull request #1744 from tshortli/revert-1741
Revert "swift-driver: correct the legacy driver path construction" This is breaking PR testing, so we should revert it.
2 parents 44239e6 + 3c03433 commit 2d61fdd

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Sources/swift-driver/main.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import Android
2525
#endif
2626

2727
import Dispatch
28-
import Foundation
2928

3029
#if os(Windows)
3130
import WinSDK
@@ -74,18 +73,13 @@ do {
7473
// Fallback to legacy driver if forced to
7574
if CommandLine.arguments.contains(Option.disallowForwardingDriver.spelling) ||
7675
ProcessEnv.vars["SWIFT_USE_OLD_DRIVER"] != nil {
77-
let executable: URL = URL(fileURLWithPath: CommandLine.arguments[0])
78-
let legacyExecutablePath: URL =
79-
executable.deletingLastPathComponent()
80-
.appendingPathComponent("\(executable.deletingPathExtension().lastPathComponent)-legacy-driver")
81-
.appendingPathExtension(executable.pathExtension)
82-
let path: String = legacyExecutablePath.withUnsafeFileSystemRepresentation { String(cString: $0!) }
83-
84-
if localFileSystem.exists(AbsolutePath(path)) {
85-
let legacyDriverCommand = [path] + CommandLine.arguments[1...]
86-
try exec(path: path, args: legacyDriverCommand)
76+
if let legacyExecutablePath = Process.findExecutable(CommandLine.arguments[0] + "-legacy-driver"),
77+
localFileSystem.exists(legacyExecutablePath) {
78+
let legacyDriverCommand = [legacyExecutablePath.pathString] +
79+
CommandLine.arguments[1...]
80+
try exec(path: legacyExecutablePath.pathString, args: legacyDriverCommand)
8781
} else {
88-
throw Driver.Error.unknownOrMissingSubcommand(legacyExecutablePath.lastPathComponent)
82+
throw Driver.Error.unknownOrMissingSubcommand(CommandLine.arguments[0] + "-legacy-driver")
8983
}
9084
}
9185

0 commit comments

Comments
 (0)