Skip to content

Commit e3599e4

Browse files
nglevinluispadron
authored andcommitted
Add new fields to AppleBinaryInfo matching AppleBundleInfo to relay target platform information.
Cherry-pick: e54e480
1 parent 19dc0c5 commit e3599e4

5 files changed

Lines changed: 33 additions & 1 deletion

File tree

apple/apple_static_library.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Expected Apple platform type of "{platform_type}", but that was not found in {to
8181
providers = [
8282
DefaultInfo(files = depset(files_to_build), runfiles = runfiles),
8383
new_applebinaryinfo(
84+
# Since the rule is deprecated, we only set what's needed for legacy users.
8485
binary = archive_result.library,
8586
infoplist = None,
8687
),

apple/internal/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ bzl_library(
8787
":rule_attrs",
8888
":rule_factory",
8989
":transition_support",
90+
"@build_bazel_apple_support//lib:apple_support",
9091
],
9192
)
9293

apple/internal/apple_universal_binary.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
"""Implementation for apple universal binary rules."""
1616

17+
load(
18+
"@build_bazel_apple_support//lib:apple_support.bzl",
19+
"apple_support",
20+
)
1721
load(
1822
"//apple/internal:linking_support.bzl",
1923
"linking_support",
@@ -66,8 +70,10 @@ def _apple_universal_binary_impl(ctx):
6670

6771
return [
6872
new_applebinaryinfo(
73+
archs = sorted(ctx.attr.forced_cpus),
6974
binary = fat_binary,
70-
infoplist = None,
75+
platform_type = apple_support.target_os_from_rule_ctx(ctx),
76+
target_environment = apple_support.target_environment_from_rule_ctx(ctx),
7177
),
7278
DefaultInfo(
7379
executable = fat_binary,
@@ -84,6 +90,7 @@ The `lipo` tool is used to combine built binaries of multiple architectures.
8490
""",
8591
implementation = _apple_universal_binary_impl,
8692
attrs = [
93+
apple_support.platform_constraint_attrs(),
8794
rule_attrs.common_attrs(),
8895
rule_attrs.platform_attrs(),
8996
{

apple/internal/macos_rules.bzl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,9 +2109,15 @@ def _macos_command_line_application_impl(ctx):
21092109

21102110
return [
21112111
new_applebinaryinfo(
2112+
archs = sorted([
2113+
x[ApplePlatformInfo].target_arch
2114+
for x in cc_toolchain_forwarder.values()
2115+
]),
21122116
binary = output_file,
21132117
infoplist = infoplist,
2118+
platform_type = platform_prerequisites.platform_type,
21142119
product_type = rule_descriptor.product_type,
2120+
target_environment = platform_prerequisites.target_environment,
21152121
),
21162122
DefaultInfo(
21172123
executable = output_file,
@@ -2250,9 +2256,15 @@ def _macos_dylib_impl(ctx):
22502256

22512257
return [
22522258
new_applebinaryinfo(
2259+
archs = sorted([
2260+
x[ApplePlatformInfo].target_arch
2261+
for x in cc_toolchain_forwarder.values()
2262+
]),
22532263
binary = output_file,
22542264
infoplist = infoplist,
2265+
platform_type = platform_prerequisites.platform_type,
22552266
product_type = rule_descriptor.product_type,
2267+
target_environment = platform_prerequisites.target_environment,
22562268
),
22572269
DefaultInfo(files = depset(transitive = [
22582270
depset([output_file]),

apple/internal/providers.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,26 @@ This provider propagates general information about an Apple binary that is not
6666
specific to any particular binary type.
6767
""",
6868
fields = {
69+
"archs": """
70+
`List` of `String`s. The architectures that the binary supports (i.e. `arm64` for Apple Silicon
71+
simulators and device builds).
72+
""",
6973
"binary": """
7074
`File`. The binary (executable, dynamic library, etc.) file that the target represents.
7175
""",
7276
"infoplist": """
7377
`File`. The complete (binary-formatted) `Info.plist` embedded in the binary.
78+
""",
79+
"platform_type": """
80+
`String`. The platform type for the binary (i.e. `ios` for iOS binaries).
7481
""",
7582
"product_type": """
7683
`String`. The dot-separated product type identifier associated with the binary (for example,
7784
`com.apple.product-type.tool`).
85+
""",
86+
"target_environment": """
87+
`String`. The environment that the binary was built for, (i.e. `device` for iOS device builds,
88+
`simulator` for iOS simulator builds).
7889
""",
7990
},
8091
init = _make_banned_init(provider_name = "AppleBinaryInfo"),

0 commit comments

Comments
 (0)