-
-
Notifications
You must be signed in to change notification settings - Fork 662
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
Gazelle is generating helloworld_proto_proto instead of helloworld_proto #1118
Comments
Gazelle generates the name for There are a few heuristics for determining the package name. Gazelle tries to predict what the proto compiler will do.
If these heuristics aren't working correctly, could you post a small proto file that shows this problem? |
Ah I see. Thanks for the explanation Jay! |
@jayconrod - what is the significance of the name of a I'm sharing a I could manually specify |
@cgrushko There's no significance to the name of a The important thing is that the value in |
If I understand correctly, it means that Gazelle can choose a different name for the Unless the issue is that Gazelle puts multiple Alternatively, Gazelle should detect existing Does one (or both) approaches seem reasonable? |
Gazelle will name the rule
Gazelle only supports one package per directory right now. It groups source files (including protos) by Go package name. If there are multiple .proto files that will generate .go files with the same package name, they will be grouped in the same rule. Supporting multiple packages is really something I want to improve, but there's a ton of stuff going on, and I haven't had time yet.
Could you expand on that (publicly or privately)? I know you have a lot more experience here with the Blaze proto rules. Why shouldn't protos in the same package be grouped in the same rule?
I intend to do this at some point (it will be necessary for multiple packages or multiple binaries / tests to ever work), but it will be hard to get it right. |
There's something about protos that causes people to make huge piles of them in a single directory called "proto". The situation is bad as it is with people putting way too many messages and services into the same .proto file, so I think that extending this to directories would mean a single proto rule for the entire project. For small projects that's no big deal, but as a project grows this becomes a drag on productivity as build times suffer, all tests trigger on each change, flaky tests deteriorate the benefits of your CI, etc. I might be overreacting :) for now, I use the names that Gazelle generates. I got beauties such as
which is a pain in the ass to use, but not the end of the world. |
I strongly agree that it would be nice if Gazelle supported having separate rules per proto. This is especially important if you have monolithic services (see Gaia or super hot) where there are a dozens or hundreds of proto files that compose a single service. With the current grouping of all proto files into a single target if you need to use one aspect of the service you are forced to depend on all the photos in the service if they are placed in a single directory. There are many issues with this as highlighted by Carmi but I think the worst are the increase in presubmit time due to increased build time and unecessary test targets being triggered, and binary bloat. |
Typed from a device I sit on, excuse the typos. |
I'm pretty much in agreement. I've filed bazel-contrib/bazel-gazelle#138 to implement this. |
When I run Gazelle from an empty build target for a proto file named helloworld.proto containing a grpc service, Gazelle generates:
proto_library(
name = "helloworld_proto_proto",
srcs = ["helloworld.proto"],
visibility = ["//visibility:public"],
)
go_grpc_library(
name = "helloworld_proto_go_proto",
importpath = "foo/builds/examples/protobuf",
proto = ":helloworld_proto_proto",
visibility = ["//visibility:public"],
)
go_library(
name = "go_default_library",
importpath = "foo/builds/examples/protobuf",
library = ":helloworld_proto_go_proto",
)
Thoughts on why its appending a _proto twice?
The text was updated successfully, but these errors were encountered: