Skip to content

Commit 3c774b9

Browse files
committed
Workspace,Build: reduce mtime updates
When building a project inside of VSCode with the LSP enabled, rebuilding the project would trigger a change to the mtimes of the auxiliary files resulting in an unnecessary rebuilding of targets. In conjunction with the changes to tools-support-core (swiftlang/swift-tools-support-core#422), incremental builds do not trigger a cascade of rebuilds that are unnecessary. Extracted from a patch by Ami Fischman!
1 parent cefff2b commit 3c774b9

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ final class WriteAuxiliaryFileCommand: CustomLLBuildCommand {
517517
}
518518

519519
do {
520-
try self.context.fileSystem.writeFileContents(outputFilePath, string: getFileContents(tool: tool))
520+
try self.context.fileSystem.writeIfChanged(path: outputFilePath, string: getFileContents(tool: tool))
521521
return true
522522
} catch {
523523
self.context.observabilityScope.emit(error: "failed to write auxiliary file '\(outputFilePath.pathString)': \(error.interpolationDescription)")

Sources/Workspace/Workspace+State.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fileprivate struct WorkspaceStateStorage {
135135
let storage = V6(dependencies: dependencies, artifacts: artifacts)
136136

137137
let data = try self.encoder.encode(storage)
138-
try self.fileSystem.writeFileContents(self.path, data: data)
138+
try self.fileSystem.writeIfChanged(path: self.path, bytes: .init(data))
139139
}
140140
}
141141

0 commit comments

Comments
 (0)