-
Notifications
You must be signed in to change notification settings - Fork 140
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
Make rules_swift work with virtual import directories. #298
Changes from 5 commits
afe7cf0
1f96a9e
72427ed
285ce60
abde1bb
6d5a84d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,3 +251,20 @@ def workspace_relative_path(file): | |
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is anything left using workspace_relative_path or should it be made private to this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You cannot know that -- anyone can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Actually, it is in an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So be it then! |
||
workspace_path = paths.join(file.root.path, file.owner.workspace_root) | ||
return paths.relativize(file.path, workspace_path) | ||
|
||
def proto_import_path(f, proto_source_root): | ||
""" Returns the import path of a `.proto` file given its path. | ||
|
||
Args: | ||
f: The `File` object representing the `.proto` file. | ||
proto_source_root: The source root for the `.proto` file. | ||
|
||
Returns: | ||
The path the `.proto` file should be imported at. | ||
""" | ||
if f.path.startswith(proto_source_root): | ||
return f.path[len(proto_source_root) + 1:] | ||
else: | ||
# Happens before Bazel 1.0, where proto_source_root was not | ||
# guaranteed to be a parent of the .proto file | ||
return workspace_relative_path(f) |
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 this part still true, or is the output path now slightly different since it might not have some the the original workspace relative info?
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.
My understanding is that this is still true -- the format is
PACKAGE/NAME.protoc_gen_EXTENSION_swift/IMPORT_PATH.<something>
, to which all of this is true. Except that the path now contains the import path and not the workspace-relative path of the source file.