Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 693308877
  • Loading branch information
Googler authored and swiple-rules-gardener committed Nov 5, 2024
1 parent 52fd255 commit 46535af
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 22 deletions.
9 changes: 7 additions & 2 deletions apple/apple_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ load(
"@build_bazel_rules_apple//apple/internal:linking_support.bzl",
"linking_support",
)
load(
"@build_bazel_rules_apple//apple/internal:providers.bzl",
"AppleExecutableBinaryInfo",
"new_appleexecutablebinaryinfo",
)
load(
"@build_bazel_rules_apple//apple/internal:rule_attrs.bzl",
"rule_attrs",
Expand Down Expand Up @@ -118,7 +123,7 @@ Resolved Xcode is version {xcode_version}.
# so that bundles can use it as their loader.
if binary_type == "executable":
providers.append(
apple_common.new_executable_binary_provider(
new_appleexecutablebinaryinfo(
cc_info = link_result.cc_info,
binary = binary_artifact,
),
Expand Down Expand Up @@ -178,7 +183,7 @@ The target representing the executable that will be loading this bundle.
Undefined symbols from the bundle are checked against this execuable during
linking as if it were one of the dynamic libraries the bundle was linked with.
""",
providers = [apple_common.AppleExecutableBinary],
providers = [AppleExecutableBinaryInfo],
),
"data": attr.label_list(allow_files = True),
"sdk_dylibs": attr.string_list(
Expand Down
3 changes: 3 additions & 0 deletions apple/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ bzl_library(
],
deps = [
":entitlements_support",
":providers",
"//apple/internal/providers:apple_dynamic_framework_info",
"@build_bazel_apple_support//lib:lipo",
],
)
Expand Down Expand Up @@ -383,6 +385,7 @@ bzl_library(
"//apple/internal/partials:swift_dylibs",
"//apple/internal/partials:swift_framework",
"//apple/internal/partials:watchos_stub",
"//apple/internal/providers:apple_dynamic_framework_info",
],
)

Expand Down
7 changes: 6 additions & 1 deletion apple/internal/apple_framework_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ load(
"@build_bazel_rules_apple//apple/internal/aspects:swift_usage_aspect.bzl",
"SwiftUsageInfo",
)
load(
"@build_bazel_rules_apple//apple/internal/providers:apple_dynamic_framework_info.bzl",
"AppleDynamicFrameworkInfo",
)
load(
"@build_bazel_rules_apple//apple/internal/toolchains:apple_toolchains.bzl",
"apple_toolchain_utils",
Expand Down Expand Up @@ -200,7 +204,8 @@ There should only be one valid framework binary, given a name that matches its f
# Create AppleDynamicFramework provider.
framework_groups = _grouped_framework_files(framework_imports)
framework_dirs_set = depset(framework_groups.keys())
providers.append(apple_common.new_dynamic_framework_provider(

providers.append(AppleDynamicFrameworkInfo(
cc_info = cc_info,
framework_dirs = framework_dirs_set,
framework_files = depset(framework_imports),
Expand Down
8 changes: 6 additions & 2 deletions apple/internal/apple_xcframework_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ load(
"@build_bazel_rules_apple//apple/internal/aspects:swift_usage_aspect.bzl",
"SwiftUsageInfo",
)
load(
"@build_bazel_rules_apple//apple/internal/providers:apple_dynamic_framework_info.bzl",
"AppleDynamicFrameworkInfo",
)
load(
"@build_bazel_rules_apple//apple/internal/toolchains:apple_toolchains.bzl",
"apple_toolchain_utils",
Expand Down Expand Up @@ -770,7 +774,7 @@ def _apple_dynamic_xcframework_import_impl(ctx):
providers.append(cc_info)

# Create AppleDynamicFrameworkInfo provider
apple_dynamic_framework_info = apple_common.new_dynamic_framework_provider(
apple_dynamic_framework_info = AppleDynamicFrameworkInfo(
cc_info = cc_info,
)
providers.append(apple_dynamic_framework_info)
Expand Down Expand Up @@ -1007,7 +1011,7 @@ on this target.
provides = [
AppleFrameworkImportInfo,
CcInfo,
apple_common.AppleDynamicFramework,
AppleDynamicFrameworkInfo,
],
toolchains = use_cpp_toolchain(),
)
Expand Down
5 changes: 3 additions & 2 deletions apple/internal/ios_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ load(
"IosFrameworkBundleInfo",
"IosImessageExtensionBundleInfo",
"WatchosApplicationBundleInfo",
"new_appleexecutablebinaryinfo",
"new_appleframeworkbundleinfo",
"new_iosappclipbundleinfo",
"new_iosapplicationbundleinfo",
Expand Down Expand Up @@ -511,7 +512,7 @@ def _ios_application_impl(ctx):
processor_result.output_groups,
)
),
apple_common.new_executable_binary_provider(
new_appleexecutablebinaryinfo(
binary = binary_artifact,
cc_info = link_result.cc_info,
),
Expand Down Expand Up @@ -811,7 +812,7 @@ def _ios_app_clip_impl(ctx):
processor_result.output_groups,
)
),
apple_common.new_executable_binary_provider(
new_appleexecutablebinaryinfo(
binary = binary_artifact,
cc_info = link_result.cc_info,
),
Expand Down
25 changes: 17 additions & 8 deletions apple/internal/linking_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ load(
"get_split_target_triplet",
"subtract_linking_contexts",
)
load(
"@build_bazel_rules_apple//apple/internal:providers.bzl",
"AppleExecutableBinaryInfo",
"new_appledebugoutputsinfo",
)
load(
"@build_bazel_rules_apple//apple/internal/providers:apple_dynamic_framework_info.bzl",
"AppleDynamicFrameworkInfo",
)

ObjcInfo = apple_common.Objc

Expand Down Expand Up @@ -183,14 +192,14 @@ def _link_multi_arch_binary(
))

avoid_cc_infos = [
dep[apple_common.AppleDynamicFramework].cc_info
dep[AppleDynamicFrameworkInfo].cc_info
for dep in avoid_deps
if apple_common.AppleDynamicFramework in dep
if AppleDynamicFrameworkInfo in dep
]
avoid_cc_infos.extend([
dep[apple_common.AppleExecutableBinary].cc_info
dep[AppleExecutableBinaryInfo].cc_info
for dep in avoid_deps
if apple_common.AppleExecutableBinary in dep
if AppleExecutableBinaryInfo in dep
])
avoid_cc_infos.extend([dep[CcInfo] for dep in avoid_deps if CcInfo in dep])
avoid_cc_linking_contexts = [dep.linking_context for dep in avoid_cc_infos]
Expand Down Expand Up @@ -307,7 +316,7 @@ def _link_multi_arch_binary(
cc_info = cc_common.merge_cc_infos(direct_cc_infos = cc_infos),
output_groups = output_groups,
outputs = outputs,
debug_outputs_provider = apple_common.AppleDebugOutputs(outputs_map = legacy_debug_outputs),
debug_outputs_provider = new_appledebugoutputsinfo(outputs_map = legacy_debug_outputs),
)

def _debug_outputs_by_architecture(link_outputs):
Expand Down Expand Up @@ -389,11 +398,11 @@ def _register_binary_linking_action(
avoid_deps: A list of `Target`s representing dependencies of the binary but whose
symbols should not be linked into it.
bundle_loader: For Mach-O bundles, the `Target` whose binary will load this bundle.
This target must propagate the `apple_common.AppleExecutableBinary` provider.
This target must propagate the `AppleExecutableBinaryInfo` provider.
This simplifies the process of passing the bundle loader to all the arguments
that need it: the binary will automatically be added to the linker inputs, its
path will be added to linkopts via `-bundle_loader`, and the `apple_common.Objc`
provider of its dependencies (obtained from the `AppleExecutableBinary` provider)
provider of its dependencies (obtained from the `AppleExecutableBinaryInfo` provider)
will be passed as an additional `avoid_dep` to ensure that those dependencies are
subtracted when linking the bundle's binary.
entitlements: An optional `File` that provides the processed entitlements for the
Expand Down Expand Up @@ -488,7 +497,7 @@ def _register_binary_linking_action(

all_avoid_deps = list(avoid_deps)
if bundle_loader:
bundle_loader_file = bundle_loader[apple_common.AppleExecutableBinary].binary
bundle_loader_file = bundle_loader[AppleExecutableBinaryInfo].binary
all_avoid_deps.append(bundle_loader)
linkopts.extend(["-bundle_loader", bundle_loader_file.path])
link_inputs.append(bundle_loader_file)
Expand Down
8 changes: 5 additions & 3 deletions apple/internal/macos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ load(
"@build_bazel_rules_apple//apple/internal:providers.bzl",
"AppleBundleInfo",
"AppleBundleVersionInfo",
"AppleExecutableBinaryInfo",
"MacosExtensionBundleInfo",
"MacosXPCServiceBundleInfo",
"new_applebinaryinfo",
"new_appleexecutablebinaryinfo",
"new_macosapplicationbundleinfo",
"new_macosbundlebundleinfo",
"new_macosextensionbundleinfo",
Expand Down Expand Up @@ -424,7 +426,7 @@ def _macos_application_impl(ctx):
processor_result.output_groups,
)
),
apple_common.new_executable_binary_provider(
new_appleexecutablebinaryinfo(
binary = binary_artifact,
cc_info = link_result.cc_info,
),
Expand Down Expand Up @@ -2071,7 +2073,7 @@ def _macos_command_line_application_impl(ctx):
processor_result.output_groups,
)
),
apple_common.new_executable_binary_provider(
new_appleexecutablebinaryinfo(
binary = output_file,
cc_info = link_result.cc_info,
),
Expand Down Expand Up @@ -2401,7 +2403,7 @@ The target representing the executable that will be loading this bundle. Undefin
bundle are checked against this execuable during linking as if it were one of the dynamic libraries
the bundle was linked with.
""",
providers = [apple_common.AppleExecutableBinary],
providers = [AppleExecutableBinaryInfo],
),
},
],
Expand Down
1 change: 1 addition & 0 deletions apple/internal/partials/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ bzl_library(
"//apple/internal:__pkg__",
],
deps = [
"//apple/internal/providers:apple_dynamic_framework_info",
"@bazel_skylib//lib:partial",
"@bazel_skylib//lib:paths",
],
Expand Down
6 changes: 5 additions & 1 deletion apple/internal/partials/framework_provider.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ load(
"@bazel_skylib//lib:paths.bzl",
"paths",
)
load(
"@build_bazel_rules_apple//apple/internal/providers:apple_dynamic_framework_info.bzl",
"AppleDynamicFrameworkInfo",
)

visibility("//apple/...")

Expand Down Expand Up @@ -77,7 +81,7 @@ def _framework_provider_partial_impl(
],
)

framework_provider = apple_common.new_dynamic_framework_provider(
framework_provider = AppleDynamicFrameworkInfo(
binary = binary_artifact,
cc_info = wrapper_cc_info,
framework_dirs = depset([absolute_framework_dir]),
Expand Down
32 changes: 32 additions & 0 deletions apple/internal/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,21 @@ target if one was generated.
init = make_banned_init(provider_name = "AppleCodesigningDossierInfo"),
)

AppleDebugOutputsInfo, new_appledebugoutputsinfo = provider(
"""
Holds debug outputs of an Apple binary rule.
This provider is DEPRECATED. Preferably use `AppleDsymBundleInfo` instead.
The only field is `output_map`, which is a dictionary of:
`{ arch: { "dsym_binary": File, "linkmap": File }`
Where `arch` is any Apple architecture such as "arm64" or "armv7".
""",
fields = ["outputs_map"],
init = make_banned_init(provider_name = "AppleDebugOutputsInfo"),
)

AppleDsymBundleInfo, new_appledsymbundleinfo = provider(
doc = "Provides information for an Apple dSYM bundle.",
fields = {
Expand All @@ -236,6 +251,23 @@ dependencies of the given target if any were generated.
init = make_banned_init(provider_name = "AppleDsymBundleInfo"),
)

AppleExecutableBinaryInfo, new_appleexecutablebinaryinfo = provider(
doc = """
Contains the executable binary output that was built using
`link_multi_arch_binary` with the `executable` binary type.
""",
fields = {
"binary": """\
The executable binary artifact output by `link_multi_arch_binary`.
""",
"cc_info": """\
A `CcInfo` which contains information about the transitive dependencies linked
into the binary.
""",
},
init = make_banned_init(provider_name = "AppleExecutableBinaryInfo"),
)

AppleExtraOutputsInfo, new_appleextraoutputsinfo = provider(
doc = """
Provides information about extra outputs that should be produced from the build.
Expand Down
10 changes: 10 additions & 0 deletions apple/internal/providers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ bzl_library(
],
)

bzl_library(
name = "apple_dynamic_framework_info",
srcs = ["apple_dynamic_framework_info.bzl"],
visibility = [
# Visibility set to subpackages since this provider is used
# by a number of rules in `internal`.
"//apple/internal:__subpackages__",
],
)

bzl_library(
name = "apple_resource_hint_info",
srcs = ["apple_resource_hint_info.bzl"],
Expand Down
38 changes: 38 additions & 0 deletions apple/internal/providers/apple_dynamic_framework_info.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""AppleDynamicFrameworkInfo provider implementation."""

visibility([
"//apple/internal/...",
])

AppleDynamicFrameworkInfo = provider(
doc = "Contains information about an Apple dynamic framework.",
fields = {
"framework_dirs": """\
The framework path names used as link inputs in order to link against the
dynamic framework.
""",
"framework_files": """\
The full set of artifacts that should be included as inputs to link against the
dynamic framework.
""",
"binary": "The dylib binary artifact of the dynamic framework.",
"cc_info": """\
A `CcInfo` which contains information about the transitive dependencies linked
into the binary.
""",
},
)
3 changes: 2 additions & 1 deletion apple/internal/testing/apple_test_bundle_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ load(
load(
"@build_bazel_rules_apple//apple/internal:providers.bzl",
"AppleBundleInfo",
"AppleExecutableBinaryInfo",
"AppleTestInfo",
"new_appleextraoutputsinfo",
"new_appletestinfo",
Expand Down Expand Up @@ -387,7 +388,7 @@ def _apple_test_bundle_impl(*, ctx, product_type):
# is never passed as the bundle loader, because the host application is loaded out-of-process.)
if (
rule_descriptor.product_type == apple_product_type.unit_test_bundle and
test_host and apple_common.AppleExecutableBinary in test_host
test_host and AppleExecutableBinaryInfo in test_host
):
bundle_loader = test_host
else:
Expand Down
3 changes: 2 additions & 1 deletion apple/internal/tvos_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ load(
"ApplePlatformInfo",
"TvosExtensionBundleInfo",
"TvosFrameworkBundleInfo",
"new_appleexecutablebinaryinfo",
"new_appleframeworkbundleinfo",
"new_tvosapplicationbundleinfo",
"new_tvosextensionbundleinfo",
Expand Down Expand Up @@ -440,7 +441,7 @@ def _tvos_application_impl(ctx):
)
),
new_tvosapplicationbundleinfo(),
apple_common.new_executable_binary_provider(
new_appleexecutablebinaryinfo(
binary = binary_artifact,
cc_info = link_result.cc_info,
),
Expand Down
Loading

1 comment on commit 46535af

@keith
Copy link
Member

@keith keith commented on 46535af Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.