-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Support passing options to plugins though a separate flag #68
Comments
I going to close this as a duplicate of #54, which is blocked on bazelbuild/bazel#8494. You can subscribe to those two, but believe me there’s great desire to see this supported! You can see there’s been some discussion in those two issues, but fundamentally we are stuck until Bazel itself has support. In the meantime, if you are defining your own plugins, you can specify a static list of options (again see #54 for example). Also, I’ve not seen buf before, it looks interesting for the linter and breaking change detector. It might be worth adding as a plugin option here 🤔 |
Sorry, but I was able to do it locally just fine in my aspect.bzl:
args.add("--{}_out={}".format(plugin_name, out_arg))
+++ if plugin.extra_options:
+++ args.add_all(plugin.extra_options) And then just piped the Is this solution going to break anything else I'm not aware of? |
Read through the existing issue. I believe that this is not a duplicate because my idea is to define options per plugin, not per target. Although per-target options would be nice as well, but that is indeed a separate issue, |
Plugins presently support passing in options, such as: rules_proto_grpc/nodejs/BUILD.bazel Lines 6 to 9 in 7e0a97a
Is this what you need? |
As I said in the initial comment, this won't work. Take a close look at the documentation. It requires it's own flag name:
|
Ok, I’ve got you now, sorry. JSON in a command line arg is somewhat nuts...but should be supportable. In theory we should just pass all options to plugins via *_opt rather than *_out, but when this was trialled previously there was some issue with certain plugins, if I remember correctly. Looking at the protoc cli source there shouldn’t really be a difference from the plugin’s perspective, so we can try flipping it again and see what CI has to say. If it’s still a problem, it could be an opt-in plugin option. |
I can confirm that the opt-in plugin option does indeed work on quite complex proto graphs. However, I found a small issue with the idea of a linter. I use
This is of course for all libraries that are transitive dependencies of more than one library. Can't say this is absolutely critical, but it's just unnecessary noise. |
… `_out` protoc argument. Fix rules-proto-grpc#68.
See attached commit for a prototype implementation. |
I feel like |
Hi, sorry this has sat so long. Would adding a flag to each plugin that determines whether it sets options via opt or out flag resolve this? If so, the steps in the next releases would be:
I agree re depsets, I'll add this shortly. |
Added in #84 |
Thanks Adam, however your implementation still doesn't work because the required flag name is UPD: honestly I'd probably also remove the custom code for the |
Wow this plugin is really breaking all the rules of protoc. The Are you passing the plugin into the |
Consider the aforementioned documentation quote:
It mentions:
So yes, the plugin is inconsistent with it's naming and thus the Note that I'm in no way affiliated with |
Adding this in 3.0.0 release as a 'extra_protoc_args' attr on plugins |
For example buf requires passing it's config through
--buf-check-lint_opt
instead of-buf-check-lint_out
. This aspect doesn't support passing options though a non-out argument.The text was updated successfully, but these errors were encountered: