Add protocopt option to protoc go compiler#2788
Add protocopt option to protoc go compiler#2788prestonvanloon wants to merge 3 commits intobazel-contrib:masterfrom
Conversation
|
@bazelbuild/go-maintainers Please comment if you have any thoughts on this PR. |
|
LGTM, would it be possible to add a testcase that exercises this? |
|
Added test scenario for this PR. Thanks! |
|
Hrm... I triggered re-run on the windows break 3 times just to get more data. I have absolutely NO idea what that means... |
|
Maybe something to do with the update in protoc. I didn't test anything for windows :( |
|
Yeah, I don't really know what to do here. I don't have a windows box to test on. @jayconrod do you have a windows box for debugging? |
|
I think this is protocolbuffers/protobuf#8049: protoc 3.14 doesn't build with MinGW on Windows. We probably need to exclude this test on Windows in .bazelci/presubmit.yml (both in the |
|
@jayconrod I've seen a couple of projects tag as |
|
No strong opinion, but if a target fundamentally doesn't work on Windows (for example, if it tests At the moment, we basically don't have test coverage for |
|
This PR should no longer be required for field presence support since 3.15 (where "optional" is enabled by default). |
|
@ah-edg Excellent! Let's close this. Users of proto3 optional can update to protoc 3.5.0 or later. |
|
Just to clarify, I decided to close this since the experimental protoc flag was the use case to support this functionality. |
…le_with (bazel-contrib#2788) This routine already copies `compatible_with`, which is little used, but does not copy `target_compatible_with`, which is broadly used. This seems like an oversight. I noticed this discrepancy when working on a system that assumes that any `tags` or `target_compatible_with` parameters supplied to a macro will propagate to all rules created by that macro. In rules_python, this already works for `tags`, but not for `target_compatible_with`. It would be great to get this accepted upstream, so that I can stop patching rules_python. --------- Co-authored-by: Richard Levasseur <richardlev@gmail.com>
What type of PR is this?
Feature
What does this PR do? Why is it needed?
This PR allows for downstream projects to define a go proto compiler that requires additional protoc arguments.
Example usage:
Which issues(s) does this PR fix?
Fixes #2673
Other notes for review
Opening as a draft to solicit early review.
This is missing any form of tests would like to receive some feedback from maintainers before proceeding.
Ideally, this functionality would be better implemented if the
--protocoptflag was exposed via the starlark API, i.e.--protocopt=--experimental_allow_proto3_optionalin the command line, however, it does not seem possible to access this flag in starlark. So, I have taken this approach to allow the arguments to be provided as target attributes on the go_proto_compiler rule.