Skip to content

[Incremental] Rename "SwiftDeps" etc. to "DependencySource" #456

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 3 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ add_library(SwiftDriver
"IncrementalCompilation/ModuleDependencyGraphParts/Integrator.swift"
"IncrementalCompilation/ModuleDependencyGraphParts/Node.swift"
"IncrementalCompilation/ModuleDependencyGraphParts/NodeFinder.swift"
"IncrementalCompilation/ModuleDependencyGraphParts/SwiftDeps.swift"
"IncrementalCompilation/ModuleDependencyGraphParts/DependencySource.swift"
"IncrementalCompilation/ModuleDependencyGraphParts/Tracer.swift"
"IncrementalCompilation/BidirectionalMap.swift"
"IncrementalCompilation/BuildRecord.swift"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ public class IncrementalCompilationState {
return nil
}

guard let (moduleDependencyGraph,
inputsHavingMalformedSwiftDeps: inputsHavingMalformedSwiftDeps) =
guard let (
moduleDependencyGraph,
inputsHavingMalformedDependencySources: inputsHavingMalformedDependencySources
) =
Self.computeModuleDependencyGraph(
buildRecordInfo,
outOfDateBuildRecord,
Expand All @@ -81,7 +83,7 @@ public class IncrementalCompilationState {
&driver,
buildRecordInfo,
outOfDateBuildRecord,
inputsHavingMalformedSwiftDeps: inputsHavingMalformedSwiftDeps,
inputsHavingMalformedDependencySources: inputsHavingMalformedDependencySources,
moduleDependencyGraph,
self.reporter)

Expand All @@ -99,42 +101,46 @@ public class IncrementalCompilationState {
_ driver: inout Driver,
_ reporter: Reporter?
)
-> (ModuleDependencyGraph, inputsHavingMalformedSwiftDeps: [TypedVirtualPath])?
-> (ModuleDependencyGraph,
inputsHavingMalformedDependencySources: [TypedVirtualPath])?
{
let diagnosticEngine = driver.diagnosticEngine
guard let (moduleDependencyGraph, inputsWithMalformedSwiftDeps: inputsWithMalformedSwiftDeps) =
ModuleDependencyGraph.buildInitialGraph(
diagnosticEngine: diagnosticEngine,
inputs: buildRecordInfo.compilationInputModificationDates.keys,
previousInputs: outOfDateBuildRecord.allInputs,
outputFileMap: outputFileMap,
parsedOptions: &driver.parsedOptions,
remarkDisabled: Diagnostic.Message.remark_incremental_compilation_has_been_disabled,
reporter: reporter,
fileSystem: driver.fileSystem)
guard let (
moduleDependencyGraph,
inputsAndMalformedDependencySources: inputsAndMalformedDependencySources
) =
ModuleDependencyGraph.buildInitialGraph(
diagnosticEngine: diagnosticEngine,
inputs: buildRecordInfo.compilationInputModificationDates.keys,
previousInputs: outOfDateBuildRecord.allInputs,
outputFileMap: outputFileMap,
parsedOptions: &driver.parsedOptions,
remarkDisabled: Diagnostic.Message.remark_incremental_compilation_has_been_disabled,
reporter: reporter,
fileSystem: driver.fileSystem)
else {
return nil
}
// Preserve legacy behavior,
// but someday, just ensure inputsWithUnreadableSwiftDeps are compiled
if let badSwiftDeps = inputsWithMalformedSwiftDeps.first?.1 {
// but someday, just ensure inputsAndMalformedDependencySources are compiled
if let badDependencySource = inputsAndMalformedDependencySources.first?.1 {
diagnosticEngine.emit(
.remark_incremental_compilation_has_been_disabled(
because: "malformed swift dependencies file '\(badSwiftDeps)'")
because: "malformed dependencies file '\(badDependencySource)'")
)
return nil
}
let inputsHavingMalformedSwiftDeps = inputsWithMalformedSwiftDeps.map {$0.0}
let inputsHavingMalformedDependencySources = inputsAndMalformedDependencySources.map {$0.0}
return (moduleDependencyGraph,
inputsHavingMalformedSwiftDeps: inputsHavingMalformedSwiftDeps)
inputsHavingMalformedDependencySources: inputsHavingMalformedDependencySources)
}

private static func computeInputsAndGroups(
_ jobsInPhases: JobsInPhases,
_ driver: inout Driver,
_ buildRecordInfo: BuildRecordInfo,
_ outOfDateBuildRecord: BuildRecord,
inputsHavingMalformedSwiftDeps: [TypedVirtualPath],
inputsHavingMalformedDependencySources: [TypedVirtualPath],
_ moduleDependencyGraph: ModuleDependencyGraph,
_ reporter: Reporter?
) throws -> (skippedCompileGroups: [TypedVirtualPath: CompileJobGroup],
Expand All @@ -148,7 +154,7 @@ public class IncrementalCompilationState {
allGroups: jobsInPhases.compileGroups,
fileSystem: driver.fileSystem,
buildRecordInfo: buildRecordInfo,
inputsHavingMalformedSwiftDeps: inputsHavingMalformedSwiftDeps,
inputsHavingMalformedDependencySources: inputsHavingMalformedDependencySources,
moduleDependencyGraph: moduleDependencyGraph,
outOfDateBuildRecord: outOfDateBuildRecord,
alwaysRebuildDependents: driver.parsedOptions.contains(.driverAlwaysRebuildDependents),
Expand Down Expand Up @@ -270,7 +276,7 @@ extension IncrementalCompilationState {
allGroups: [CompileJobGroup],
fileSystem: FileSystem,
buildRecordInfo: BuildRecordInfo,
inputsHavingMalformedSwiftDeps: [TypedVirtualPath],
inputsHavingMalformedDependencySources: [TypedVirtualPath],
moduleDependencyGraph: ModuleDependencyGraph,
outOfDateBuildRecord: BuildRecord,
alwaysRebuildDependents: Bool,
Expand Down Expand Up @@ -299,7 +305,7 @@ extension IncrementalCompilationState {
// Combine to obtain the inputs that definitely must be recompiled.
let definitelyRequiredInputs =
Set(changedInputs.map({ $0.filePath }) + externalDependents +
inputsHavingMalformedSwiftDeps
inputsHavingMalformedDependencySources
+ inputsMissingOutputs)
if let reporter = reporter {
for scheduledInput in definitelyRequiredInputs.sorted(by: {$0.file.name < $1.file.name}) {
Expand Down Expand Up @@ -402,31 +408,31 @@ extension IncrementalCompilationState {
moduleDependencyGraph: ModuleDependencyGraph,
reporter: IncrementalCompilationState.Reporter?
) -> [TypedVirtualPath] {
var externallyDependentSwiftDeps = Set<ModuleDependencyGraph.SwiftDeps>()
var externalDependencySources = Set<ModuleDependencyGraph.DependencySource>()
for extDep in moduleDependencyGraph.externalDependencies {
let extModTime = extDep.file.flatMap {
try? fileSystem.getFileInfo($0).modTime}
?? Date.distantFuture
if extModTime >= buildTime {
for dependent in moduleDependencyGraph.untracedDependents(of: extDep) {
guard let swiftDeps = dependent.swiftDeps else {
fatalError("Dependent \(dependent) does not have swiftdeps file!")
guard let dependencySource = dependent.dependencySource else {
fatalError("Dependent \(dependent) does not have dependencies source file!")
}
reporter?.report(
"Queuing because of external dependency on newer \(extDep.file?.basename ?? "extDep?")",
path: TypedVirtualPath(file: swiftDeps.file, type: .swiftDeps))
externallyDependentSwiftDeps.insert(swiftDeps)
path: TypedVirtualPath(file: dependencySource.file, type: .swiftDeps))
externalDependencySources.insert(dependencySource)
}
}
}
return externallyDependentSwiftDeps.compactMap {
moduleDependencyGraph.sourceSwiftDepsMap[$0]
return externalDependencySources.compactMap {
moduleDependencyGraph.inputDependencySourceMap[$0]
}
}

/// Returns the cascaded files to compile in the first wave, even though it may not be need.
/// The needs[Non}CascadingBuild stuff was cargo-culted from the legacy driver.
/// TODO: something better, e.g. return nothing here, but process changed swiftDeps
/// TODO: something better, e.g. return nothing here, but process changed dependencySource
/// before the whole frontend job finished.
private static func computeSpeculativeInputs(
changedInputs: [ChangedInput],
Expand All @@ -436,10 +442,11 @@ extension IncrementalCompilationState {
alwaysRebuildDependents: Bool,
reporter: IncrementalCompilationState.Reporter?
) -> Set<TypedVirtualPath> {
let cascadingChangedInputs = Self.computeCascadingChangedInputs(from: changedInputs,
inputsMissingOutputs: inputsMissingOutputs,
alwaysRebuildDependents: alwaysRebuildDependents,
reporter: reporter)
let cascadingChangedInputs = Self.computeCascadingChangedInputs(
from: changedInputs,
inputsMissingOutputs: inputsMissingOutputs,
alwaysRebuildDependents: alwaysRebuildDependents,
reporter: reporter)
let cascadingExternalDependents = alwaysRebuildDependents ? externalDependents : []
// Collect the dependent files to speculatively schedule
var dependentFiles = Set<TypedVirtualPath>()
Expand Down Expand Up @@ -554,7 +561,7 @@ extension IncrementalCompilationState {
if let found = moduleDependencyGraph.findSourcesToCompileAfterCompiling(input, on: self.driver.fileSystem) {
return found
}
self.reporter?.report("Failed to read some swiftdeps; compiling everything", path: input)
self.reporter?.report("Failed to read some dependencies source; compiling everything", path: input)
return Array(skippedCompileGroups.keys)
}
)
Expand Down
Loading