@@ -18,6 +18,13 @@ public enum ModuleOutput: Equatable {
18
18
return path
19
19
}
20
20
}
21
+
22
+ public var isTopLevel : Bool {
23
+ switch self {
24
+ case . topLevel: return true
25
+ default : return false
26
+ }
27
+ }
21
28
}
22
29
23
30
/// The Swift driver.
@@ -63,12 +70,6 @@ public struct Driver {
63
70
/// The mode in which the compiler will execute.
64
71
public let compilerMode : CompilerMode
65
72
66
- /// Whether to print out incremental build decisions
67
- public let showIncrementalBuildDecisions : Bool
68
-
69
- /// Is the build incremental?
70
- public let isIncremental : Bool
71
-
72
73
/// The type of the primary output generated by the compiler.
73
74
public let compilerOutputType : FileType ?
74
75
@@ -88,6 +89,9 @@ public struct Driver {
88
89
/// \c nil if no module should be emitted.
89
90
public let moduleOutput : ModuleOutput ?
90
91
92
+ /// Code & data for incremental compilation
93
+ public let incrementalCompilation : IncrementalCompilation
94
+
91
95
/// The name of the Swift module being built.
92
96
public let moduleName : String
93
97
@@ -196,24 +200,17 @@ public struct Driver {
196
200
self . inputFiles = try Self . collectInputFiles ( & self . parsedOptions)
197
201
198
202
// Initialize an empty output file map, which will be populated when we start creating jobs.
199
- let outputFileMap : OutputFileMap ?
200
203
if let outputFileMapArg = parsedOptions. getLastArgument ( . output_file_map) ? . asSingle {
201
204
let path = try AbsolutePath ( validating: outputFileMapArg)
202
- outputFileMap = try . load( file: path, diagnosticEngine: diagnosticEngine)
205
+ self . outputFileMap = try . load( file: path, diagnosticEngine: diagnosticEngine)
203
206
}
204
207
else {
205
- outputFileMap = nil
208
+ self . outputFileMap = nil
206
209
}
207
- self . outputFileMap = outputFileMap
208
210
209
211
// Determine the compilation mode.
210
212
self . compilerMode = Self . computeCompilerMode ( & parsedOptions, driverKind: driverKind)
211
213
212
- // Determine whether the compilation should be incremental
213
- ( showIncrementalBuildDecisions: self . showIncrementalBuildDecisions,
214
- shouldBeIncremental: self . isIncremental) =
215
- Self . computeIncrementalPredicates ( & parsedOptions, driverKind: driverKind)
216
-
217
214
// Figure out the primary outputs from the driver.
218
215
( self . compilerOutputType, self . linkerOutputType) = Self . determinePrimaryOutputs ( & parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)
219
216
@@ -224,9 +221,20 @@ public struct Driver {
224
221
( self . debugInfoLevel, self . debugInfoFormat) = Self . computeDebugInfo ( & parsedOptions, diagnosticsEngine: diagnosticEngine)
225
222
226
223
// Determine the module we're building and whether/how the module file itself will be emitted.
227
- ( self . moduleOutput, self . moduleName) = try Self . computeModuleInfo (
224
+ let moduleOutput : ModuleOutput ?
225
+ ( moduleOutput, self . moduleName) = try Self . computeModuleInfo (
228
226
& parsedOptions, compilerOutputType: compilerOutputType, compilerMode: compilerMode, linkerOutputType: linkerOutputType,
229
227
debugInfoLevel: debugInfoLevel, diagnosticsEngine: diagnosticEngine)
228
+ self . moduleOutput = moduleOutput
229
+
230
+ // Determine the state for incremental compilation
231
+ self . incrementalCompilation = IncrementalCompilation (
232
+ & parsedOptions,
233
+ compilerMode: compilerMode,
234
+ outputFileMap: self . outputFileMap,
235
+ compilerOutputType: self . compilerOutputType,
236
+ moduleOutput: moduleOutput,
237
+ diagnosticEngine: diagnosticEngine)
230
238
231
239
self . sdkPath = Self . computeSDKPath ( & parsedOptions, compilerMode: compilerMode, toolchain: toolchain, diagnosticsEngine: diagnosticEngine)
232
240
@@ -402,31 +410,6 @@ extension Driver {
402
410
}
403
411
}
404
412
405
- extension Driver {
406
- /// Compute whether the compilation should be incremental
407
- private static func computeIncrementalPredicates(
408
- _ parsedOptions: inout ParsedOptions ,
409
- driverKind: DriverKind ) -> ( showIncrementalBuildDecisions: Bool , shouldBeIncremental: Bool ) {
410
- let showIncrementalBuildDecisions = parsedOptions. hasArgument ( . driver_show_incremental) )
411
- guard ( parsedOptions. hasArgument ( . incremental) else {
412
- return ( showIncrementalBuildDecisions: showIncrementalBuildDecisions, shouldBeIncremental: false )
413
- }
414
- guard let reasonToDisable = parsedOptions. hasArgument ( . whole_module_optimization)
415
- ? " is not compatible with whole module optimization. "
416
- : parsedOptions. hasArgument ( . embed_bitcode)
417
- ? " is not currently compatible with embedding LLVM IR bitcode. "
418
- : nil
419
- else {
420
- return ( showIncrementalBuildDecisions: showIncrementalBuildDecisions, shouldBeIncremental: true )
421
- }
422
- if ( showIncrementalBuildDecisions) {
423
- stderrStream << < " Incremental compilation has been disabled, because it \( reasonToDisable) \n "
424
- stderrStream. flush ( )
425
- }
426
- return ( showIncrementalBuildDecisions: showIncrementalBuildDecisions, shouldBeIncremental: false )
427
- }
428
- }
429
-
430
413
/// Input and output file handling.
431
414
extension Driver {
432
415
/// Apply the given working directory to all paths in the parsed options.
0 commit comments