-
-
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 and inconvenient go_proto_library #317
Comments
This is a pain point for a lot of projects. We've been discussing internally how to improve this, but we don't have a concrete plan. This is definitely on our roadmap though. |
If you want your code to build with 'go build', then you do have to put each proto in its own directory to satisfy Go, e.g. https://github.com/golang/protobuf/tree/master/ptypes/timestamp I agree that it is awkward, but talk to the Go team about that! We are looking at upgrading gazelle to handle bazel-style naming, e.g. multiple things in a directory (but remember: those won't build with 'go build', and will break any go tooling/IDEs) |
@pmbethe09 I believe I've seen @jayconrod commented in another issue on make With the help of
The outer BUILD file has:
And the inner one has:
By doing this, I can have proto files in one place, and have the |
We support building with the native Go toolchain already. You can just call
If I understand correctly, you need the This does seem a little inconvenient, but in the near future (when #859 is closed), you'll be able to set the |
My understanding for "work with native go toolchain" here is that to organize the go code in a bazel workspace in a way that host
That's right. By doing this, it generates all the files in the correct directory, which host go toolchain understands. Other tools like Ideally I want be able to generate different |
There's no way to do this in a single build with the proto rules at the moment, since they are designed around toolchains, and only one proto toolchain can be active at a time. We may need to reconsider our design here if compiling with multiple plugins in a common use case. The toolchain thing is a general Bazel problem: it also prevents us from compiling binaries for multiple platforms in the same build, which is something Kubernetes and other projects want. Toolchains are a new feature, so hopefully this will continue to improve.
Just to clarify, if you were able to generate multiple |
@jayconrod Most of these issues are from the need of creating grpc gateway packages. For our case, we have two separate servers for every exposed services, one grpc server, and one grpc-gateway server. The former don't really need the code generated by the grpc-gateway plugin, while the latter requires it to build. Although the gateway version of go_library is completely compatible with the grpc version, it does introduce many unneeded dependencies to the build graph, which I intend to avoid. One solution is to allow build two 'go_libraries' from a single proto file. When build different binaries, use different version of generated package. Also note that, for the grpc-gateway plugin, it depends on the output of grpc plugin -- as it only generates partial output -- an additional |
It sounds like you might need to define a new The two libraries would have the same @ianthehat Does that sound about right? |
This is problematic, which means I have to manually maintain those build files, and it's error prone. I'd prefer to generate those targets in different packages so we can distinguish them at the import time -- and make
Yeah, I've made it an optional attribute to allow manually setting it when necessary, which also opens the opportunity to chain up with other protoc generated grpc code (eg. gogo -- not our case though). |
Ok, we're going to try moving in a bit of a different direction. #1098 is a change to We still don't have a good way to change the import path. It doesn't seem like there's a way to do this without changing the proto file as it's being compiled or changing the binary proto descriptor. |
#1098 LGMT. Looking forward to having it checked in. |
#1098 and some related changes are checked in and released. The one thing that is still wrong is that Gazelle will generate I'll close this issue now, but please take a look and reopen if we're missing something. |
gazelle lists all imports as
xxx:go_default_library
in generated deps, butgo_proto_library
doesn't satisfy this convention, unless the proto file is put underxxx_proto
directory and being called asname="go_default_library"
. Which is awkward.#315 should address this issue as well.
The text was updated successfully, but these errors were encountered: