Skip to content

Commit be88f7c

Browse files
author
David Ungar
committed
Honor -driver-always-rebuild-dependents
1 parent e5acce7 commit be88f7c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Sources/SwiftDriver/Incremental Compilation/IncrementalCompilationState.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public class IncrementalCompilationState {
118118
buildRecordInfo: buildRecordInfo,
119119
moduleDependencyGraph: moduleDependencyGraph,
120120
outOfDateBuildRecord: outOfDateBuildRecord,
121+
alwaysRebuildDependents: parsedOptions.contains(.driverAlwaysRebuildDependents),
121122
reportIncrementalDecision: reportIncrementalDecision)
122123

123124
self.moduleDependencyGraph = moduleDependencyGraph
@@ -208,6 +209,7 @@ extension IncrementalCompilationState {
208209
buildRecordInfo: BuildRecordInfo,
209210
moduleDependencyGraph: ModuleDependencyGraph,
210211
outOfDateBuildRecord: BuildRecord,
212+
alwaysRebuildDependents: Bool,
211213
reportIncrementalDecision: ((String, TypedVirtualPath?) -> Void)?
212214
) -> Set<TypedVirtualPath> {
213215

@@ -238,6 +240,7 @@ extension IncrementalCompilationState {
238240
let speculativeInputs = computeSpeculativeInputs(
239241
changedInputs: changedInputs,
240242
moduleDependencyGraph: moduleDependencyGraph,
243+
alwaysRebuildDependents: alwaysRebuildDependents,
241244
reportIncrementalDecision: reportIncrementalDecision)
242245
.subtracting(definitelyRequiredInputs)
243246

@@ -330,26 +333,32 @@ extension IncrementalCompilationState {
330333
private static func computeSpeculativeInputs(
331334
changedInputs: [(TypedVirtualPath, InputInfo.Status)],
332335
moduleDependencyGraph: ModuleDependencyGraph,
336+
alwaysRebuildDependents: Bool,
333337
reportIncrementalDecision: ((String, TypedVirtualPath?) -> Void)?
334338
) -> Set<TypedVirtualPath> {
335339
// Collect the files that will be compiled whose dependents should be schedule
336340
let cascadingFiles: [TypedVirtualPath] = changedInputs.compactMap { input, status in
337341
let basename = input.file.basename
338-
switch status {
339-
case .needsCascadingBuild:
342+
switch (status, alwaysRebuildDependents) {
343+
344+
case (_, true):
345+
reportIncrementalDecision?(
346+
"scheduling dependents of \(basename); -driver-always-rebuild-dependents", nil)
347+
return input
348+
case (.needsCascadingBuild, false):
340349
reportIncrementalDecision?(
341350
"scheduling dependents of \(basename); needed cascading build", nil)
342351
return input
343352

344-
case .upToDate: // Must be building because it changed
353+
case (.upToDate, false): // was up to date, but changed
345354
reportIncrementalDecision?(
346355
"not scheduling dependents of \(basename); unknown changes", nil)
347356
return nil
348-
case .newlyAdded:
357+
case (.newlyAdded, false):
349358
reportIncrementalDecision?(
350359
"not scheduling dependents of \(basename): no entry in build record or dependency graph", nil)
351360
return nil
352-
case .needsNonCascadingBuild:
361+
case (.needsNonCascadingBuild, false):
353362
reportIncrementalDecision?(
354363
"not scheduling dependents of \(basename): does not need cascading build", nil)
355364
return nil

0 commit comments

Comments
 (0)