rules_proto icon indicating copy to clipboard operation
rules_proto copied to clipboard

Add current_proto_toolchain

Open psalaberria002 opened this issue 1 year ago • 6 comments

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:

load("@rules_proto//proto:defs.bzl", "current_proto_toolchain")

current_proto_toolchain(
    name = "current_proto_toolchain",
    visibility = ["//visibility:public"],
)

genrule(
    name = "x",
    srcs = [":current_proto_toolchain"],
    outs = ["x"],
    cmd = "$(PROTOC) > $(OUTS)",
    toolchains = [":current_proto_toolchain"],
)

How should we test this feature?

Is there any other preferred alternative for exposing the current protoc binary after toolchain resolution?

psalaberria002 avatar May 21 '24 14:05 psalaberria002