Skip to content

Commit 1d11f11

Browse files
author
David Ungar
authored
Merge pull request #456 from davidungar/rename-swiftdeps
[Incremental] Rename "SwiftDeps" etc. to "DependencySource"
2 parents f37d935 + 0f8dbf4 commit 1d11f11

File tree

11 files changed

+254
-229
lines changed

11 files changed

+254
-229
lines changed

Sources/SwiftDriver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ add_library(SwiftDriver
3333
"IncrementalCompilation/ModuleDependencyGraphParts/Integrator.swift"
3434
"IncrementalCompilation/ModuleDependencyGraphParts/Node.swift"
3535
"IncrementalCompilation/ModuleDependencyGraphParts/NodeFinder.swift"
36-
"IncrementalCompilation/ModuleDependencyGraphParts/SwiftDeps.swift"
36+
"IncrementalCompilation/ModuleDependencyGraphParts/DependencySource.swift"
3737
"IncrementalCompilation/ModuleDependencyGraphParts/Tracer.swift"
3838
"IncrementalCompilation/BidirectionalMap.swift"
3939
"IncrementalCompilation/BuildRecord.swift"

Sources/SwiftDriver/IncrementalCompilation/IncrementalCompilationState.swift

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ public class IncrementalCompilationState {
6363
return nil
6464
}
6565

66-
guard let (moduleDependencyGraph,
67-
inputsHavingMalformedSwiftDeps: inputsHavingMalformedSwiftDeps) =
66+
guard let (
67+
moduleDependencyGraph,
68+
inputsHavingMalformedDependencySources: inputsHavingMalformedDependencySources
69+
) =
6870
Self.computeModuleDependencyGraph(
6971
buildRecordInfo,
7072
outOfDateBuildRecord,
@@ -81,7 +83,7 @@ public class IncrementalCompilationState {
8183
&driver,
8284
buildRecordInfo,
8385
outOfDateBuildRecord,
84-
inputsHavingMalformedSwiftDeps: inputsHavingMalformedSwiftDeps,
86+
inputsHavingMalformedDependencySources: inputsHavingMalformedDependencySources,
8587
moduleDependencyGraph,
8688
self.reporter)
8789

@@ -99,42 +101,46 @@ public class IncrementalCompilationState {
99101
_ driver: inout Driver,
100102
_ reporter: Reporter?
101103
)
102-
-> (ModuleDependencyGraph, inputsHavingMalformedSwiftDeps: [TypedVirtualPath])?
104+
-> (ModuleDependencyGraph,
105+
inputsHavingMalformedDependencySources: [TypedVirtualPath])?
103106
{
104107
let diagnosticEngine = driver.diagnosticEngine
105-
guard let (moduleDependencyGraph, inputsWithMalformedSwiftDeps: inputsWithMalformedSwiftDeps) =
106-
ModuleDependencyGraph.buildInitialGraph(
107-
diagnosticEngine: diagnosticEngine,
108-
inputs: buildRecordInfo.compilationInputModificationDates.keys,
109-
previousInputs: outOfDateBuildRecord.allInputs,
110-
outputFileMap: outputFileMap,
111-
parsedOptions: &driver.parsedOptions,
112-
remarkDisabled: Diagnostic.Message.remark_incremental_compilation_has_been_disabled,
113-
reporter: reporter,
114-
fileSystem: driver.fileSystem)
108+
guard let (
109+
moduleDependencyGraph,
110+
inputsAndMalformedDependencySources: inputsAndMalformedDependencySources
111+
) =
112+
ModuleDependencyGraph.buildInitialGraph(
113+
diagnosticEngine: diagnosticEngine,
114+
inputs: buildRecordInfo.compilationInputModificationDates.keys,
115+
previousInputs: outOfDateBuildRecord.allInputs,
116+
outputFileMap: outputFileMap,
117+
parsedOptions: &driver.parsedOptions,
118+
remarkDisabled: Diagnostic.Message.remark_incremental_compilation_has_been_disabled,
119+
reporter: reporter,
120+
fileSystem: driver.fileSystem)
115121
else {
116122
return nil
117123
}
118124
// Preserve legacy behavior,
119-
// but someday, just ensure inputsWithUnreadableSwiftDeps are compiled
120-
if let badSwiftDeps = inputsWithMalformedSwiftDeps.first?.1 {
125+
// but someday, just ensure inputsAndMalformedDependencySources are compiled
126+
if let badDependencySource = inputsAndMalformedDependencySources.first?.1 {
121127
diagnosticEngine.emit(
122128
.remark_incremental_compilation_has_been_disabled(
123-
because: "malformed swift dependencies file '\(badSwiftDeps)'")
129+
because: "malformed dependencies file '\(badDependencySource)'")
124130
)
125131
return nil
126132
}
127-
let inputsHavingMalformedSwiftDeps = inputsWithMalformedSwiftDeps.map {$0.0}
133+
let inputsHavingMalformedDependencySources = inputsAndMalformedDependencySources.map {$0.0}
128134
return (moduleDependencyGraph,
129-
inputsHavingMalformedSwiftDeps: inputsHavingMalformedSwiftDeps)
135+
inputsHavingMalformedDependencySources: inputsHavingMalformedDependencySources)
130136
}
131137

132138
private static func computeInputsAndGroups(
133139
_ jobsInPhases: JobsInPhases,
134140
_ driver: inout Driver,
135141
_ buildRecordInfo: BuildRecordInfo,
136142
_ outOfDateBuildRecord: BuildRecord,
137-
inputsHavingMalformedSwiftDeps: [TypedVirtualPath],
143+
inputsHavingMalformedDependencySources: [TypedVirtualPath],
138144
_ moduleDependencyGraph: ModuleDependencyGraph,
139145
_ reporter: Reporter?
140146
) throws -> (skippedCompileGroups: [TypedVirtualPath: CompileJobGroup],
@@ -148,7 +154,7 @@ public class IncrementalCompilationState {
148154
allGroups: jobsInPhases.compileGroups,
149155
fileSystem: driver.fileSystem,
150156
buildRecordInfo: buildRecordInfo,
151-
inputsHavingMalformedSwiftDeps: inputsHavingMalformedSwiftDeps,
157+
inputsHavingMalformedDependencySources: inputsHavingMalformedDependencySources,
152158
moduleDependencyGraph: moduleDependencyGraph,
153159
outOfDateBuildRecord: outOfDateBuildRecord,
154160
alwaysRebuildDependents: driver.parsedOptions.contains(.driverAlwaysRebuildDependents),
@@ -270,7 +276,7 @@ extension IncrementalCompilationState {
270276
allGroups: [CompileJobGroup],
271277
fileSystem: FileSystem,
272278
buildRecordInfo: BuildRecordInfo,
273-
inputsHavingMalformedSwiftDeps: [TypedVirtualPath],
279+
inputsHavingMalformedDependencySources: [TypedVirtualPath],
274280
moduleDependencyGraph: ModuleDependencyGraph,
275281
outOfDateBuildRecord: BuildRecord,
276282
alwaysRebuildDependents: Bool,
@@ -299,7 +305,7 @@ extension IncrementalCompilationState {
299305
// Combine to obtain the inputs that definitely must be recompiled.
300306
let definitelyRequiredInputs =
301307
Set(changedInputs.map({ $0.filePath }) + externalDependents +
302-
inputsHavingMalformedSwiftDeps
308+
inputsHavingMalformedDependencySources
303309
+ inputsMissingOutputs)
304310
if let reporter = reporter {
305311
for scheduledInput in definitelyRequiredInputs.sorted(by: {$0.file.name < $1.file.name}) {
@@ -402,31 +408,31 @@ extension IncrementalCompilationState {
402408
moduleDependencyGraph: ModuleDependencyGraph,
403409
reporter: IncrementalCompilationState.Reporter?
404410
) -> [TypedVirtualPath] {
405-
var externallyDependentSwiftDeps = Set<ModuleDependencyGraph.SwiftDeps>()
411+
var externalDependencySources = Set<ModuleDependencyGraph.DependencySource>()
406412
for extDep in moduleDependencyGraph.externalDependencies {
407413
let extModTime = extDep.file.flatMap {
408414
try? fileSystem.getFileInfo($0).modTime}
409415
?? Date.distantFuture
410416
if extModTime >= buildTime {
411417
for dependent in moduleDependencyGraph.untracedDependents(of: extDep) {
412-
guard let swiftDeps = dependent.swiftDeps else {
413-
fatalError("Dependent \(dependent) does not have swiftdeps file!")
418+
guard let dependencySource = dependent.dependencySource else {
419+
fatalError("Dependent \(dependent) does not have dependencies source file!")
414420
}
415421
reporter?.report(
416422
"Queuing because of external dependency on newer \(extDep.file?.basename ?? "extDep?")",
417-
path: TypedVirtualPath(file: swiftDeps.file, type: .swiftDeps))
418-
externallyDependentSwiftDeps.insert(swiftDeps)
423+
path: TypedVirtualPath(file: dependencySource.file, type: .swiftDeps))
424+
externalDependencySources.insert(dependencySource)
419425
}
420426
}
421427
}
422-
return externallyDependentSwiftDeps.compactMap {
423-
moduleDependencyGraph.sourceSwiftDepsMap[$0]
428+
return externalDependencySources.compactMap {
429+
moduleDependencyGraph.inputDependencySourceMap[$0]
424430
}
425431
}
426432

427433
/// Returns the cascaded files to compile in the first wave, even though it may not be need.
428434
/// The needs[Non}CascadingBuild stuff was cargo-culted from the legacy driver.
429-
/// TODO: something better, e.g. return nothing here, but process changed swiftDeps
435+
/// TODO: something better, e.g. return nothing here, but process changed dependencySource
430436
/// before the whole frontend job finished.
431437
private static func computeSpeculativeInputs(
432438
changedInputs: [ChangedInput],
@@ -436,10 +442,11 @@ extension IncrementalCompilationState {
436442
alwaysRebuildDependents: Bool,
437443
reporter: IncrementalCompilationState.Reporter?
438444
) -> Set<TypedVirtualPath> {
439-
let cascadingChangedInputs = Self.computeCascadingChangedInputs(from: changedInputs,
440-
inputsMissingOutputs: inputsMissingOutputs,
441-
alwaysRebuildDependents: alwaysRebuildDependents,
442-
reporter: reporter)
445+
let cascadingChangedInputs = Self.computeCascadingChangedInputs(
446+
from: changedInputs,
447+
inputsMissingOutputs: inputsMissingOutputs,
448+
alwaysRebuildDependents: alwaysRebuildDependents,
449+
reporter: reporter)
443450
let cascadingExternalDependents = alwaysRebuildDependents ? externalDependents : []
444451
// Collect the dependent files to speculatively schedule
445452
var dependentFiles = Set<TypedVirtualPath>()
@@ -554,7 +561,7 @@ extension IncrementalCompilationState {
554561
if let found = moduleDependencyGraph.findSourcesToCompileAfterCompiling(input, on: self.driver.fileSystem) {
555562
return found
556563
}
557-
self.reporter?.report("Failed to read some swiftdeps; compiling everything", path: input)
564+
self.reporter?.report("Failed to read some dependencies source; compiling everything", path: input)
558565
return Array(skippedCompileGroups.keys)
559566
}
560567
)

0 commit comments

Comments
 (0)