-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Bazel: How can I compile gRPC java without having to compile protoc? #11764
Comments
I know grpc-kotlin uses grpc-java runtime, and protoc kotlin for messages which uses protoc java for messages. But does the generated code actually depend on protoc-gen-grpc-java generated code? Looking at the example, it seems so. I have spoken to Alex about aspect-build. But we (grpc) is not actively spending time on it. There are already pre-built binaries available on Maven Central, so most of what is needed is probably plumbing and glue. Yes, grpc-java has a limited toolchain, but it was more to consume the other toolchain stuff that has been going on, in particular to trigger some specialized Android goo. No work has been made to allow the toolchain to be customized (and I still don't understand how the toolchains work in Bazel). I have been waiting for proto_lang_toolchain to become available. Twice a year or so I check on it and it there hadn't been much to show for it over the years. I've not looked into it yet, but I understand that things have improved in recent Bazel with the movement of rules_proto finally out of Bazel and not being bound to com_google_protobuf for the runtime. Most of my time over the years on Bazel rules has been dealing with the com_google_protobuf dependency. I'm quite open to changes, but we will need to think about the upgrade story and I assume support both old and new ways simultaneously. |
Thanks @ejona86! This all sounds very reasonable! I'd say the next steps (for me, or anyone else interested in this work) is:
And yes, all the new Bazel 8.X can make this all moot, so I guess there's an option to wait until protocolbuffers/protobuf#19558 is resolved. What's the best way to track this work? This issue? |
As discovered at #11767 (comment), there are problems depending on Bazel 8, rules_proto 7, and (already known) newer protobufs that probably have good things in them. I think rules_proto 6 may be enough to let things move forward, but that is a complication. I see a notice that toolchains_protoc is currently broken with Bazel 8 and will only be fixed in a future protobuf release. We may find this issue to be premature, but there may still be ways to make progress. I think that notice is because protobuf made the toolchains private. I'll note that any refactoring should probably first move to proto_lang_toolchain(). We wouldn't want to make our toolchain public without first being on proto_lang_toolchain(). I see protobuf has their toolchains as private. As we are refactoring, we should probably do the same, until we are certain things are ready. As long as protobuf has a private toolchain, you must use the Bazel build from protobuf and not depend on Java binaries on Maven Central. I'd be very happy to split out the grpc-java rule to its own repository and not require building grpc-java's Java dependencies from source. But right now you need |
Hi! I'm on a journey to try to eradicate having bazel build protoc each time in favor of using prebuilt binaries. I'm really after kotlin, but it has a hard dependency on grpc-java and here I am.
https://github.com/aspect-build/toolchains_protoc has made some progress in that for regular proto generation, but it seems like grpc java generation still requires building protoc from source, plausibly to build the plugin. Looks like there're also precompiled plugin source distributed via source, but I don't see an easy way to switch to use them.
Hopefully patches are welcome. :)
The text was updated successfully, but these errors were encountered: