Skip to content

Commit 1a6ff93

Browse files
authored
Merge pull request #90 from owenv/remove-integrated-repl
Remove support for the integrated repl
2 parents 693512d + 09bd4bb commit 1a6ff93

File tree

4 files changed

+24
-43
lines changed

4 files changed

+24
-43
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ public enum ModuleOutput: Equatable {
4242

4343
/// The Swift driver.
4444
public struct Driver {
45-
public enum Error: Swift.Error, DiagnosticData {
45+
public enum Error: Swift.Error, Equatable, DiagnosticData {
4646
case invalidDriverName(String)
4747
case invalidInput(String)
4848
case noJobsPassedToDriverFromEmptyInputFileList
4949
case relativeFrontendPath(String)
5050
case subcommandPassedToDriver
51+
case integratedReplRemoved
5152

5253
public var description: String {
5354
switch self {
@@ -62,6 +63,8 @@ public struct Driver {
6263
return "relative frontend path: \(path)"
6364
case .subcommandPassedToDriver:
6465
return "subcommand passed to driver"
66+
case .integratedReplRemoved:
67+
return "Compiler-internal integrated REPL has been removed; use the LLDB-enhanced REPL instead."
6568
}
6669
}
6770
}
@@ -295,7 +298,7 @@ public struct Driver {
295298
}
296299

297300
// Determine the compilation mode.
298-
self.compilerMode = Self.computeCompilerMode(&parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)
301+
self.compilerMode = try Self.computeCompilerMode(&parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)
299302

300303
// Figure out the primary outputs from the driver.
301304
(self.compilerOutputType, self.linkerOutputType) = Self.determinePrimaryOutputs(&parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)
@@ -759,16 +762,19 @@ extension Driver {
759762
_ parsedOptions: inout ParsedOptions,
760763
driverKind: DriverKind,
761764
diagnosticsEngine: DiagnosticsEngine
762-
) -> CompilerMode {
765+
) throws -> CompilerMode {
763766
// Some output flags affect the compiler mode.
764767
if let outputOption = parsedOptions.getLast(in: .modes) {
765768
switch outputOption.option {
766769
case .emitPch, .emitImportedModules:
767770
return .singleCompile
768771

769-
case .repl, .deprecatedIntegratedRepl, .lldbRepl:
772+
case .repl, .lldbRepl:
770773
return .repl
771774

775+
case .deprecatedIntegratedRepl:
776+
throw Error.integratedReplRemoved
777+
772778
case .emitPcm:
773779
return .compilePCM
774780

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ extension Driver {
196196
}
197197
}
198198

199-
// Repl Jobs may include -module-name depending on the selected REPL (LLDB or integrated).
199+
// Repl Jobs shouldn't include -module-name.
200200
if compilerMode != .repl {
201201
commandLine.appendFlags("-module-name", moduleName)
202202
}

Sources/SwiftDriver/Jobs/ReplJob.swift

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,15 @@ extension Driver {
2020
try commandLine.appendLast(.importObjcHeader, from: &parsedOptions)
2121
try commandLine.appendAll(.l, .framework, .L, from: &parsedOptions)
2222

23-
// Look for -lldb-repl or -deprecated-integrated-repl to determine which
24-
// REPL to use. If neither is provided, prefer LLDB if it can be found.
25-
if parsedOptions.hasFlag(positive: .lldbRepl,
26-
negative: .deprecatedIntegratedRepl,
27-
default: (try? toolchain.getToolPath(.lldb)) != nil) {
28-
// Squash important frontend options into a single argument for LLDB.
29-
let lldbArg = "--repl=\(commandLine.joinedArguments)"
30-
return Job(
31-
kind: .repl,
32-
tool: .absolute(try toolchain.getToolPath(.lldb)),
33-
commandLine: [Job.ArgTemplate.flag(lldbArg)],
34-
inputs: [],
35-
outputs: [],
36-
requiresInPlaceExecution: true
37-
)
38-
} else {
39-
// Invoke the integrated REPL, which is part of the frontend.
40-
commandLine = [.flag("-frontend"), .flag("-repl")] + commandLine
41-
commandLine.appendFlags("-module-name", moduleName)
42-
return Job(
43-
kind: .repl,
44-
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
45-
commandLine: commandLine,
46-
inputs: [],
47-
outputs: [],
48-
requiresInPlaceExecution: true
49-
)
50-
}
23+
// Squash important frontend options into a single argument for LLDB.
24+
let lldbArg = "--repl=\(commandLine.joinedArguments)"
25+
return Job(
26+
kind: .repl,
27+
tool: .absolute(try toolchain.getToolPath(.lldb)),
28+
commandLine: [Job.ArgTemplate.flag(lldbArg)],
29+
inputs: [],
30+
outputs: [],
31+
requiresInPlaceExecution: true
32+
)
5133
}
5234
}

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,16 +1190,9 @@ final class SwiftDriverTests: XCTestCase {
11901190
}
11911191

11921192
do {
1193-
var driver = try Driver(args: ["swift", "-deprecated-integrated-repl"])
1194-
let plannedJobs = try driver.planBuild()
1195-
XCTAssertEqual(plannedJobs.count, 1)
1196-
let replJob = plannedJobs.first!
1197-
XCTAssertTrue(replJob.tool.name.contains("swift"))
1198-
XCTAssertTrue(replJob.requiresInPlaceExecution)
1199-
XCTAssertTrue(replJob.commandLine.count >= 2)
1200-
XCTAssertEqual(replJob.commandLine[0], .flag("-frontend"))
1201-
XCTAssertEqual(replJob.commandLine[1], .flag("-repl"))
1202-
XCTAssert(replJob.commandLine.contains(.flag("-module-name")))
1193+
XCTAssertThrowsError(try Driver(args: ["swift", "-deprecated-integrated-repl"])) {
1194+
XCTAssertEqual($0 as? Driver.Error, Driver.Error.integratedReplRemoved)
1195+
}
12031196
}
12041197

12051198
do {

0 commit comments

Comments
 (0)