-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Applying fixer for grpc_go_plugin plugin #146
Comments
That rule is marked as experimental, so we’re free to change it in a breaking way without bumping the major version anyway. IIRC, the issue is that the validate_library rule needs to bundle at least the protobuf plugin and dep to actually build correctly. So we could split it out to two rules go_proto_validate_library and go_grpc_validate_library, but I don’t think we can have a go_validate_library that has only the validate plugin. Alternatively we could however retain a go_validate_compile that just has the validate plugin, then just add ‘validate’ attrs to the library rules. Do you have an example of how you expect to use the rules? |
Here is what I currently do using my own plugin definition. I pretty much swapped my own So you can see that I have two macros: So I would expect to continue to use the rule this way, but I'm also open to doing something else as long as it makes sense :) I don't care much about the I think what you are proposing makes sense. |
Ok, thanks for the details. Once I have a PR for this, I'll add you as a reviewer to check I'm not doing something too wild 😄 |
This is causing some grief again... |
Workaround is to define custom rules like so: load(
"@rules_proto_grpc//:defs.bzl",
"ProtoPluginInfo",
"proto_compile_attrs",
"proto_compile_impl",
)
go_grpc_compile = rule(
implementation = proto_compile_impl,
attrs = dict(
proto_compile_attrs,
_plugins = attr.label_list(
providers = [ProtoPluginInfo],
default = [
Label("@rules_proto_grpc//go:grpc_go_plugin"),
],
doc = "List of protoc plugins to apply",
),
),
toolchains = [str(Label("@rules_proto_grpc//protobuf:toolchain_type"))],
)
go_validate_compile = rule(
implementation = proto_compile_impl,
attrs = dict(
proto_compile_attrs,
_plugins = attr.label_list(
providers = [ProtoPluginInfo],
default = [
Label("@rules_proto_grpc//go:validate_go_plugin"),
],
doc = "List of protoc plugins to apply",
),
),
toolchains = [str(Label("@rules_proto_grpc//protobuf:toolchain_type"))],
) |
Description
I'm getting a lot of such messages with 4.0.0 and new
go_validate_compile()
:Looking at the sources in https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/go/go_validate_compile.bzl and https://github.com/rules-proto-grpc/rules_proto_grpc/blob/master/go/go_grpc_compile.bzl looks like they both include the gRPC plugin and validate includes all three plugins.
In my project I call each compile rule independently and explicitly, depending on which proto file I'm compiling. So, I didn't expect these rules to try to do this all for me :) Quite a few proto files in my project use the validator plugin but not gRPC and I think that explains why I'm getting those messages.
I'm not sure what to suggest here. I just expected each rule to do one thing only so that they can be composed (via macros) by the end user to do what is necessary. I'm not sure what to do with the existing approach - I was trying to get rid of my custom plugin definition for the validate plugin but looks like I cannot. I prefer to not have those warnings and to not do the compilation work multiple times.
Would it be possible to remove proto and grpc plugins from the validate rule definition? It's probably not too late as 4.0.0 has just been released and not many people use it (it's a breaking change).
The text was updated successfully, but these errors were encountered: