From d5c788f684314916748bf418ce99014b2ef41f66 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 21 Apr 2022 10:45:38 -0700 Subject: [PATCH] Move shared `_cc_toolchain` attribute to common `attrs.bzl` library. Similar to other shared attributes, this change moves the `_cc_toolchain`\ attribute to the shared `attr.bzl` library. RELNOTES: N/A PiperOrigin-RevId: 443420195 --- .../builtins_bzl/common/objc/apple_static_library.bzl | 8 +++----- src/main/starlark/builtins_bzl/common/objc/attrs.bzl | 8 ++++++++ .../starlark/builtins_bzl/common/objc/objc_import.bzl | 4 +--- .../starlark/builtins_bzl/common/objc/objc_library.bzl | 4 +--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/starlark/builtins_bzl/common/objc/apple_static_library.bzl b/src/main/starlark/builtins_bzl/common/objc/apple_static_library.bzl index 543744eb95339a..7a2034f1939c40 100644 --- a/src/main/starlark/builtins_bzl/common/objc/apple_static_library.bzl +++ b/src/main/starlark/builtins_bzl/common/objc/apple_static_library.bzl @@ -140,14 +140,12 @@ apple_static_library = rule( cfg = apple_common.multi_arch_split, default = "@" + semantics.get_repo() + "//tools/cpp:current_cc_toolchain", ), - "_cc_toolchain": attr.label( - default = "@" + semantics.get_repo() + "//tools/cpp:current_cc_toolchain", - ), }, + common_attrs.CC_TOOLCHAIN_RULE, common_attrs.LICENSES, - common_attrs.XCRUN_RULE, - common_attrs.SDK_FRAMEWORK_DEPENDER_RULE, common_attrs.PLATFORM_RULE, + common_attrs.SDK_FRAMEWORK_DEPENDER_RULE, + common_attrs.XCRUN_RULE, ), outputs = { "lipo_archive": "%{name}_lipo.a", diff --git a/src/main/starlark/builtins_bzl/common/objc/attrs.bzl b/src/main/starlark/builtins_bzl/common/objc/attrs.bzl index 848b8aec6a7902..5532bd4013d17b 100644 --- a/src/main/starlark/builtins_bzl/common/objc/attrs.bzl +++ b/src/main/starlark/builtins_bzl/common/objc/attrs.bzl @@ -20,6 +20,13 @@ ObjcInfo = _builtins.toplevel.apple_common.Objc AppleDynamicFrameworkInfo = _builtins.toplevel.apple_common.AppleDynamicFramework TemplateVariableInfo = _builtins.toplevel.platform_common.TemplateVariableInfo +# Private attribute required by `objc_internal.expand_toolchain_and_ctx_variables` +_CC_TOOLCHAIN_RULE = { + "_cc_toolchain": attr.label( + default = "@" + semantics.get_repo() + "//tools/cpp:current_cc_toolchain", + ), +} + _COMPILING_RULE = { "srcs": attr.label_list( allow_files = [ @@ -129,6 +136,7 @@ def _union(*dictionaries): common_attrs = struct( union = _union, + CC_TOOLCHAIN_RULE = _CC_TOOLCHAIN_RULE, COMPILING_RULE = _COMPILING_RULE, COMPILE_DEPENDENCY_RULE = _COMPILE_DEPENDENCY_RULE, INCLUDE_SCANNING_RULE = _INCLUDE_SCANNING_RULE, diff --git a/src/main/starlark/builtins_bzl/common/objc/objc_import.bzl b/src/main/starlark/builtins_bzl/common/objc/objc_import.bzl index 1ab2ab917c53e9..4c5ed0a8cc5674 100644 --- a/src/main/starlark/builtins_bzl/common/objc/objc_import.bzl +++ b/src/main/starlark/builtins_bzl/common/objc/objc_import.bzl @@ -49,10 +49,8 @@ objc_import = rule( attrs = common_attrs.union( { "archives": attr.label_list(allow_empty = False, mandatory = True, allow_files = [".a"]), - "_cc_toolchain": attr.label( - default = "@" + semantics.get_repo() + "//tools/cpp:current_cc_toolchain", - ), }, + common_attrs.CC_TOOLCHAIN_RULE, common_attrs.LICENSES, common_attrs.COMPILE_DEPENDENCY_RULE, common_attrs.INCLUDE_SCANNING_RULE, diff --git a/src/main/starlark/builtins_bzl/common/objc/objc_library.bzl b/src/main/starlark/builtins_bzl/common/objc/objc_library.bzl index bed58dd2237f1e..73ee5ddc4641ee 100644 --- a/src/main/starlark/builtins_bzl/common/objc/objc_library.bzl +++ b/src/main/starlark/builtins_bzl/common/objc/objc_library.bzl @@ -192,10 +192,8 @@ objc_library = rule( attrs = common_attrs.union( { "data": attr.label_list(allow_files = True), - "_cc_toolchain": attr.label( - default = "@" + semantics.get_repo() + "//tools/cpp:current_cc_toolchain", - ), }, + common_attrs.CC_TOOLCHAIN_RULE, common_attrs.LICENSES, common_attrs.COMPILING_RULE, common_attrs.COMPILE_DEPENDENCY_RULE,