github.com/bazelbuild/rules_go@v0.47.2-0.20240515105122-e7ddb9ea474e/proto/private/toolchain.bzl (about)

     1  # Copyright 2024 The Bazel Authors. All rights reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #    http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  # Helper that wraps --proto_compiler into a ProtoLangToolchainInfo for backwards
    16  # compatibility with --noincompatible_enable_proto_toolchain_resolution.
    17  
    18  load(
    19      "@rules_proto//proto:proto_common.bzl",
    20      "ProtoLangToolchainInfo",
    21  )
    22  load(
    23      "//go/private/rules:transition.bzl",
    24      "non_go_tool_transition",
    25  )
    26  
    27  def _legacy_proto_toolchain_impl(ctx):
    28      return [
    29          ProtoLangToolchainInfo(
    30              proto_compiler = ctx.attr._protoc.files_to_run,
    31          ),
    32      ]
    33  
    34  legacy_proto_toolchain = rule(
    35      implementation = _legacy_proto_toolchain_impl,
    36      cfg = non_go_tool_transition,
    37      attrs = {
    38          "_protoc": attr.label(
    39              default = configuration_field(fragment = "proto", name = "proto_compiler"),
    40          ),
    41          "_allowlist_function_transition": attr.label(
    42              default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
    43          ),
    44      },
    45      fragments = ["proto"],
    46  )