1# Protocol Buffers - Google's data interchange format 2# Copyright 2024 Google Inc. All rights reserved. 3# 4# Use of this source code is governed by a BSD-style 5# license that can be found in the LICENSE file or at 6# https://developers.google.com/open-source/licenses/bsd 7# 8"""Macro wrapping the proto_toolchain implementation. 9 10The macro additionally creates toolchain target when toolchain_type is given. 11""" 12 13load("//bazel/private:proto_toolchain_rule.bzl", _proto_toolchain_rule = "proto_toolchain") 14load("//bazel/private:toolchain_helpers.bzl", "toolchains") 15 16def proto_toolchain(*, name, proto_compiler, exec_compatible_with = []): 17 """Creates a proto_toolchain and toolchain target for proto_library. 18 19 Toolchain target is suffixed with "_toolchain". 20 21 Args: 22 name: name of the toolchain 23 proto_compiler: (Label) of either proto compiler sources or prebuild binaries 24 exec_compatible_with: ([constraints]) List of constraints the prebuild binary is compatible with. 25 """ 26 _proto_toolchain_rule(name = name, proto_compiler = proto_compiler) 27 28 native.toolchain( 29 name = name + "_toolchain", 30 toolchain_type = toolchains.PROTO_TOOLCHAIN, 31 exec_compatible_with = exec_compatible_with, 32 target_compatible_with = [], 33 toolchain = name, 34 ) 35