-
-
Notifications
You must be signed in to change notification settings - Fork 6
Only write the dependency tree output file if it has changed #167
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #167 +/- ##
=======================================
Coverage 99.92% 99.92%
=======================================
Files 32 32
Lines 3751 3763 +12
=======================================
+ Hits 3748 3760 +12
Misses 3 3
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job. I hope this makes build time even faster for incremental builds. 🙌🏼
@@ -52,6 +52,13 @@ struct SafeDITool: AsyncParsableCommand, Sendable { | |||
throw ValidationError("Must provide 'swift-sources-file-path', '--include', or '--include-file-path'.") | |||
} | |||
|
|||
async let existingGeneratedCode: String? = Task.detached { | |||
if let dependencyTreeOutput { | |||
try? String(contentsOf: dependencyTreeOutput.asFileURL, encoding: .utf8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to log if unable to initialize a string with the content of the tree output? Anyway, it should be nil
for initialization errors, or the file doesn't exist initially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so – if we can't read it for whatever reason we'll just write a new one.
if let dependencyTreeOutput, let generatedCode = try await generatedCode { | ||
if let dependencyTreeOutput, | ||
let generatedCode = try await generatedCode, | ||
// Only update the file if the file has changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice inline comment
Co-authored-by: Ahmed M. Hassan <[email protected]>
@ahmdmhasn had a great idea to not touch the output file if the output file's content hasn't changed. Looks like modern Xcode seems to support having a package plugin that does supports this, so let's do it.
I believe earlier SPM implementations required the output file to be touched as part of the build plugin run, so we needed to write the file. This does not seem to be the case in Xcode 16+.