Skip to content

Commit

Permalink
Use the helper for declaring the cc toolchain type on rules in builtins.
Browse files Browse the repository at this point in the history
Part of #14727.

PiperOrigin-RevId: 449703810
  • Loading branch information
katre authored and copybara-github committed May 19, 2022
1 parent 2f03f9c commit 798bd5e
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -994,9 +994,7 @@ def make_cc_binary(cc_binary_attrs, **kwargs):
exec_groups = {
"cpp_link": exec_group(copy_from_rule = True),
},
toolchains = [
"@" + semantics.get_repo() + "//tools/cpp:toolchain_type",
],
toolchains = cc_helper.use_cpp_toolchain(),
incompatible_use_toolchain_transition = True,
executable = True,
**kwargs
Expand Down
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ cc_import = rule(
),
"_cc_toolchain": attr.label(default = "@" + semantics.get_repo() + "//tools/cpp:current_cc_toolchain"),
},
toolchains = ["@" + semantics.get_repo() + "//tools/cpp:toolchain_type"], # copybara-use-repo-external-label
toolchains = cc_helper.use_cpp_toolchain(),
fragments = ["cpp"],
incompatible_use_toolchain_transition = True,
)
2 changes: 1 addition & 1 deletion src/main/starlark/builtins_bzl/common/cc/cc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ attrs.update(semantics.get_interface_deps_allowed_attr())
cc_library = rule(
implementation = _cc_library_impl,
attrs = attrs,
toolchains = ["@" + semantics.get_repo() + "//tools/cpp:toolchain_type"],
toolchains = cc_helper.use_cpp_toolchain(),
fragments = ["cpp"] + semantics.additional_fragments(),
incompatible_use_toolchain_transition = True,
provides = [CcInfo],
Expand Down
4 changes: 1 addition & 3 deletions src/main/starlark/builtins_bzl/common/cc/cc_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ def make_cc_test(with_linkstatic = False):
exec_groups = {
"cpp_link": exec_group(copy_from_rule = True),
},
toolchains = [
"@" + semantics.get_repo() + "//tools/cpp:toolchain_type",
],
toolchains = cc_helper.use_cpp_toolchain(),
incompatible_use_toolchain_transition = True,
test = True,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ cc_shared_library = rule(
default = Label("@" + semantics.get_repo() + "//tools/cpp:grep-includes"),
),
},
toolchains = ["@" + semantics.get_repo() + "//tools/cpp:toolchain_type"], # copybara-use-repo-external-label
toolchains = cc_helper.use_cpp_toolchain(),
fragments = ["google_cpp", "cpp"],
incompatible_use_toolchain_transition = True,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"""apple_static_library Starlark implementation"""

load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
load("@_builtins//:common/objc/attrs.bzl", "common_attrs")
load("@_builtins//:common/objc/linking_support.bzl", "linking_support")
load("@_builtins//:common/objc/semantics.bzl", "semantics")
Expand Down Expand Up @@ -152,6 +153,6 @@ apple_static_library = rule(
},
cfg = apple_crosstool_transition,
fragments = ["objc", "apple", "cpp"],
toolchains = ["@" + semantics.get_repo() + "//tools/cpp:toolchain_type"],
toolchains = cc_helper.use_cpp_toolchain(),
incompatible_use_toolchain_transition = True,
)
3 changes: 1 addition & 2 deletions src/main/starlark/builtins_bzl/common/objc/objc_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

"""objc_import Starlark implementation replacing native"""

load("@_builtins//:common/objc/semantics.bzl", "semantics")
load("@_builtins//:common/objc/attrs.bzl", "common_attrs")
load("@_builtins//:common/objc/compilation_support.bzl", "compilation_support")
load("@_builtins//:common/cc/cc_helper.bzl", "cc_helper")
Expand Down Expand Up @@ -58,6 +57,6 @@ objc_import = rule(
common_attrs.XCRUN_RULE,
),
fragments = ["objc", "apple", "cpp"],
toolchains = ["@" + semantics.get_repo() + "//tools/cpp:toolchain_type"],
toolchains = cc_helper.use_cpp_toolchain(),
incompatible_use_toolchain_transition = True,
)
3 changes: 1 addition & 2 deletions src/main/starlark/builtins_bzl/common/objc/objc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

"""objc_library Starlark implementation replacing native"""

load("@_builtins//:common/objc/semantics.bzl", "semantics")
load("@_builtins//:common/objc/compilation_support.bzl", "compilation_support")
load("@_builtins//:common/objc/attrs.bzl", "common_attrs")
load("@_builtins//:common/objc/transitions.bzl", "apple_crosstool_transition")
Expand Down Expand Up @@ -254,6 +253,6 @@ objc_library = rule(
),
fragments = ["objc", "apple", "cpp"],
cfg = apple_crosstool_transition,
toolchains = ["@" + semantics.get_repo() + "//tools/cpp:toolchain_type"],
toolchains = cc_helper.use_cpp_toolchain(),
incompatible_use_toolchain_transition = True,
)

0 comments on commit 798bd5e

Please sign in to comment.