Skip to content

Commit 6539aad

Browse files
committed
Add target_compatible_with parameter to proto_toolchain in Bazel rules
In some cases, few targets can require different proto_toolchains.
1 parent 3e935cf commit 6539aad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

bazel/toolchains/proto_toolchain.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The macro additionally creates toolchain target when toolchain_type is given.
1313
load("//bazel/private:proto_toolchain_rule.bzl", _proto_toolchain_rule = "proto_toolchain")
1414
load("//bazel/private:toolchain_helpers.bzl", "toolchains")
1515

16-
def proto_toolchain(*, name, proto_compiler, exec_compatible_with = []):
16+
def proto_toolchain(*, name, proto_compiler, exec_compatible_with = [], target_compatible_with = []):
1717
"""Creates a proto_toolchain and toolchain target for proto_library.
1818
1919
Toolchain target is suffixed with "_toolchain".
@@ -22,13 +22,14 @@ def proto_toolchain(*, name, proto_compiler, exec_compatible_with = []):
2222
name: name of the toolchain
2323
proto_compiler: (Label) of either proto compiler sources or prebuild binaries
2424
exec_compatible_with: ([constraints]) List of constraints the prebuild binary is compatible with.
25+
target_compatible_with: ([constraints]) List of constraints the target it is compatible with.
2526
"""
2627
_proto_toolchain_rule(name = name, proto_compiler = proto_compiler)
2728

2829
native.toolchain(
2930
name = name + "_toolchain",
3031
toolchain_type = toolchains.PROTO_TOOLCHAIN,
3132
exec_compatible_with = exec_compatible_with,
32-
target_compatible_with = [],
33+
target_compatible_with = target_compatible_with,
3334
toolchain = name,
3435
)

0 commit comments

Comments
 (0)