Skip to content

Refactoring plan standard compile #270

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 14 commits into from
Sep 23, 2020
9 changes: 9 additions & 0 deletions Sources/SwiftDriver/Driver/CompilerMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ extension CompilerMode {
}
}

public var isStandardCompilationForPlanning: Bool {
switch self {
case .immediate, .repl, .compilePCM:
return false
case .batchCompile, .standardCompile, .singleCompile:
return true
}
}

// Whether this compilation mode supports the use of bridging pre-compiled
// headers.
public var supportsBridgingPCH: Bool {
Expand Down
5 changes: 3 additions & 2 deletions Sources/SwiftDriver/Jobs/BackendJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import Foundation
extension Driver {
/// Form a backend job.
mutating func backendJob(input: TypedVirtualPath,
allOutputs: inout [TypedVirtualPath]) throws -> Job {
addJobOutputs: ([TypedVirtualPath]) -> Void)
throws -> Job {
var commandLine: [Job.ArgTemplate] = swiftCompilerPrefixArgs.map { Job.ArgTemplate.flag($0) }
var inputs = [TypedVirtualPath]()
var outputs = [TypedVirtualPath]()
Expand Down Expand Up @@ -62,7 +63,7 @@ extension Driver {
outputs.append(output)
}

allOutputs += outputs
addJobOutputs(outputs)

return Job(
moduleName: moduleOutputInfo.name,
Expand Down
8 changes: 5 additions & 3 deletions Sources/SwiftDriver/Jobs/CompileJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ extension Driver {
}

/// Form a compile job, which executes the Swift frontend to produce various outputs.
mutating func compileJob(primaryInputs: [TypedVirtualPath], outputType: FileType?,
allOutputs: inout [TypedVirtualPath]) throws -> Job {
mutating func compileJob(primaryInputs: [TypedVirtualPath],
outputType: FileType?,
addJobOutputs: ([TypedVirtualPath]) -> Void)
throws -> Job {
var commandLine: [Job.ArgTemplate] = swiftCompilerPrefixArgs.map { Job.ArgTemplate.flag($0) }
var inputs: [TypedVirtualPath] = []
var outputs: [TypedVirtualPath] = []
Expand Down Expand Up @@ -249,7 +251,7 @@ extension Driver {
try commandLine.appendLast(.runtimeCompatibilityVersion, from: &parsedOptions)
try commandLine.appendLast(.disableAutolinkingRuntimeCompatibilityDynamicReplacements, from: &parsedOptions)

allOutputs += outputs
addJobOutputs(outputs)

// If we're creating emit module job, order the compile jobs after that.
if shouldCreateEmitModuleJob {
Expand Down
Loading