Skip to content

Commit bbb9958

Browse files
committed
Add fallback to auxiliary legacy driver executable on '--disallow-use-new-driver'
With the swift-driver executable becoming the default target of 'swift' and 'swiftc' sumlinks, we need to allow for the prior mechanism afforded by this flag
1 parent 14226b3 commit bbb9958

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Sources/swift-driver/main.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212
import SwiftDriverExecution
1313
import SwiftDriver
14+
import SwiftOptions
1415
#if os(Windows)
1516
import CRT
1617
#elseif os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
@@ -65,6 +66,18 @@ do {
6566
}
6667
interruptSignalSource.resume()
6768

69+
// Fallback to legacy driver if forced to
70+
if CommandLine.arguments.contains(Option.disallowForwardingDriver.spelling) {
71+
if let legacyExecutablePath = Process.findExecutable(CommandLine.arguments[0] + "-legacy-driver"),
72+
localFileSystem.exists(legacyExecutablePath) {
73+
let legacyDriverCommand = [legacyExecutablePath.pathString] +
74+
CommandLine.arguments[1...]
75+
try exec(path: legacyExecutablePath.pathString, args: legacyDriverCommand)
76+
} else {
77+
throw Driver.Error.unknownOrMissingSubcommand(CommandLine.arguments[0] + "-legacy-driver")
78+
}
79+
}
80+
6881
if ProcessEnv.vars["SWIFT_ENABLE_EXPLICIT_MODULE"] != nil {
6982
CommandLine.arguments.append("-explicit-module-build")
7083
}

0 commit comments

Comments
 (0)