Skip to content

Commit

Permalink
Update rules_cc to use the correct toolchain type (@bazel_tools//tool…
Browse files Browse the repository at this point in the history
…s/cpp:toolchain_type).

PiperOrigin-RevId: 361158816
Change-Id: Ief011b23ddb9bdf3b49237f90fa631b6f916e8de
  • Loading branch information
katre authored and Copybara-Service committed Mar 5, 2021
1 parent 25193de commit 88ef31b
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cc/find_cc_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cc/private/rules_impl/cc_flags_supplier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
2 changes: 1 addition & 1 deletion cc/private/rules_impl/compiler_flag.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
)
2 changes: 1 addition & 1 deletion examples/experimental_cc_shared_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)

Expand Down
2 changes: 1 addition & 1 deletion examples/my_c_archive/my_c_archive.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
2 changes: 1 addition & 1 deletion examples/my_c_compile/my_c_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
2 changes: 1 addition & 1 deletion examples/write_cc_toolchain_cpu/write_cc_toolchain_cpu.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit 88ef31b

Please sign in to comment.