Add current_proto_toolchain#214
Conversation
After asking in https://bazelbuild.slack.com/archives/C04281DTLH0/p1716279966809639 I gave it a tried, and it seems to be working. The implementation is based on https://github.com/bazelbuild/rules_python/blob/730a2e39bd2702910f28629d4583b3ec49f4ee5e/python/current_py_toolchain.bzl
thesayyn
left a comment
There was a problem hiding this comment.
LGTM, maybe a genrule test for it so we know it works?
I get Is it possible to register toolchains only for running tests, but not when publishing the module? |
|
i think so yes, https://bazel.build/rules/lib/globals/module#register_toolchains has an attribute dev_dependency. |
|
we already depend on protobuf repo which has a protoc binary which can be registered as a toolchain only as a dev dep. Line 18 in d205d37 |
1f62032 to
d463d3c
Compare
|
|
It was recommended in the Slack workspace. Whats the alternative for accessing the protoc binary when using the toolchain? |
Hmm, what is it being replaced with? Currently, in order to use a toolchain in a genrule, you need a target to materialize a toolchain type and return some providers according to this issue. This target is also important to workaround issues such as bazelbuild/bazel#19645 |
After asking in https://bazelbuild.slack.com/archives/C04281DTLH0/p1716279966809639 I gave it a tried, and it seems to be working.
The implementation is based on https://github.com/bazelbuild/rules_python/blob/730a2e39bd2702910f28629d4583b3ec49f4ee5e/python/current_py_toolchain.bzl
Tested with the following snippet:
How should we test this feature?
Is there any other preferred alternative for exposing the current protoc binary after toolchain resolution?