-
-
Notifications
You must be signed in to change notification settings - Fork 511
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache the helpers module #691
Conversation
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 work - looks good overall
let dylibName = "libProjectDescriptionHelpers.dylib" | ||
|
||
if FileHandler.shared.exists(helpersModuleCachePath) { | ||
return helpersModuleCachePath.appending(component: dylibName) |
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.
As a further optimization, you could cache the known built dylib paths in an in memory cache (saves calculating hashes repeatedly for every manifest)
let helpersPath = path.appending(RelativePath("Tuist/ProjectDescriptionHelpers")) | ||
try FileHandler.shared.createFolder(helpersPath) | ||
try FileHandler.shared.write("import Foundation; class Test {}", path: helpersPath.appending(component: "Helper.swift"), atomically: true) | ||
let projectDescriptionPath = try resourceLocator.projectDescription() | ||
|
||
// When | ||
_ = try subject.build(at: path, projectDescriptionPath: projectDescriptionPath) |
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.
Is the purpose of adding two calls here to test out caching?
If so, perhaps we could do that in a separate test that tests for it a bit more explicitly?
e.g.
// When
let paths = try (0..<3).map { _ in try subject.build(at: path, projectDescriptionPath: projectDescriptionPath) }
// Then
// check all the paths are equal
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.
That's a good idea. I changed the current test to follow your approach instead.
Related #668
Short description 馃摑
This PR adds support for caching the project description helpers modules across runs. If any of the files under the helpers directory changes, the logic deletes the old version of the framework automatically.
Solution 馃摝
Extend the
ProjectDescriptionHelpersBuilder
logic to cache the frameworks in a system directory.