Skip to content

Commit 7e82541

Browse files
committed
Fix subcommand discovery
1 parent 4bd5495 commit 7e82541

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Sources/swift-driver/main.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ do {
3030
if case .subcommand(let subcommand) = mode {
3131
// We are running as a subcommand, try to find the subcommand adjacent to the executable we are running as.
3232
// If we didn't find the tool there, let the OS search for it.
33-
let subcommandPath = Process.findExecutable(arguments[0])?.parentDirectory.appending(component: subcommand)
34-
?? Process.findExecutable(subcommand)
33+
#if os(Windows)
34+
let filename = subcommand + ".exe"
35+
#else
36+
let filename = subcommand
37+
#endif
38+
let subcommandPath = Process.findExecutable(arguments[0])?.parentDirectory.appending(component: filename)
39+
?? Process.findExecutable(filename)
3540

3641
if subcommandPath == nil || !localFileSystem.exists(subcommandPath!) {
37-
fatalError("cannot find subcommand executable '\(subcommand)'")
42+
fatalError("cannot find subcommand executable '\(filename)'")
3843
}
3944

4045
// Execute the subcommand.

0 commit comments

Comments
 (0)