File tree Expand file tree Collapse file tree 4 files changed +35
-11
lines changed Expand file tree Collapse file tree 4 files changed +35
-11
lines changed Original file line number Diff line number Diff line change @@ -971,10 +971,7 @@ extension Driver {
971
971
if !childJobs. isEmpty {
972
972
do {
973
973
defer {
974
- self . incrementalCompilationState? . writeDependencyGraph ( )
975
- buildRecordInfo? . writeBuildRecord (
976
- jobs,
977
- incrementalCompilationState? . skippedCompilationInputs)
974
+ writeIncrementalBuildInformation ( jobs)
978
975
}
979
976
try performTheBuild ( allJobs: childJobs,
980
977
jobExecutionDelegate: toolExecutionDelegate,
@@ -1038,6 +1035,20 @@ extension Driver {
1038
1035
recordedInputModificationDates: recordedInputModificationDates)
1039
1036
}
1040
1037
1038
+ private func writeIncrementalBuildInformation( _ jobs: [ Job ] ) {
1039
+ if let incrementalCompilationState = self . incrementalCompilationState {
1040
+ let hadError = incrementalCompilationState. writeDependencyGraph ( )
1041
+ /// Ensure that a bogus dependency graph is not used next time
1042
+ guard !hadError else {
1043
+ buildRecordInfo? . removeBuildRecord ( )
1044
+ return
1045
+ }
1046
+ }
1047
+ buildRecordInfo? . writeBuildRecord (
1048
+ jobs,
1049
+ incrementalCompilationState? . skippedCompilationInputs)
1050
+ }
1051
+
1041
1052
private func printBindings( _ job: Job ) {
1042
1053
stdoutStream <<< #"# ""# <<< targetTriple. triple
1043
1054
stdoutStream <<< #"" - ""# <<< job. tool. basename
Original file line number Diff line number Diff line change @@ -184,6 +184,13 @@ import SwiftOptions
184
184
}
185
185
}
186
186
187
+ func removeBuildRecord( ) {
188
+ guard let absPath = buildRecordPath. absolutePath else {
189
+ return
190
+ }
191
+ try ? fileSystem. removeFileTree ( absPath)
192
+ }
193
+
187
194
/// Before writing to the dependencies file path, preserve any previous file
188
195
/// that may have been there. No error handling -- this is just a nicety, it
189
196
/// doesn't matter if it fails.
Original file line number Diff line number Diff line change @@ -444,23 +444,26 @@ extension IncrementalCompilationState {
444
444
// MARK: - Serialization
445
445
446
446
extension IncrementalCompilationState {
447
- @_spi ( Testing) public func writeDependencyGraph( ) {
447
+ @_spi ( Testing) public func writeDependencyGraph( ) -> Bool {
448
448
// If the cross-module build is not enabled, the status quo dictates we
449
449
// not emit this file.
450
450
guard moduleDependencyGraph. info. isCrossModuleIncrementalBuildEnabled else {
451
- return
451
+ return false
452
452
}
453
453
454
454
guard
455
455
let recordInfo = self . driver. buildRecordInfo
456
456
else {
457
+ // It's OK to silently fail because no build record will be written
458
+ // so there will be no attempt to use the saved module dependency graph
459
+ // next time.
457
460
self . driver. diagnosticEngine. emit (
458
461
. warning_could_not_write_dependency_graph)
459
- return
462
+ return true
460
463
}
461
- self . moduleDependencyGraph. write ( to: recordInfo. dependencyGraphPath,
462
- on: self . driver. fileSystem,
463
- compilerVersion: recordInfo. actualSwiftVersion)
464
+ return self . moduleDependencyGraph. write ( to: recordInfo. dependencyGraphPath,
465
+ on: self . driver. fileSystem,
466
+ compilerVersion: recordInfo. actualSwiftVersion)
464
467
}
465
468
}
466
469
Original file line number Diff line number Diff line change @@ -663,19 +663,22 @@ extension ModuleDependencyGraph {
663
663
/// - fileSystem: The file system for this location.
664
664
/// - compilerVersion: A string containing version information for the
665
665
/// driver used to create this file.
666
+ /// - Returns: true if had error
666
667
@_spi ( Testing) public func write(
667
668
to path: VirtualPath ,
668
669
on fileSystem: FileSystem ,
669
670
compilerVersion: String
670
- ) {
671
+ ) -> Bool {
671
672
let data = ModuleDependencyGraph . Serializer. serialize ( self , compilerVersion)
672
673
673
674
do {
674
675
try fileSystem. writeFileContents ( path,
675
676
bytes: data,
676
677
atomically: true )
678
+ return false
677
679
} catch {
678
680
info. diagnosticEngine. emit ( . warning_could_not_write_dep_graph( to: path, error: error) )
681
+ return true
679
682
}
680
683
}
681
684
You can’t perform that action at this time.
0 commit comments