Update rules_cc to use the correct toolchain type (@bazel_tools//tools/cpp:toolchain_type).

PiperOrigin-RevId: 361158816
Change-Id: Ief011b23ddb9bdf3b49237f90fa631b6f916e8de
This commit is contained in:
Googler 2021-03-05 09:10:01 -08:00 committed by Copybara-Service
parent 25193de8f5
commit 88ef31b429
7 changed files with 9 additions and 9 deletions

View File

@ -40,7 +40,7 @@ Returns the current `CcToolchainInfo`.
foo = rule(
implementation = _foo_impl,
toolchains = [
"@rules_cc//cc:toolchain_type", # copybara-use-repo-external-label
"@bazel_tools//tools/cpp:toolchain_type", # copybara-use-repo-external-label
],
)
@ -63,9 +63,9 @@ Returns the current `CcToolchainInfo`.
# Check the incompatible flag for toolchain resolution.
if hasattr(cc_common, "is_cc_toolchain_resolution_enabled_do_not_use") and cc_common.is_cc_toolchain_resolution_enabled_do_not_use(ctx = ctx):
if not "//cc:toolchain_type" in ctx.toolchains:
if not "@bazel_tools//tools/cpp:toolchain_type" in ctx.toolchains: # copybara-use-repo-external-label
fail("In order to use find_cc_toolchain, your rule has to depend on C++ toolchain. See find_cc_toolchain.bzl docs for details.")
toolchain_info = ctx.toolchains["//cc:toolchain_type"]
toolchain_info = ctx.toolchains["@bazel_tools//tools/cpp:toolchain_type"] # copybara-use-repo-external-label
if hasattr(toolchain_info, "cc_provider_in_toolchain") and hasattr(toolchain_info, "cc"):
return toolchain_info.cc
return toolchain_info

View File

@ -30,7 +30,7 @@ cc_flags_supplier = rule(
attrs = {
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
},
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], # copybara-use-repo-external-label
incompatible_use_toolchain_transition = True,
fragments = ["cpp"],
)

View File

@ -26,6 +26,6 @@ compiler_flag = rule(
"_cc_toolchain": attr.label(default = Label("//cc:current_cc_toolchain")),
},
toolchains = [
"@rules_cc//cc:toolchain_type", # copybara-use-repo-external-label
"@bazel_tools//tools/cpp:toolchain_type", # copybara-use-repo-external-label
],
)

View File

@ -460,7 +460,7 @@ cc_shared_library = rule(
"_experimental_debug": attr.label(default = "//examples:experimental_debug"),
"_incompatible_link_once": attr.label(default = "//examples:incompatible_link_once"),
},
toolchains = ["@rules_cc//cc:toolchain_type"], # copybara-use-repo-external-label
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], # copybara-use-repo-external-label
fragments = ["cpp"],
)

View File

@ -95,6 +95,6 @@ my_c_archive = rule(
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
},
fragments = ["cpp"],
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], # copybara-use-repo-external-label
incompatible_use_toolchain_transition = True,
)

View File

@ -76,7 +76,7 @@ my_c_compile = rule(
"src": attr.label(mandatory = True, allow_single_file = True),
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
},
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], # copybara-use-repo-external-label
incompatible_use_toolchain_transition = True,
fragments = ["cpp"],
)

View File

@ -28,6 +28,6 @@ write_cc_toolchain_cpu = rule(
attrs = {
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
},
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"], # copybara-use-repo-external-label
incompatible_use_toolchain_transition = True,
)