Skip to content
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

Protobuf fixes for Bazel 0.29 #288

Closed
wants to merge 2 commits into from
Closed

Protobuf fixes for Bazel 0.29 #288

wants to merge 2 commits into from

Conversation

steeve
Copy link
Contributor

@steeve steeve commented Aug 20, 2019

Fixes #287

The fix was stolen from various patches found in bazelbuild/bazel#7157

@steeve
Copy link
Contributor Author

steeve commented Aug 20, 2019

It might be a good idea to backport this on 0.12, since rules_swift master is not compatible with the latest swift-protobuf release because of 8d61a41

steeve added 2 commits August 21, 2019 14:10
register_module_mapping_write_action expects a string, not a target.

Signed-off-by: Steeve Morin <[email protected]>
The change was introduced in #1.

1. bazelbuild/bazel#7157

Signed-off-by: Steeve Morin <[email protected]>
@@ -270,7 +270,7 @@ def _swift_protoc_gen_aspect_impl(target, aspect_ctx):
minimal_module_mappings.extend(_gather_transitive_module_mappings(proto_deps))

transitive_module_mapping_file = register_module_mapping_write_action(
target,
target.label.name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed for Bazel 0.29, but I figure I would take the change and fix it anyway, that's why it's in its own commit

register_module_mapping_write_action expects a string, not a target

The bug was that the file was named path/to/the/file/<generated //xxxxx>.yyy

@steeve
Copy link
Contributor Author

steeve commented Aug 22, 2019

Also if you want I can change the commit/PR to be:

Add support for --incompatible_generated_protos_in_virtual_imports

Since things have changed.

# paths (e.g. using strip_import_prefix / import_prefix attributes)
virtual_imports = "/_virtual_imports/"
if virtual_imports in file.path:
return file.path.split(virtual_imports)[1].split("/", 1)[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the ongoing discussion on bazelbuild/bazel#9215, I'm not sure this is right since it seems like we'd need to pick up a different root also to properly handle generated proto files.

Copy link
Contributor Author

@steeve steeve Aug 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure:

When this flag is flipped, the two .proto files are both symlinked into a directory bazel-bin/x/virtual_imports/p) and that's what proto_source_root will be.

In the above case, it depends on whether foo.proto is generated or not. If it is not, the proto path of the proto compile action of :bar will be . and bazel-bin/x/_virtual_imports/p. If it is, in addition to that, bazel-bin/m/n/o/_virtual_imports/foo will also be there.

Also, the fix is from:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what is being said, yea, they also won't handle a generated proto file being used (unless they are hardcoding other output paths into the proto search path for their protoc invokes)

@thomasvl
Copy link
Member

I believe #298 covers this using the data from the provider vs. hardcoding things.

@thomasvl thomasvl closed this Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to depend on WKTs with Bazel 0.29
3 participants