xref: /aosp_15_r20/external/bazelbuild-rules_rust/proto/protobuf/legacy_proto_toolchain.bzl (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1"""Helper that wraps --proto_compiler into a ProtoLangToolchainInfo for backwards
2compatibility with --noincompatible_enable_proto_toolchain_resolution.
3
4Borrowed from https://github.com/bazelbuild/rules_go/pull/3919
5"""
6
7load(
8    "@rules_proto//proto:proto_common.bzl",
9    "ProtoLangToolchainInfo",
10)
11
12def _legacy_proto_toolchain_impl(ctx):
13    return [
14        ProtoLangToolchainInfo(
15            proto_compiler = ctx.attr._protoc.files_to_run,
16        ),
17    ]
18
19legacy_proto_toolchain = rule(
20    implementation = _legacy_proto_toolchain_impl,
21    attrs = {
22        "_protoc": attr.label(
23            cfg = "exec",
24            default = configuration_field(fragment = "proto", name = "proto_compiler"),
25        ),
26    },
27    fragments = ["proto"],
28)
29