Skip to content

Commit 35e61f0

Browse files
author
David Ungar
authored
Merge pull request #270 from davidungar/refactoring-planStandardCompile
Refactoring plan standard compile
2 parents c605132 + ea42216 commit 35e61f0

File tree

5 files changed

+339
-213
lines changed

5 files changed

+339
-213
lines changed

Sources/SwiftDriver/Driver/CompilerMode.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ extension CompilerMode {
6262
}
6363
}
6464

65+
public var isStandardCompilationForPlanning: Bool {
66+
switch self {
67+
case .immediate, .repl, .compilePCM:
68+
return false
69+
case .batchCompile, .standardCompile, .singleCompile:
70+
return true
71+
}
72+
}
73+
6574
// Whether this compilation mode supports the use of bridging pre-compiled
6675
// headers.
6776
public var supportsBridgingPCH: Bool {

Sources/SwiftDriver/Jobs/BackendJob.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import Foundation
1515
extension Driver {
1616
/// Form a backend job.
1717
mutating func backendJob(input: TypedVirtualPath,
18-
allOutputs: inout [TypedVirtualPath]) throws -> Job {
18+
addJobOutputs: ([TypedVirtualPath]) -> Void)
19+
throws -> Job {
1920
var commandLine: [Job.ArgTemplate] = swiftCompilerPrefixArgs.map { Job.ArgTemplate.flag($0) }
2021
var inputs = [TypedVirtualPath]()
2122
var outputs = [TypedVirtualPath]()
@@ -62,7 +63,7 @@ extension Driver {
6263
outputs.append(output)
6364
}
6465

65-
allOutputs += outputs
66+
addJobOutputs(outputs)
6667

6768
return Job(
6869
moduleName: moduleOutputInfo.name,

Sources/SwiftDriver/Jobs/CompileJob.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ extension Driver {
157157
}
158158

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

252-
allOutputs += outputs
254+
addJobOutputs(outputs)
253255

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

0 commit comments

Comments
 (0)