我有这样的规则
do_action = rule (
implementation = _impl,
attrs = {
...
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
},
fragments = ["cpp"],
toolchains = [
"@bazel_tools//tools/cpp:toolchain_type",
],
)
我为自定义 cpu 定义了自定义 cc_toolchain:
toolchain(
name = "cc-toolchain-%{toolchain_name}",
toolchain = ":cc-compiler-%{toolchain_name}",
# can be run on this platform
target_compatible_with = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"%{cpu}": ":cc-compiler-%{toolchain_name}",
},
)
我--crostool_top
会在需要时选择此工具链。
我只想在 --crostool_top 与我的自定义工具链之一匹配时才允许调用我的自定义规则。这个怎么做?