Skip to content

Commit

Permalink
Workspace,Build: reduce mtime updates
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
compnerd committed Jun 15, 2023
1 parent cefff2b commit 3c774b9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ final class WriteAuxiliaryFileCommand: CustomLLBuildCommand {
}

do {
try self.context.fileSystem.writeFileContents(outputFilePath, string: getFileContents(tool: tool))
try self.context.fileSystem.writeIfChanged(path: outputFilePath, string: getFileContents(tool: tool))
return true
} catch {
self.context.observabilityScope.emit(error: "failed to write auxiliary file '\(outputFilePath.pathString)': \(error.interpolationDescription)")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Workspace/Workspace+State.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fileprivate struct WorkspaceStateStorage {
let storage = V6(dependencies: dependencies, artifacts: artifacts)

let data = try self.encoder.encode(storage)
try self.fileSystem.writeFileContents(self.path, data: data)
try self.fileSystem.writeIfChanged(path: self.path, bytes: .init(data))
}
}

Expand Down

0 comments on commit 3c774b9

Please sign in to comment.