Skip to content

Commit

Permalink
Move shared _cc_toolchain attribute to common attrs.bzl library.
Browse files Browse the repository at this point in the history
Similar to other shared attributes, this change moves the `_cc_toolchain`\
attribute to the shared `attr.bzl` library.

RELNOTES: N/A
PiperOrigin-RevId: 443420195
  • Loading branch information
Googler authored and copybara-github committed Apr 21, 2022
1 parent 63cfdf9 commit d5c788f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions src/main/starlark/builtins_bzl/common/objc/attrs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions src/main/starlark/builtins_bzl/common/objc/objc_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions src/main/starlark/builtins_bzl/common/objc/objc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d5c788f

Please sign in to comment.