Skip to content

Remove support for the integrated repl #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ public enum ModuleOutput: Equatable {

/// The Swift driver.
public struct Driver {
public enum Error: Swift.Error, DiagnosticData {
public enum Error: Swift.Error, Equatable, DiagnosticData {
case invalidDriverName(String)
case invalidInput(String)
case noJobsPassedToDriverFromEmptyInputFileList
case relativeFrontendPath(String)
case subcommandPassedToDriver
case integratedReplRemoved

public var description: String {
switch self {
Expand All @@ -62,6 +63,8 @@ public struct Driver {
return "relative frontend path: \(path)"
case .subcommandPassedToDriver:
return "subcommand passed to driver"
case .integratedReplRemoved:
return "Compiler-internal integrated REPL has been removed; use the LLDB-enhanced REPL instead."
}
}
}
Expand Down Expand Up @@ -295,7 +298,7 @@ public struct Driver {
}

// Determine the compilation mode.
self.compilerMode = Self.computeCompilerMode(&parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)
self.compilerMode = try Self.computeCompilerMode(&parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)

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

case .repl, .deprecatedIntegratedRepl, .lldbRepl:
case .repl, .lldbRepl:
return .repl

case .deprecatedIntegratedRepl:
throw Error.integratedReplRemoved

case .emitPcm:
return .compilePCM

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ extension Driver {
}
}

// Repl Jobs may include -module-name depending on the selected REPL (LLDB or integrated).
// Repl Jobs shouldn't include -module-name.
if compilerMode != .repl {
commandLine.appendFlags("-module-name", moduleName)
}
Expand Down
38 changes: 10 additions & 28 deletions Sources/SwiftDriver/Jobs/ReplJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,15 @@ extension Driver {
try commandLine.appendLast(.importObjcHeader, from: &parsedOptions)
try commandLine.appendAll(.l, .framework, .L, from: &parsedOptions)

// Look for -lldb-repl or -deprecated-integrated-repl to determine which
// REPL to use. If neither is provided, prefer LLDB if it can be found.
if parsedOptions.hasFlag(positive: .lldbRepl,
negative: .deprecatedIntegratedRepl,
default: (try? toolchain.getToolPath(.lldb)) != nil) {
// Squash important frontend options into a single argument for LLDB.
let lldbArg = "--repl=\(commandLine.joinedArguments)"
return Job(
kind: .repl,
tool: .absolute(try toolchain.getToolPath(.lldb)),
commandLine: [Job.ArgTemplate.flag(lldbArg)],
inputs: [],
outputs: [],
requiresInPlaceExecution: true
)
} else {
// Invoke the integrated REPL, which is part of the frontend.
commandLine = [.flag("-frontend"), .flag("-repl")] + commandLine
commandLine.appendFlags("-module-name", moduleName)
return Job(
kind: .repl,
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: [],
outputs: [],
requiresInPlaceExecution: true
)
}
// Squash important frontend options into a single argument for LLDB.
let lldbArg = "--repl=\(commandLine.joinedArguments)"
return Job(
kind: .repl,
tool: .absolute(try toolchain.getToolPath(.lldb)),
commandLine: [Job.ArgTemplate.flag(lldbArg)],
inputs: [],
outputs: [],
requiresInPlaceExecution: true
)
}
}
13 changes: 3 additions & 10 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1190,16 +1190,9 @@ final class SwiftDriverTests: XCTestCase {
}

do {
var driver = try Driver(args: ["swift", "-deprecated-integrated-repl"])
let plannedJobs = try driver.planBuild()
XCTAssertEqual(plannedJobs.count, 1)
let replJob = plannedJobs.first!
XCTAssertTrue(replJob.tool.name.contains("swift"))
XCTAssertTrue(replJob.requiresInPlaceExecution)
XCTAssertTrue(replJob.commandLine.count >= 2)
XCTAssertEqual(replJob.commandLine[0], .flag("-frontend"))
XCTAssertEqual(replJob.commandLine[1], .flag("-repl"))
XCTAssert(replJob.commandLine.contains(.flag("-module-name")))
XCTAssertThrowsError(try Driver(args: ["swift", "-deprecated-integrated-repl"])) {
XCTAssertEqual($0 as? Driver.Error, Driver.Error.integratedReplRemoved)
}
}

do {
Expand Down