-
Notifications
You must be signed in to change notification settings - Fork 204
Allow relative paths in output file map #63
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
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.
Sorry it took so long to look over this! I just have a few small comments, but everything else looks good to me. Also, could you add a test for output file map resolution to SwiftDriverTests.swift
?
@@ -46,7 +46,7 @@ public struct Driver { | |||
case subcommandPassedToDriver | |||
case relativeFrontendPath(String) | |||
} | |||
|
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 you mind breaking these whitespace changes out into a separate PR? We can probably get those merged faster and they make this diff a little harder to read.
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.
done #70
@@ -233,10 +233,10 @@ public struct Driver { | |||
} | |||
|
|||
// Compute the working directory. | |||
let cwd = localFileSystem.currentWorkingDirectory |
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'm not sure we necessarily want to set the cwd here if we're not overriding it. It doesn't look like the C++ driver applies the cwd to the inputs in that case, it just uses relative paths.
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.
The thing that bothers me here, that you can override working directory with relative path, and if you override it with .
like this -working-directory=.
and not override it at all, code will take completely different paths.
Do you think that instead of making all arguments absolute we need to teach code to correctly handle relative paths?
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.
Removed this change for now, it works only when -working-directory
supplied. To work relative to cwd, further changes needed to teach code to work with relative paths.
return .absolute(.init(base, relPath)) | ||
} | ||
|
||
fileprivate static let singleDep = VirtualPath.relative(.init("")) |
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.
This is only used once, so I think you can just inline it into the if statement above with a comment explaining what it means.
(try VirtualPath(path: input), try entry.paths.mapValues(VirtualPath.init(path:))) | ||
}) | ||
}, uniquingKeysWith: { $1 }) |
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.
This behavior looks good to me, and I think it's consistent with the C++ driver
a911c1d
to
224d9e6
Compare
224d9e6
to
bc1d31b
Compare
@owenv thanks for reviewing! |
@swift-ci please test |
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.
Thanks for working through this, it looks really good
This allows having relative paths on output file map json file.
Also, I've made working directory to default to cwd if no
-working-directory
arg is supplied.Also, there is small bug, if there is two identical inputs in output file map, driver would silently crash, as it uses
Dictionary(uniqueKeysWithValues:)
initializer, now it will choose last record (behaviour that usually seen in clang, for example), but is it better to have warning or error? There is some difficulty thought, as closure that handles duplicates doesn't have key as argument, so we need to find duplicates beforehand.Also, it looks that there is a lot of dangling whitespaces, is it ok to remove them? May be e need some codestyle tool (swift-format?) that will make codestyle automated?
This is my first contribution to swift project, so any help would be very much appreciated :)