From 2529e5e186a838d7dc2ca47138fbaddc7b51102c Mon Sep 17 00:00:00 2001 From: Nicholas Levin Date: Fri, 25 Apr 2025 05:57:08 -0700 Subject: [PATCH 01/13] Start wiring up build settings for crosstool dSYM bundles into the rules themselves. Cherry-pick: f1ed76b96f6adc3fca76375be79fb20c320b0733 --- apple/BUILD | 1 + apple/apple_binary.bzl | 8 +++ apple/build_settings/build_settings.bzl | 8 +++ apple/internal/ios_rules.bzl | 6 +++ apple/internal/linking_support.bzl | 54 ++++++++++++++----- apple/internal/macos_rules.bzl | 11 ++++ .../testing/apple_test_bundle_support.bzl | 1 + apple/internal/tvos_rules.bzl | 4 ++ apple/internal/visionos_rules.bzl | 4 ++ apple/internal/watchos_rules.bzl | 4 ++ apple/internal/xcframework_rules.bzl | 1 + 11 files changed, 88 insertions(+), 14 deletions(-) diff --git a/apple/BUILD b/apple/BUILD index cf151a306a..ef778fd902 100644 --- a/apple/BUILD +++ b/apple/BUILD @@ -77,6 +77,7 @@ bzl_library( "//apple/internal:rule_attrs", "//apple/internal:rule_factory", "//apple/internal:transition_support", + "//apple/internal/toolchains:apple_toolchains", "@build_bazel_apple_support//lib:apple_support", ], ) diff --git a/apple/apple_binary.bzl b/apple/apple_binary.bzl index 6fba3459cb..c1a81af745 100644 --- a/apple/apple_binary.bzl +++ b/apple/apple_binary.bzl @@ -18,6 +18,11 @@ load( "@build_bazel_apple_support//lib:apple_support.bzl", "apple_support", ) +load( + "//apple/internal:apple_toolchains.bzl", + "AppleXPlatToolsToolchainInfo", + "apple_toolchain_utils", +) load( "//apple/internal:linking_support.bzl", "linking_support", @@ -67,6 +72,7 @@ visionOS binaries require a visionOS SDK provided by Xcode 15.1 beta or later. Resolved Xcode is version {xcode_version}. """.format(xcode_version = str(xcode_version_config.xcode_version()))) + apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] binary_type = ctx.attr.binary_type bundle_loader = ctx.attr.bundle_loader cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder @@ -97,6 +103,7 @@ Resolved Xcode is version {xcode_version}. link_result = linking_support.register_binary_linking_action( ctx, cc_toolchains = cc_toolchain_forwarder, + build_settings = apple_xplat_toolchain_info.build_settings, bundle_loader = bundle_loader, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = extra_linkopts, @@ -152,6 +159,7 @@ implementation of `apple_binary` in Bazel core so that it can be removed. implementation = _apple_binary_impl, attrs = [ apple_support.platform_constraint_attrs(), + apple_toolchain_utils.shared_attrs(), rule_attrs.binary_linking_attrs( deps_cfg = transition_support.apple_platform_split_transition, is_test_supporting_rule = False, diff --git a/apple/build_settings/build_settings.bzl b/apple/build_settings/build_settings.bzl index 510003609c..86be205b38 100644 --- a/apple/build_settings/build_settings.bzl +++ b/apple/build_settings/build_settings.bzl @@ -58,6 +58,14 @@ physical devices) or `xcrun simctl list devices` (for simulators). """, default = "", ), + "dsym_variant_flag": struct( + doc = """ +Controls the output format for dSYM debug symbols. Valid values are: +- "flat": Outputs individual dSYM files as additional outputs from the target. +- "bundle": Outputs dSYM bundles as directories. +""", + default = "flat", + ), } # List of all registered build settings without command line flags at diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index e020315c96..edf34c1dc0 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -248,6 +248,7 @@ def _ios_application_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = extra_linkopts, @@ -624,6 +625,7 @@ def _ios_app_clip_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, platform_prerequisites = platform_prerequisites, @@ -956,6 +958,7 @@ def _ios_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -1233,6 +1236,7 @@ def _ios_extension_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = extra_linkopts, @@ -1548,6 +1552,7 @@ def _ios_dynamic_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -2184,6 +2189,7 @@ def _ios_imessage_extension_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = extra_linkopts, diff --git a/apple/internal/linking_support.bzl b/apple/internal/linking_support.bzl index cd25702993..6a468016b7 100644 --- a/apple/internal/linking_support.bzl +++ b/apple/internal/linking_support.bzl @@ -146,6 +146,7 @@ def _link_multi_arch_binary( *, ctx, avoid_deps, + build_settings, cc_toolchains, extra_linkopts, extra_link_inputs, @@ -168,6 +169,7 @@ def _link_multi_arch_binary( dependencies that will be found at runtime in another image, such as the bundle loader or any dynamic libraries/frameworks that will be loaded by this binary. + build_settings: A struct with build settings info from AppleXplatToolsToolchainInfo. cc_toolchains: Dictionary of CcToolchainInfo and ApplePlatformInfo providers under a split transition to relay target platform information for related deps. extra_linkopts: A list of strings: Extra linkopts to add to the linking action. @@ -277,21 +279,42 @@ def _link_multi_arch_binary( additional_outputs = [] extensions = {} - dsym_binary = None + dsym_output = None if ctx.fragments.cpp.apple_generate_dsym: - if ctx.fragments.cpp.objc_should_strip_binary: - suffix = "_bin_unstripped.dwarf" + dsym_variants = build_settings.dsym_variant_flag + if dsym_variants == "bundle": + # TODO(b/391401130): Remove this once dsymutil generated bundle dSYM output is + # supported. + fail("dsymutil bundle dSYM output is not yet supported by the Apple BUILD Rules.") + elif dsym_variants != "flat": + fail(""" +Internal Error: Found unsupported dsym_variant_flag: {dsym_variants}. + +Please report this as a bug to the Apple BUILD Rules team. + """.format( + dsym_variants = dsym_variants, + )) else: - suffix = "_bin.dwarf" - dsym_binary = intermediates.file( - actions = ctx.actions, - target_name = ctx.label.name, - output_discriminator = split_transition_key, - file_name = ctx.label.name + suffix, - ) - extensions["dsym_path"] = dsym_binary.path # dsym symbol file - additional_outputs.append(dsym_binary) - legacy_debug_outputs.setdefault(platform_info.target_arch, {})["dsym_binary"] = dsym_binary + if ctx.fragments.cpp.objc_should_strip_binary: + suffix = "_bin_unstripped" + else: + suffix = "_bin" + dsym_output = intermediates.file( + actions = ctx.actions, + target_name = ctx.label.name, + output_discriminator = split_transition_key, + file_name = "{}.dwarf".format(ctx.label.name + suffix), + ) + + # TODO(b/391401130): Remove this once all users are migrated to the downstream + # provider AppleDsymBundleInfo. + legacy_debug_outputs.setdefault( + platform_info.target_arch, + {}, + )["dsym_binary"] = dsym_output + + extensions["dsym_path"] = dsym_output.path # dsym symbol file + additional_outputs.append(dsym_output) linkmap = None if ctx.fragments.cpp.objc_generate_linkmap: @@ -326,7 +349,7 @@ def _link_multi_arch_binary( "platform": platform_info.target_os, "architecture": platform_info.target_arch, "environment": platform_info.target_environment, - "dsym_binary": dsym_binary, + "dsym_binary": dsym_output, "linkmap": linkmap, } @@ -416,6 +439,7 @@ def _register_binary_linking_action( ctx, *, avoid_deps = [], + build_settings, bundle_loader = None, cc_toolchains, entitlements = None, @@ -436,6 +460,7 @@ def _register_binary_linking_action( ctx: The rule context. avoid_deps: A list of `Target`s representing dependencies of the binary but whose symbols should not be linked into it. + build_settings: A struct with build settings info from AppleXplatToolsToolchainInfo. bundle_loader: For Mach-O bundles, the `Target` whose binary will load this bundle. This target must propagate the `AppleExecutableBinaryInfo` provider. This simplifies the process of passing the bundle loader to all the arguments @@ -547,6 +572,7 @@ def _register_binary_linking_action( linking_outputs = _link_multi_arch_binary( ctx = ctx, avoid_deps = all_avoid_deps, + build_settings = build_settings, cc_toolchains = cc_toolchains, extra_linkopts = linkopts, extra_link_inputs = link_inputs, diff --git a/apple/internal/macos_rules.bzl b/apple/internal/macos_rules.bzl index 31d4aecc4c..347f264f91 100644 --- a/apple/internal/macos_rules.bzl +++ b/apple/internal/macos_rules.bzl @@ -241,6 +241,7 @@ def _macos_application_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, platform_prerequisites = platform_prerequisites, @@ -543,6 +544,7 @@ def _macos_bundle_impl(ctx): link_result = linking_support.register_binary_linking_action( ctx, cc_toolchains = cc_toolchain_forwarder, + build_settings = apple_xplat_toolchain_info.build_settings, bundle_loader = ctx.attr.bundle_loader, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -797,6 +799,7 @@ def _macos_extension_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = extra_linkopts, @@ -1065,6 +1068,7 @@ def _macos_quick_look_plugin_impl(ctx): link_result = linking_support.register_binary_linking_action( ctx, + build_settings = apple_xplat_toolchain_info.build_settings, cc_toolchains = cc_toolchain_forwarder, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -1319,6 +1323,7 @@ def _macos_kernel_extension_impl(ctx): link_result = linking_support.register_binary_linking_action( ctx, + build_settings = apple_xplat_toolchain_info.build_settings, cc_toolchains = cc_toolchain_forwarder, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -1562,6 +1567,7 @@ def _macos_spotlight_importer_impl(ctx): link_result = linking_support.register_binary_linking_action( ctx, + build_settings = apple_xplat_toolchain_info.build_settings, cc_toolchains = cc_toolchain_forwarder, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -1803,6 +1809,7 @@ def _macos_xpc_service_impl(ctx): link_result = linking_support.register_binary_linking_action( ctx, + build_settings = apple_xplat_toolchain_info.build_settings, cc_toolchains = cc_toolchain_forwarder, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -2019,6 +2026,7 @@ def _macos_command_line_application_impl(ctx): link_result = linking_support.register_binary_linking_action( ctx, + build_settings = apple_xplat_toolchain_info.build_settings, cc_toolchains = cc_toolchain_forwarder, # Command-line applications do not have entitlements. entitlements = None, @@ -2161,6 +2169,7 @@ def _macos_dylib_impl(ctx): link_result = linking_support.register_binary_linking_action( ctx, + build_settings = apple_xplat_toolchain_info.build_settings, cc_toolchains = cc_toolchain_forwarder, # Dynamic libraries do not have entitlements. entitlements = None, @@ -2853,6 +2862,7 @@ def _macos_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -3136,6 +3146,7 @@ def _macos_dynamic_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, diff --git a/apple/internal/testing/apple_test_bundle_support.bzl b/apple/internal/testing/apple_test_bundle_support.bzl index 9f1eed951c..b2b6b62ed0 100644 --- a/apple/internal/testing/apple_test_bundle_support.bzl +++ b/apple/internal/testing/apple_test_bundle_support.bzl @@ -392,6 +392,7 @@ def _apple_test_bundle_impl(*, ctx, product_type): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = getattr(ctx.attr, "frameworks", []), + build_settings = apple_xplat_toolchain_info.build_settings, bundle_loader = bundle_loader, # Unit/UI tests do not use entitlements. entitlements = None, diff --git a/apple/internal/tvos_rules.bzl b/apple/internal/tvos_rules.bzl index 89efc9e1b7..0c5b471348 100644 --- a/apple/internal/tvos_rules.bzl +++ b/apple/internal/tvos_rules.bzl @@ -225,6 +225,7 @@ def _tvos_application_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, platform_prerequisites = platform_prerequisites, @@ -558,6 +559,7 @@ def _tvos_dynamic_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -845,6 +847,7 @@ def _tvos_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -1130,6 +1133,7 @@ def _tvos_extension_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = extra_linkopts, diff --git a/apple/internal/visionos_rules.bzl b/apple/internal/visionos_rules.bzl index caaa6313a7..c9c04b17ff 100644 --- a/apple/internal/visionos_rules.bzl +++ b/apple/internal/visionos_rules.bzl @@ -233,6 +233,7 @@ Resolved Xcode is version {xcode_version}. ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, platform_prerequisites = platform_prerequisites, @@ -562,6 +563,7 @@ def _visionos_dynamic_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -850,6 +852,7 @@ def _visionos_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -1122,6 +1125,7 @@ def _visionos_extension_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = [ diff --git a/apple/internal/watchos_rules.bzl b/apple/internal/watchos_rules.bzl index 358fb20403..daf90e0923 100644 --- a/apple/internal/watchos_rules.bzl +++ b/apple/internal/watchos_rules.bzl @@ -226,6 +226,7 @@ def _watchos_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -506,6 +507,7 @@ def _watchos_dynamic_framework_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, # Frameworks do not have entitlements. entitlements = None, exported_symbols_lists = ctx.files.exported_symbols_lists, @@ -1124,6 +1126,7 @@ def _watchos_extension_impl(ctx): ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = extra_linkopts, @@ -1591,6 +1594,7 @@ delegate is referenced in the single-target `watchos_application`'s `deps`. ctx, cc_toolchains = cc_toolchain_forwarder, avoid_deps = ctx.attr.frameworks, + build_settings = apple_xplat_toolchain_info.build_settings, entitlements = entitlements.linking, exported_symbols_lists = ctx.files.exported_symbols_lists, extra_linkopts = [], diff --git a/apple/internal/xcframework_rules.bzl b/apple/internal/xcframework_rules.bzl index 5295dfa0b3..f0ae06e24c 100644 --- a/apple/internal/xcframework_rules.bzl +++ b/apple/internal/xcframework_rules.bzl @@ -590,6 +590,7 @@ def _apple_xcframework_impl(ctx): link_result = linking_support.register_binary_linking_action( ctx, + build_settings = apple_xplat_toolchain_info.build_settings, cc_toolchains = cc_toolchain_forwarder, # Frameworks do not have entitlements. entitlements = None, From cba6a325ededd061dfb3a5f8366d0bee43f1b0df Mon Sep 17 00:00:00 2001 From: Nicholas Levin Date: Fri, 25 Apr 2025 07:11:38 -0700 Subject: [PATCH 02/13] Remove bin_root_path reference from the dynamic framework provider partial along with dead code that was present from use of the vestigial AppleDynamicFrameworkInfo fields. Cherry-pick: 28d227adc9bd6b35468f4504d8e6338b9d13bb77 --- apple/internal/apple_framework_import.bzl | 4 -- apple/internal/features_support.bzl | 16 ++++++ apple/internal/ios_rules.bzl | 21 ++----- apple/internal/macos_rules.bzl | 21 ++----- apple/internal/partials/BUILD | 1 - .../internal/partials/framework_provider.bzl | 57 +++++++------------ apple/internal/providers.bzl | 9 --- apple/internal/tvos_rules.bzl | 21 ++----- apple/internal/visionos_rules.bzl | 21 ++----- apple/internal/watchos_rules.bzl | 21 ++----- 10 files changed, 65 insertions(+), 127 deletions(-) diff --git a/apple/internal/apple_framework_import.bzl b/apple/internal/apple_framework_import.bzl index 102c7d2d94..bf1ae1f6b3 100644 --- a/apple/internal/apple_framework_import.bzl +++ b/apple/internal/apple_framework_import.bzl @@ -245,12 +245,8 @@ def _apple_dynamic_framework_import_impl(ctx): providers.append(cc_info) # Create AppleDynamicFramework provider. - framework_groups = _grouped_framework_files(framework_imports) - framework_dirs_set = depset(framework_groups.keys()) providers.append(new_appledynamicframeworkinfo( cc_info = cc_info, - framework_dirs = framework_dirs_set, - framework_files = depset(framework_imports), )) if "apple._import_framework_via_swiftinterface" in features and framework.swift_interface_imports: diff --git a/apple/internal/features_support.bzl b/apple/internal/features_support.bzl index aff81f9361..5c5029270e 100644 --- a/apple/internal/features_support.bzl +++ b/apple/internal/features_support.bzl @@ -15,6 +15,7 @@ """Support macros to assist in detecting build features.""" load("@bazel_skylib//lib:new_sets.bzl", "sets") +load("@rules_cc//cc/common:cc_common.bzl", "cc_common") def _compute_enabled_features(*, requested_features, unsupported_features): """Returns a list of features for the given build. @@ -33,6 +34,21 @@ def _compute_enabled_features(*, requested_features, unsupported_features): ) return sets.to_list(enabled_features_set) +def _make_cc_configured_features_init(ctx): + """Captures the rule ctx for a deferred `cc_common.configure_features(...)` call. + + Args: + ctx: The rule context, expected to be captured directly in the rule context and NOT within a + partial or helper method. + + Returns: + A lambda that has the captured instance of the rule context, which will always set that rule + context as the `ctx` argument of `cc_common.configure_features(...)` and will forward any + arguments it is given to `cc_common.configure_features(...)`. + """ + return lambda *args, **kwargs: cc_common.configure_features(ctx = ctx, *args, **kwargs) + features_support = struct( compute_enabled_features = _compute_enabled_features, + make_cc_configured_features_init = _make_cc_configured_features_init, ) diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index edf34c1dc0..69537ae597 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -883,7 +883,6 @@ def _ios_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, label_name = ctx.label.name, @@ -898,13 +897,6 @@ def _ios_framework_impl(ctx): ) cc_toolchain = find_cc_toolchain(ctx) cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder - cc_features = cc_common.configure_features( - ctx = ctx, - cc_toolchain = cc_toolchain, - language = "objc", - requested_features = ctx.features, - unsupported_features = ctx.disabled_features, - ) executable_name = ctx.attr.executable_name features = features_support.compute_enabled_features( requested_features = ctx.features, @@ -1065,13 +1057,13 @@ def _ios_framework_impl(ctx): partials.framework_headers_partial(hdrs = ctx.files.hdrs), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( @@ -1476,7 +1468,6 @@ def _ios_dynamic_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, @@ -1656,13 +1647,13 @@ def _ios_dynamic_framework_impl(ctx): ), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = False, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( diff --git a/apple/internal/macos_rules.bzl b/apple/internal/macos_rules.bzl index 347f264f91..87a4f51842 100644 --- a/apple/internal/macos_rules.bzl +++ b/apple/internal/macos_rules.bzl @@ -2793,7 +2793,6 @@ def _macos_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, @@ -2803,13 +2802,6 @@ def _macos_framework_impl(ctx): executable_name = ctx.attr.executable_name cc_toolchain = find_cc_toolchain(ctx) cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder - cc_features = cc_common.configure_features( - ctx = ctx, - cc_toolchain = cc_toolchain, - language = "objc", - requested_features = ctx.features, - unsupported_features = ctx.disabled_features, - ) features = features_support.compute_enabled_features( requested_features = ctx.features, unsupported_features = ctx.disabled_features, @@ -2969,13 +2961,13 @@ def _macos_framework_impl(ctx): partials.framework_headers_partial(hdrs = ctx.files.hdrs), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( @@ -3070,7 +3062,6 @@ def _macos_dynamic_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, @@ -3250,13 +3241,13 @@ def _macos_dynamic_framework_impl(ctx): ), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = False, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( diff --git a/apple/internal/partials/BUILD b/apple/internal/partials/BUILD index 6b689ebdd1..4e4366e96c 100644 --- a/apple/internal/partials/BUILD +++ b/apple/internal/partials/BUILD @@ -235,7 +235,6 @@ bzl_library( "//apple/internal:framework_import_support", "//apple/internal:providers", "@bazel_skylib//lib:partial", - "@bazel_skylib//lib:paths", ], ) diff --git a/apple/internal/partials/framework_provider.bzl b/apple/internal/partials/framework_provider.bzl index dcadbb4a97..440f1ee56f 100644 --- a/apple/internal/partials/framework_provider.bzl +++ b/apple/internal/partials/framework_provider.bzl @@ -18,10 +18,6 @@ load( "@bazel_skylib//lib:partial.bzl", "partial", ) -load( - "@bazel_skylib//lib:paths.bzl", - "paths", -) load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_cc//cc/common:cc_info.bzl", "CcInfo") load("//apple/internal:providers.bzl", "new_appledynamicframeworkinfo") @@ -29,39 +25,26 @@ load("//apple/internal:providers.bzl", "new_appledynamicframeworkinfo") def _framework_provider_partial_impl( *, actions, - bin_root_path, binary_artifact, - bundle_name, bundle_only, - cc_features, + cc_configured_features_init, cc_info, cc_toolchain, + disabled_features, + features, rule_label): """Implementation for the framework provider partial.""" - # Create a directory structure that the linker can use to reference this - # framework. It follows the pattern of - # any_path/MyFramework.framework/MyFramework. The absolute path and files are - # propagated using the AppleDynamicFrameworkInfo provider. - framework_dir = paths.join("frameworks", "%s.framework" % bundle_name) - framework_file = actions.declare_file( - paths.join(framework_dir, bundle_name), - ) - actions.symlink( - target_file = binary_artifact, - output = framework_file, - ) - - absolute_framework_dir = paths.join( - bin_root_path, - rule_label.package, - framework_dir, + feature_configuration = cc_configured_features_init( + cc_toolchain = cc_toolchain, + language = "objc", + requested_features = features, + unsupported_features = disabled_features, ) - library_to_link = cc_common.create_library_to_link( actions = actions, cc_toolchain = cc_toolchain, - feature_configuration = cc_features, + feature_configuration = feature_configuration, dynamic_library = binary_artifact, ) linker_input = cc_common.create_linker_input( @@ -80,10 +63,7 @@ def _framework_provider_partial_impl( ) framework_provider = new_appledynamicframeworkinfo( - binary = binary_artifact, cc_info = wrapper_cc_info, - framework_dirs = depset([absolute_framework_dir]), - framework_files = depset([framework_file]), ) return struct( @@ -93,13 +73,13 @@ def _framework_provider_partial_impl( def framework_provider_partial( *, actions, - bin_root_path, binary_artifact, - bundle_name, bundle_only, - cc_features, + cc_configured_features_init, cc_info, cc_toolchain, + disabled_features, + features, rule_label): """Constructor for the framework provider partial. @@ -110,14 +90,15 @@ def framework_provider_partial( Args: actions: The actions provider from `ctx.actions`. - bin_root_path: The path to the root `-bin` directory. binary_artifact: The linked dynamic framework binary. - bundle_name: The name of the output bundle. bundle_only: Only include the bundle but do not link the framework - cc_features: List of enabled C++ features. + cc_configured_features_init: A lambda that is the same as cc_common.configure_features(...) + without the need for a `ctx`. cc_info: The CcInfo provider containing information about the targets linked into the dynamic framework. cc_toolchain: The C++ toolchain to use. + disabled_features: List of features to be disabled for C++ actions. + features: List of features to be enabled for C++ actions. rule_label: The label of the target being analyzed. Returns: @@ -128,12 +109,12 @@ def framework_provider_partial( return partial.make( _framework_provider_partial_impl, actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = bundle_only, - cc_features = cc_features, + cc_configured_features_init = cc_configured_features_init, cc_info = cc_info, cc_toolchain = cc_toolchain, + disabled_features = disabled_features, + features = features, rule_label = rule_label, ) diff --git a/apple/internal/providers.bzl b/apple/internal/providers.bzl index d27e0d1ac1..b04838e96c 100644 --- a/apple/internal/providers.bzl +++ b/apple/internal/providers.bzl @@ -232,15 +232,6 @@ dependencies of the given target if any were generated. AppleDynamicFrameworkInfo, new_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. diff --git a/apple/internal/tvos_rules.bzl b/apple/internal/tvos_rules.bzl index 0c5b471348..b9f86f6c31 100644 --- a/apple/internal/tvos_rules.bzl +++ b/apple/internal/tvos_rules.bzl @@ -494,7 +494,6 @@ def _tvos_dynamic_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, @@ -669,13 +668,13 @@ def _tvos_dynamic_framework_impl(ctx): ), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( @@ -782,7 +781,6 @@ def _tvos_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, label_name = ctx.label.name, @@ -797,13 +795,6 @@ def _tvos_framework_impl(ctx): ) cc_toolchain = find_cc_toolchain(ctx) cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder - cc_features = cc_common.configure_features( - ctx = ctx, - cc_toolchain = cc_toolchain, - language = "objc", - requested_features = ctx.features, - unsupported_features = ctx.disabled_features, - ) executable_name = ctx.attr.executable_name features = features_support.compute_enabled_features( requested_features = ctx.features, @@ -960,13 +951,13 @@ def _tvos_framework_impl(ctx): partials.framework_headers_partial(hdrs = ctx.files.hdrs), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( diff --git a/apple/internal/visionos_rules.bzl b/apple/internal/visionos_rules.bzl index c9c04b17ff..6768e96c91 100644 --- a/apple/internal/visionos_rules.bzl +++ b/apple/internal/visionos_rules.bzl @@ -498,7 +498,6 @@ def _visionos_dynamic_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, @@ -671,13 +670,13 @@ def _visionos_dynamic_framework_impl(ctx): ), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( @@ -787,7 +786,6 @@ def _visionos_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, label_name = ctx.label.name, @@ -802,13 +800,6 @@ def _visionos_framework_impl(ctx): ) cc_toolchain = find_cc_toolchain(ctx) cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder - cc_features = cc_common.configure_features( - ctx = ctx, - cc_toolchain = cc_toolchain, - language = "objc", - requested_features = ctx.features, - unsupported_features = ctx.disabled_features, - ) executable_name = ctx.attr.executable_name features = features_support.compute_enabled_features( requested_features = ctx.features, @@ -965,13 +956,13 @@ def _visionos_framework_impl(ctx): partials.framework_headers_partial(hdrs = ctx.files.hdrs), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( diff --git a/apple/internal/watchos_rules.bzl b/apple/internal/watchos_rules.bzl index daf90e0923..7401f4e1b5 100644 --- a/apple/internal/watchos_rules.bzl +++ b/apple/internal/watchos_rules.bzl @@ -157,7 +157,6 @@ def _watchos_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, @@ -167,13 +166,6 @@ def _watchos_framework_impl(ctx): executable_name = ctx.attr.executable_name cc_toolchain = find_cc_toolchain(ctx) cc_toolchain_forwarder = ctx.split_attr._cc_toolchain_forwarder - cc_features = cc_common.configure_features( - ctx = ctx, - cc_toolchain = cc_toolchain, - language = "objc", - requested_features = ctx.features, - unsupported_features = ctx.disabled_features, - ) features = features_support.compute_enabled_features( requested_features = ctx.features, unsupported_features = ctx.disabled_features, @@ -331,13 +323,13 @@ def _watchos_framework_impl(ctx): partials.framework_headers_partial(hdrs = ctx.files.hdrs), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( @@ -432,7 +424,6 @@ def _watchos_dynamic_framework_impl(ctx): actions = ctx.actions apple_mac_toolchain_info = ctx.attr._mac_toolchain[AppleMacToolsToolchainInfo] apple_xplat_toolchain_info = ctx.attr._xplat_toolchain[AppleXPlatToolsToolchainInfo] - bin_root_path = ctx.bin_dir.path bundle_id = ctx.attr.bundle_id bundle_name, bundle_extension = bundling_support.bundle_full_name( custom_bundle_name = ctx.attr.bundle_name, @@ -611,13 +602,13 @@ def _watchos_dynamic_framework_impl(ctx): ), partials.framework_provider_partial( actions = actions, - bin_root_path = bin_root_path, binary_artifact = binary_artifact, - bundle_name = bundle_name, bundle_only = ctx.attr.bundle_only, - cc_features = cc_features, + cc_configured_features_init = features_support.make_cc_configured_features_init(ctx), cc_info = link_result.cc_info, cc_toolchain = cc_toolchain, + features = features, + disabled_features = ctx.disabled_features, rule_label = label, ), partials.resources_partial( From 74be43b53e905bc5bc415c595aab063d81de2382 Mon Sep 17 00:00:00 2001 From: Nicholas Levin Date: Fri, 25 Apr 2025 07:51:28 -0700 Subject: [PATCH 03/13] Unify all the disassociated references to the "unstripped" binary outputs and the anticipated base name via use of "fragment_support" and "outputs", shared through compilation_support and linking_support. This will be used to reference the unstripped binary that is found in the generated dSYM bundles. Cherry-pick: c19c91b330d8036aa2edd941877c58b79cf91b90 --- apple/internal/BUILD | 12 +++++ apple/internal/compilation_support.bzl | 68 +++++++++++++------------- apple/internal/fragment_support.bzl | 31 ++++++++++++ apple/internal/linking_support.bzl | 30 ++++++++---- apple/internal/outputs.bzl | 47 ++++++++++++++++++ 5 files changed, 143 insertions(+), 45 deletions(-) create mode 100644 apple/internal/fragment_support.bzl diff --git a/apple/internal/BUILD b/apple/internal/BUILD index e98884d67b..fb79217628 100644 --- a/apple/internal/BUILD +++ b/apple/internal/BUILD @@ -202,6 +202,8 @@ bzl_library( "//apple:__subpackages__", ], deps = [ + ":fragment_support", + ":outputs", ":platform_support", "@bazel_skylib//lib:paths", "@rules_cc//cc/common", @@ -261,6 +263,14 @@ bzl_library( ], ) +bzl_library( + name = "fragment_support", + srcs = ["fragment_support.bzl"], + visibility = [ + "//apple:__subpackages__", + ], +) + bzl_library( name = "framework_import_support", srcs = ["framework_import_support.bzl"], @@ -345,6 +355,7 @@ bzl_library( ":compilation_support", ":entitlements_support", ":intermediates", + ":outputs", ":providers", ":rule_support", "@bazel_skylib//lib:collections", @@ -432,6 +443,7 @@ bzl_library( ], deps = [ ":experimental", + ":fragment_support", ":intermediates", "@bazel_skylib//lib:paths", ], diff --git a/apple/internal/compilation_support.bzl b/apple/internal/compilation_support.bzl index 6950c21003..b02986503d 100644 --- a/apple/internal/compilation_support.bzl +++ b/apple/internal/compilation_support.bzl @@ -22,6 +22,14 @@ load( "@rules_cc//cc/common:cc_common.bzl", "cc_common", ) +load( + "//apple/internal:fragment_support.bzl", + "fragment_support", +) +load( + "//apple/internal:outputs.bzl", + "outputs", +) load( "//apple/internal:platform_support.bzl", "platform_support", @@ -163,10 +171,12 @@ def _register_binary_strip_action( "-bundle" in extra_link_args or link_bundle or "-kext" in extra_link_args): strip_safe = True - # TODO(b/331163513): Use intermediates.file() instead of declare_shareable_artifact(). - stripped_binary = ctx.actions.declare_shareable_artifact( - paths.join(ctx.label.package, name), - apple_platform_info.target_build_config.bin_dir, + stripped_binary = outputs.main_binary( + actions = ctx.actions, + apple_platform_info = apple_platform_info, + cpp_fragment = ctx.fragments.cpp, + label = ctx.label, + unstripped = False, ) args = ctx.actions.args() args.add("strip") @@ -240,9 +250,6 @@ def _classify_libraries(libraries_to_link): } return always_link_libraries.keys(), as_needed_libraries.keys() -def _emit_builtin_objc_strip_action(ctx): - return ctx.fragments.cpp.objc_should_strip_binary - def _register_configuration_specific_link_actions( *, additional_outputs, @@ -268,23 +275,19 @@ def _register_configuration_specific_link_actions( ctx = common_variables.ctx feature_configuration = _build_feature_configuration(common_variables) - # When compilation_mode=opt and objc_enable_binary_stripping are specified, the unstripped - # binary containing debug symbols is generated by the linker, which also needs the debug - # symbols for dead-code removal. The binary is also used to generate dSYM bundle if - # --apple_generate_dsym is specified. A symbol strip action is later registered to strip - # the symbol table from the unstripped binary. - if _emit_builtin_objc_strip_action(ctx): - # TODO(b/331163513): Use intermediates.file() instead of declare_shareable_artifact(). - binary = ctx.actions.declare_shareable_artifact( - paths.join(ctx.label.package, name + "_unstripped"), - apple_platform_info.target_build_config.bin_dir, - ) + # TODO: Remove when we drop Bazel 8 + if bazel_features.cc.objc_fragment_has_builtin_objc_strip_action: + unstripped = ctx.fragments.objc.builtin_objc_strip_action else: - # TODO(b/331163513): Use intermediates.file() instead of declare_shareable_artifact(). - binary = ctx.actions.declare_shareable_artifact( - paths.join(ctx.label.package, name), - apple_platform_info.target_build_config.bin_dir, - ) + unstripped = False + + binary = outputs.main_binary( + actions = ctx.actions, + apple_platform_info = apple_platform_info, + cpp_fragment = ctx.fragments.cpp, + label = ctx.label, + unstripped = unstripped, + ) # TODO: Delete feature check and else branch when we drop Bazel 8 support (see f4a3fa40) if cc_common.is_enabled( @@ -374,7 +377,12 @@ def _register_configuration_specific_link_actions_with_cpp_variables( variables_extension = user_variable_extensions, ) - if _emit_builtin_objc_strip_action(ctx): + # TODO: Remove bazel_features check when we drop Baze 8 + if bazel_features.cc.objc_fragment_has_builtin_objc_strip_action and \ + fragment_support.is_objc_strip_action_enabled( + cpp_fragment = ctx.fragments.cpp, + ) and \ + ctx.fragments.objc.builtin_objc_strip_action: return _register_binary_strip_action( ctx = ctx, apple_platform_info = apple_platform_info, @@ -554,17 +562,7 @@ def _register_configuration_specific_link_actions_with_objc_variables( main_output = binary, ) - if _emit_builtin_objc_strip_action(ctx): - return _register_binary_strip_action( - apple_platform_info = apple_platform_info, - binary = binary, - ctx = ctx, - extra_link_args = extra_link_args, - feature_configuration = feature_configuration, - name = name, - ) - else: - return binary + return binary compilation_support = struct( # TODO(b/331163513): Move apple_common.compliation_support.build_common_variables here, too. diff --git a/apple/internal/fragment_support.bzl b/apple/internal/fragment_support.bzl new file mode 100644 index 0000000000..34797eec7f --- /dev/null +++ b/apple/internal/fragment_support.bzl @@ -0,0 +1,31 @@ +# Copyright 2025 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. + +"""Wrapper to centralize configuration of fragment-based logic.""" + +visibility([ + "//apple/...", + "//test/...", +]) + +def _is_objc_strip_action_enabled(*, cpp_fragment): + """Returns wheither the Objective-C strip action is active.""" + return ( + cpp_fragment.objc_enable_binary_stripping() and + cpp_fragment.compilation_mode() == "opt" + ) + +fragment_support = struct( + is_objc_strip_action_enabled = _is_objc_strip_action_enabled, +) diff --git a/apple/internal/linking_support.bzl b/apple/internal/linking_support.bzl index 6a468016b7..8a53bc108a 100644 --- a/apple/internal/linking_support.bzl +++ b/apple/internal/linking_support.bzl @@ -37,6 +37,10 @@ load( "//apple/internal:multi_arch_binary_support.bzl", "subtract_linking_contexts", ) +load( + "//apple/internal:outputs.bzl", + "outputs", +) load( "//apple/internal:providers.bzl", "AppleDynamicFrameworkInfo", @@ -219,7 +223,7 @@ def _link_multi_arch_binary( 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] - outputs = [] + linker_outputs = [] cc_infos = [] legacy_debug_outputs = {} @@ -295,15 +299,16 @@ Please report this as a bug to the Apple BUILD Rules team. dsym_variants = dsym_variants, )) else: - if ctx.fragments.cpp.objc_should_strip_binary: - suffix = "_bin_unstripped" - else: - suffix = "_bin" + main_binary_unstripped_basename = outputs.main_binary_basename( + cpp_fragment = ctx.fragments.cpp, + label_name = ctx.label.name, + unstripped = True, + ) dsym_output = intermediates.file( actions = ctx.actions, target_name = ctx.label.name, output_discriminator = split_transition_key, - file_name = "{}.dwarf".format(ctx.label.name + suffix), + file_name = "{}.dwarf".format(main_binary_unstripped_basename), ) # TODO(b/391401130): Remove this once all users are migrated to the downstream @@ -328,7 +333,12 @@ Please report this as a bug to the Apple BUILD Rules team. additional_outputs.append(linkmap) legacy_debug_outputs.setdefault(platform_info.target_arch, {})["linkmap"] = linkmap - name = ctx.label.name + "_bin" + main_binary_basename = outputs.main_binary_basename( + cpp_fragment = ctx.fragments.cpp, + label_name = ctx.label.name, + unstripped = False, + ) + executable = compilation_support.register_configuration_specific_link_actions( additional_outputs = additional_outputs, apple_platform_info = platform_info, @@ -337,7 +347,7 @@ Please report this as a bug to the Apple BUILD Rules team. common_variables = common_variables, extra_link_args = extra_linkopts, extra_link_inputs = extra_link_inputs, - name = name, + name = main_binary_basename, # TODO: Delete when we drop Bazel 8 support (see f4a3fa40) split_transition_key = split_transition_key, stamp = stamp, @@ -353,7 +363,7 @@ Please report this as a bug to the Apple BUILD Rules team. "linkmap": linkmap, } - outputs.append(struct(**output)) + linker_outputs.append(struct(**output)) header_tokens = [] for _, deps in split_deps.items(): @@ -366,7 +376,7 @@ Please report this as a bug to the Apple BUILD Rules team. return struct( cc_info = cc_common.merge_cc_infos(direct_cc_infos = cc_infos), output_groups = output_groups, - outputs = outputs, + outputs = linker_outputs, debug_outputs_provider = new_appledebugoutputsinfo(outputs_map = legacy_debug_outputs), ) diff --git a/apple/internal/outputs.bzl b/apple/internal/outputs.bzl index 145c851d7e..a57dd73480 100644 --- a/apple/internal/outputs.bzl +++ b/apple/internal/outputs.bzl @@ -26,6 +26,10 @@ load( "//apple/internal:experimental.bzl", "is_experimental_tree_artifact_enabled", ) +load( + "//apple/internal:fragment_support.bzl", + "fragment_support", +) load( "//apple/internal:intermediates.bzl", "intermediates", @@ -127,6 +131,47 @@ def _infoplist(*, actions, label_name, output_discriminator): file_name = "Info.plist", ) +def _main_binary( + *, + actions, + apple_platform_info, + cpp_fragment, + label, + unstripped): + """Returns a file reference for the main binary that gets linked.""" + + # TODO(b/331163513): Use intermediates.file() instead of declare_shareable_artifact() as soon as + # it is safe to do so. + return actions.declare_shareable_artifact( + paths.join(label.package, _main_binary_basename( + cpp_fragment = cpp_fragment, + label_name = label.name, + unstripped = unstripped, + )), + apple_platform_info.target_build_config.bin_dir, + ) + +def _main_binary_basename( + *, + cpp_fragment, + label_name, + unstripped): + """Returns the basename of the main binary that gets linked.""" + + # When compilation_mode=opt and objc_enable_binary_stripping are specified, the unstripped + # binary containing debug symbols is generated by the linker, which also needs the debug + # symbols for dead-code removal. The binary is also used to generate dSYM bundle if + # --apple_generate_dsym is specified. A symbol strip action is later registered to strip + # the symbol table from the unstripped binary. + if fragment_support.is_objc_strip_action_enabled( + cpp_fragment = cpp_fragment, + ) and unstripped: + suffix = "_bin_unstripped" + else: + suffix = "_bin" + + return label_name + suffix + def _has_different_embedding_archive(*, platform_prerequisites, rule_descriptor): """Returns True if this target exposes a different archive when embedded in another target.""" tree_artifact_enabled = is_experimental_tree_artifact_enabled( @@ -193,6 +238,8 @@ outputs = struct( dsyms = _dsyms, executable = _executable, infoplist = _infoplist, + main_binary = _main_binary, + main_binary_basename = _main_binary_basename, merge_output_groups = _merge_output_groups, root_path_from_archive = _root_path_from_archive, has_different_embedding_archive = _has_different_embedding_archive, From 4ea6d99c43b5c5bc06bf26686eed574082abce43 Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Thu, 15 Jan 2026 11:22:23 -0500 Subject: [PATCH 04/13] Sync `debug_symbols.bzl` with upstream --- apple/internal/partials/debug_symbols.bzl | 121 ++++++++++++++-------- apple/internal/resource_actions/plist.bzl | 3 + 2 files changed, 79 insertions(+), 45 deletions(-) diff --git a/apple/internal/partials/debug_symbols.bzl b/apple/internal/partials/debug_symbols.bzl index 44c0433c7e..42e32fc76d 100644 --- a/apple/internal/partials/debug_symbols.bzl +++ b/apple/internal/partials/debug_symbols.bzl @@ -22,11 +22,14 @@ load( "@bazel_skylib//lib:paths.bzl", "paths", ) +load( + "@bazel_skylib//lib:shell.bzl", + "shell", +) load( "@build_bazel_apple_support//lib:apple_support.bzl", "apple_support", ) -load("@build_bazel_apple_support//lib:lipo.bzl", "lipo") load( "//apple:providers.bzl", "AppleBundleVersionInfo", @@ -54,6 +57,8 @@ load( "defines", ) +visibility("//apple/...") + def _declare_linkmap( *, actions, @@ -107,13 +112,12 @@ def _collect_linkmaps( return outputs -def _generate_dsym_binaries( +def _copy_dsyms_into_declared_bundle( *, actions, debug_output_filename, dsym_bundle_name, - found_binaries_by_arch, - platform_prerequisites): + found_binaries_by_arch): """Declares the dSYM binary file and copies it into the preferred .dSYM bundle location. Args: @@ -124,22 +128,25 @@ def _generate_dsym_binaries( dsym_bundle_name: The full name of the dSYM bundle, including its extension. found_binaries_by_arch: A mapping of architectures to Files representing dsym binary outputs for each architecture. - platform_prerequisites: Struct containing information on the platform being targeted. Returns: A list of Files representing the copied dSYM binary which is located in the preferred .dSYM bundle locations. """ - output_binary = actions.declare_file( - "%s/Contents/Resources/DWARF/%s" % ( - dsym_bundle_name, + output_binaries = [] + + for arch, dsym_binary in found_binaries_by_arch.items(): + output_relpath = "Contents/Resources/DWARF/%s_%s" % ( debug_output_filename, - ), - ) + arch, + ) - # Copy the binary over if there's only a single arch. - if len(found_binaries_by_arch) == 1: - dsym_binary = found_binaries_by_arch.values()[0] + output_binary = actions.declare_file( + "%s/%s" % ( + dsym_bundle_name, + output_relpath, + ), + ) # cp instead of symlink here because a dSYM with a symlink to the DWARF data will not be # recognized by spotlight which is key for lldb on mac to find a dSYM for a binary. @@ -159,21 +166,49 @@ fi cp $flags "{src}" "{dst}" """.format(src = dsym_binary.path, dst = output_binary.path), ) - else: - lipo.create( - actions = actions, - apple_fragment = platform_prerequisites.apple_fragment, - inputs = found_binaries_by_arch.values(), - output = output_binary, - xcode_config = platform_prerequisites.xcode_version_config, - ) - return [output_binary] + output_binaries.append(output_binary) + + return output_binaries + +def _lipo_command_for_dsyms( + *, + debug_output_filename, + found_binaries_by_arch): + """Returns a shell command to invoke lipo against all provided dSYMs for a given bundle. + + Args: + debug_output_filename: The base file name to use for this debug output, which will be followed + by the architecture with an underscore to make the dSYM binary file name or with the bundle + extension following it for the dSYM bundle file name. + found_binaries_by_arch: A mapping of architectures to Files representing dsym binary outputs + for each architecture. + + Returns: + A String representing the shell command to invoke lipo, referencing an OUTPUT_DIR shell + variable that is expected to represent the dSYM bundle root. + """ + found_binary_paths = [] + + for dsym_binary in found_binaries_by_arch.values(): + found_binary_paths.append(dsym_binary.path) + + lipo_command = ( + "/usr/bin/lipo " + + "-create {found_binary_inputs} " + + "-output \"${{OUTPUT_DIR}}/Contents/Resources/DWARF/{debug_output_filename}\"" + ).format( + found_binary_inputs = " ".join([shell.quote(path) for path in found_binary_paths]), + debug_output_filename = debug_output_filename, + ) + + return lipo_command def _generate_dsym_info_plist( actions, dsym_bundle_name, dsym_info_plist_template, + mac_exec_group, output_discriminator, platform_prerequisites, plisttool, @@ -185,6 +220,7 @@ def _generate_dsym_info_plist( actions: The actions provider from `ctx.actions`. dsym_bundle_name: The full name of the dSYM bundle, including its extension. dsym_info_plist_template: File referencing a plist template for dSYM bundles. + mac_exec_group: The exec_group associated with plisttool. output_discriminator: A string to differentiate between different target intermediate files or `None`. platform_prerequisites: Struct containing information on the platform being targeted. @@ -237,6 +273,7 @@ def _generate_dsym_info_plist( actions = actions, control_file = control_file, inputs = plisttool_input_files, + mac_exec_group = mac_exec_group, mnemonic = "CompileDSYMInfoPlist", outputs = [dsym_plist], platform_prerequisites = platform_prerequisites, @@ -251,7 +288,7 @@ def _bundle_dsym_files( debug_output_filename, dsym_binaries = {}, dsym_info_plist_template, - dsym_output_filename, + mac_exec_group, label_name, output_discriminator, platform_prerequisites, @@ -276,7 +313,7 @@ def _bundle_dsym_files( dsym_binaries: A mapping of architectures to Files representing dSYM binary outputs for each architecture. dsym_info_plist_template: File referencing a plist template for dSYM bundles. - dsym_output_filename: The dSYM binary file name. + mac_exec_group: The exec_group associated with plisttool. label_name: The name of the target. output_discriminator: A string to differentiate between different target intermediate files or `None`. @@ -305,21 +342,16 @@ def _bundle_dsym_files( found_binaries_by_arch.update(dsym_binaries) if found_binaries_by_arch: - generated_dsym_binaries = _generate_dsym_binaries( + output_files = _copy_dsyms_into_declared_bundle( actions = actions, - debug_output_filename = dsym_output_filename, + debug_output_filename = debug_output_filename, dsym_bundle_name = dsym_bundle_name, found_binaries_by_arch = found_binaries_by_arch, - platform_prerequisites = platform_prerequisites, ) - output_files.extend(generated_dsym_binaries) - dsyms_command = (" && ".join([ - "cp \"{dsym_path}\" \"${{OUTPUT_DIR}}/Contents/Resources/DWARF/{dsym_bundle_name}\"".format( - dsym_path = dsym_binary.path, - dsym_bundle_name = dsym_output_filename, - ) - for dsym_binary in generated_dsym_binaries - ])) + lipo_command = _lipo_command_for_dsyms( + debug_output_filename = debug_output_filename, + found_binaries_by_arch = found_binaries_by_arch, + ) # If we found any binaries, create the Info.plist for the bundle as well. dsym_plist = _generate_dsym_info_plist( @@ -327,6 +359,7 @@ def _bundle_dsym_files( dsym_bundle_name = dsym_bundle_name, dsym_info_plist_template = dsym_info_plist_template, output_discriminator = output_discriminator, + mac_exec_group = mac_exec_group, platform_prerequisites = platform_prerequisites, plisttool = plisttool, rule_label = rule_label, @@ -344,9 +377,10 @@ def _bundle_dsym_files( apple_support.run_shell( actions = actions, apple_fragment = platform_prerequisites.apple_fragment, - inputs = generated_dsym_binaries + [dsym_plist] + found_binaries_by_arch.values(), + inputs = [dsym_plist] + found_binaries_by_arch.values(), outputs = [dsym_bundle_dir], - command = ("mkdir -p \"${OUTPUT_DIR}/Contents/Resources/DWARF\" && " + dsyms_command + " && " + plist_command), + command = ("mkdir -p \"${OUTPUT_DIR}/Contents/Resources/DWARF\" && " + lipo_command + + " && " + plist_command), env = { "OUTPUT_DIR": dsym_bundle_dir.path, }, @@ -365,9 +399,9 @@ def _debug_symbols_partial_impl( debug_discriminator = None, dsym_binaries = {}, dsym_info_plist_template, - executable_name = None, label_name, linkmaps = {}, + mac_exec_group, output_discriminator = None, platform_prerequisites, plisttool, @@ -408,16 +442,13 @@ def _debug_symbols_partial_impl( if platform_prerequisites.cpp_fragment: if platform_prerequisites.cpp_fragment.apple_generate_dsym: - dsym_output_filename = executable_name or bundle_name - if debug_discriminator: - dsym_output_filename += "_" + debug_discriminator dsym_files, dsym_bundle_dir = _bundle_dsym_files( actions = actions, bundle_extension = bundle_extension, debug_output_filename = debug_output_filename, dsym_binaries = dsym_binaries, dsym_info_plist_template = dsym_info_plist_template, - dsym_output_filename = dsym_output_filename, + mac_exec_group = mac_exec_group, label_name = label_name, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, @@ -495,9 +526,9 @@ def debug_symbols_partial( debug_discriminator = None, dsym_binaries = {}, dsym_info_plist_template, - executable_name = None, label_name, linkmaps = {}, + mac_exec_group, output_discriminator = None, platform_prerequisites, plisttool, @@ -523,9 +554,9 @@ def debug_symbols_partial( dsym_binaries: A mapping of architectures to Files representing dsym binary outputs for each architecture. dsym_info_plist_template: File referencing a plist template for dSYM bundles. - executable_name: The name of the output DWARF executable. label_name: The name of the target. linkmaps: A mapping of architectures to Files representing linkmaps for each architecture. + mac_exec_group: The exec_group associated with plisttool. output_discriminator: A string to differentiate between different target intermediate files or `None`. platform_prerequisites: Struct containing information on the platform being targeted. @@ -545,9 +576,9 @@ def debug_symbols_partial( debug_discriminator = debug_discriminator, dsym_binaries = dsym_binaries, dsym_info_plist_template = dsym_info_plist_template, - executable_name = executable_name or bundle_name, label_name = label_name, linkmaps = linkmaps, + mac_exec_group = mac_exec_group, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, plisttool = plisttool, diff --git a/apple/internal/resource_actions/plist.bzl b/apple/internal/resource_actions/plist.bzl index 35ea4fe4f0..383283b11d 100644 --- a/apple/internal/resource_actions/plist.bzl +++ b/apple/internal/resource_actions/plist.bzl @@ -44,6 +44,7 @@ def plisttool_action( actions, control_file, inputs, + mac_exec_group = None, mnemonic = None, outputs, platform_prerequisites, @@ -58,6 +59,7 @@ def plisttool_action( actions: The actions provider from `ctx.actions`. control_file: The `File` containing the control struct to be passed to plisttool. inputs: Any `File`s that should be treated as inputs to the underlying action. + mac_exec_group: The exec_group associated with plisttool. mnemonic: The mnemonic to display when the action executes. Defaults to None. outputs: Any `File`s that should be treated as outputs of the underlying action. platform_prerequisites: Struct containing information on the platform being targeted. @@ -69,6 +71,7 @@ def plisttool_action( arguments = [control_file.path], executable = plisttool, inputs = inputs + [control_file], + exec_group = mac_exec_group, mnemonic = mnemonic, outputs = outputs, xcode_config = platform_prerequisites.xcode_version_config, From ca66bd71c45d2526c1981cf818bd713a87562ea7 Mon Sep 17 00:00:00 2001 From: Nicholas Levin Date: Fri, 25 Apr 2025 08:33:42 -0700 Subject: [PATCH 05/13] Handle "bundle" outputs from the crosstool primarily via the debug symbols partial. Tests for other platforms and targets besides ios_application will arrive in a following commit. NOTE: includes manual addition of `dsym_variant_flag` since its not public in the upstream code Cherry-pick: 7a0ef14a7bab82b02074203595e2a27382bfd75d --- apple/internal/ios_rules.bzl | 24 +- apple/internal/linking_support.bzl | 32 +- apple/internal/macos_rules.bzl | 45 +-- apple/internal/partials/BUILD | 2 + .../internal/partials/apple_symbols_file.bzl | 20 +- apple/internal/partials/debug_symbols.bzl | 335 +++++++++++------- apple/internal/resource_actions/plist.bzl | 3 - .../testing/apple_test_bundle_support.bzl | 2 +- apple/internal/tvos_rules.bzl | 18 +- apple/internal/visionos_rules.bzl | 20 +- apple/internal/watchos_rules.bzl | 21 +- apple/internal/xcframework_rules.bzl | 15 +- test/starlark_tests/ios_application_tests.bzl | 86 ++++- .../analysis_output_group_info_files_test.bzl | 31 ++ .../rules/apple_dsym_bundle_info_test.bzl | 46 ++- 15 files changed, 456 insertions(+), 244 deletions(-) diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index 69537ae597..35d6cd22c0 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -343,9 +343,8 @@ def _ios_application_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = embeddable_targets + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -409,7 +408,7 @@ def _ios_application_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = ctx.attr.include_symbols_in_bundle, platform_prerequisites = platform_prerequisites, @@ -709,9 +708,8 @@ def _ios_app_clip_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = embeddable_targets + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1033,9 +1031,8 @@ def _ios_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1097,7 +1094,7 @@ def _ios_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1338,9 +1335,8 @@ def _ios_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1390,7 +1386,7 @@ def _ios_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1624,9 +1620,8 @@ def _ios_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -2276,9 +2271,8 @@ def _ios_imessage_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, diff --git a/apple/internal/linking_support.bzl b/apple/internal/linking_support.bzl index 8a53bc108a..f6ff060a2c 100644 --- a/apple/internal/linking_support.bzl +++ b/apple/internal/linking_support.bzl @@ -156,6 +156,7 @@ def _link_multi_arch_binary( extra_link_inputs, extra_requested_features, extra_disabled_features, + rule_descriptor, stamp): """Links a (potentially multi-architecture) binary targeting Apple platforms. @@ -182,6 +183,9 @@ def _link_multi_arch_binary( to the linker action. extra_disabled_features: A list of strings: Extra disabled features to be passed to the linker action. + rule_descriptor: The rule descriptor if one exists for the given rule. For convenience, This + will define additional parameters required for linking, such as the dSYM bundle name. If + `None`, these additional parameters will not be set on the linked binary. stamp: Whether to include build information in the linked binary. If 1, build information is always included. If 0, build information is always excluded. If -1 (the default), then the behavior is determined by the --[no]stamp @@ -287,9 +291,18 @@ def _link_multi_arch_binary( if ctx.fragments.cpp.apple_generate_dsym: dsym_variants = build_settings.dsym_variant_flag if dsym_variants == "bundle": - # TODO(b/391401130): Remove this once dsymutil generated bundle dSYM output is - # supported. - fail("dsymutil bundle dSYM output is not yet supported by the Apple BUILD Rules.") + if rule_descriptor: + dsym_bundle_name = ctx.label.name + rule_descriptor.bundle_extension + else: + dsym_bundle_name = ctx.label.name + + # Avoiding "intermediates" as this will be the canonical dSYM in a single arch build + dsym_output = ctx.actions.declare_directory( + "{split_transition_key}/{dsym_bundle_name}.dSYM".format( + split_transition_key = split_transition_key, + dsym_bundle_name = dsym_bundle_name, + ), + ) elif dsym_variants != "flat": fail(""" Internal Error: Found unsupported dsym_variant_flag: {dsym_variants}. @@ -359,7 +372,7 @@ Please report this as a bug to the Apple BUILD Rules team. "platform": platform_info.target_os, "architecture": platform_info.target_arch, "environment": platform_info.target_environment, - "dsym_binary": dsym_output, + "dsym_output": dsym_output, "linkmap": linkmap, } @@ -390,20 +403,20 @@ def _debug_outputs_by_architecture(link_outputs): Returns: A `struct` containing three fields: - * `dsym_binaries`: A mapping of architectures to Files representing dSYM binary outputs - for each architecture. + * `dsym_outputs`: A mapping of architectures to Files representing dSYM outputs for each + architecture. * `linkmaps`: A mapping of architectures to Files representing linkmaps for each architecture. """ - dsym_binaries = {} + dsym_outputs = {} linkmaps = {} for link_output in link_outputs: - dsym_binaries[link_output.architecture] = link_output.dsym_binary + dsym_outputs[link_output.architecture] = link_output.dsym_output linkmaps[link_output.architecture] = link_output.linkmap return struct( - dsym_binaries = dsym_binaries, + dsym_outputs = dsym_outputs, linkmaps = linkmaps, ) @@ -590,6 +603,7 @@ def _register_binary_linking_action( # TODO(321109350): Disable include scanning to work around issue with GrepIncludes actions # being routed to the wrong exec platform. extra_disabled_features = extra_disabled_features + ["cc_include_scanning"], + rule_descriptor = rule_descriptor, stamp = stamp, ) diff --git a/apple/internal/macos_rules.bzl b/apple/internal/macos_rules.bzl index 87a4f51842..37acb831b7 100644 --- a/apple/internal/macos_rules.bzl +++ b/apple/internal/macos_rules.bzl @@ -317,9 +317,8 @@ def _macos_application_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = embedded_targets + ctx.attr.additional_contents.keys(), - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -381,7 +380,7 @@ def _macos_application_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embedded_targets, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = ctx.attr.include_symbols_in_bundle, platform_prerequisites = platform_prerequisites, @@ -624,9 +623,8 @@ def _macos_bundle_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.additional_contents.keys(), - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -889,9 +887,8 @@ def _macos_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.additional_contents.keys(), - dsym_binaries = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -938,7 +935,7 @@ def _macos_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = [], - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1151,9 +1148,8 @@ def _macos_quick_look_plugin_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.additional_contents.keys(), - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1196,7 +1192,7 @@ def _macos_quick_look_plugin_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = [], - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1404,9 +1400,8 @@ def _macos_kernel_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.additional_contents.keys(), - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1449,7 +1444,7 @@ def _macos_kernel_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = [], - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1647,9 +1642,8 @@ def _macos_spotlight_importer_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.additional_contents.keys(), - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1691,7 +1685,7 @@ def _macos_spotlight_importer_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = [], - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1889,9 +1883,8 @@ def _macos_xpc_service_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.additional_contents.keys(), - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1933,7 +1926,7 @@ def _macos_xpc_service_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = [], - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -2042,7 +2035,7 @@ def _macos_command_line_application_impl(ctx): actions = actions, bundle_extension = bundle_extension, bundle_name = bundle_name, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -2186,7 +2179,7 @@ def _macos_dylib_impl(ctx): actions = actions, bundle_extension = bundle_extension, bundle_name = bundle_name, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -2937,9 +2930,8 @@ def _macos_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -3001,7 +2993,7 @@ def _macos_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -3218,9 +3210,8 @@ def _macos_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, diff --git a/apple/internal/partials/BUILD b/apple/internal/partials/BUILD index 4e4366e96c..26368e9102 100644 --- a/apple/internal/partials/BUILD +++ b/apple/internal/partials/BUILD @@ -147,11 +147,13 @@ bzl_library( deps = [ "//apple:providers", "//apple/internal:intermediates", + "//apple/internal:outputs", "//apple/internal:providers", "//apple/internal:resource_actions", "//apple/internal/providers:apple_debug_info", "//apple/internal/utils:defines", "@bazel_skylib//lib:partial", + "@bazel_skylib//lib:paths", "@bazel_skylib//lib:shell", "@build_bazel_apple_support//lib:apple_support", ], diff --git a/apple/internal/partials/apple_symbols_file.bzl b/apple/internal/partials/apple_symbols_file.bzl index 1a5cfb3553..a3ac156545 100644 --- a/apple/internal/partials/apple_symbols_file.bzl +++ b/apple/internal/partials/apple_symbols_file.bzl @@ -48,7 +48,7 @@ def _apple_symbols_file_partial_impl( actions, binary_artifact, dependency_targets, - dsym_binaries, + dsym_outputs, label_name, output_discriminator, include_symbols_in_bundle, @@ -56,13 +56,19 @@ def _apple_symbols_file_partial_impl( """Implementation for the Apple .symbols file processing partial.""" outputs = [] if (platform_prerequisites.cpp_fragment.apple_generate_dsym and - binary_artifact and dsym_binaries): + binary_artifact and dsym_outputs): inputs = [binary_artifact] - for dsym_binary in dsym_binaries.values(): - inputs.append(dsym_binary) + + # The xcrun symbols tool can handle both dSYM bundles and "flat file" dSYM binaries as + # inputs; therefore, we handle them as inputs in the same way without "guessing" paths to + # the dSYM binaries in a dSYM bundle. + for dsym_output in dsym_outputs.values(): + inputs.append(dsym_output) + for target in dependency_targets: if AppleFrameworkImportInfo in target: inputs.extend(target[AppleFrameworkImportInfo].debug_info_binaries.to_list()) + output = intermediates.directory( actions = actions, target_name = label_name, @@ -110,7 +116,7 @@ def apple_symbols_file_partial( actions, binary_artifact, dependency_targets = [], - dsym_binaries, + dsym_outputs, label_name, output_discriminator = None, include_symbols_in_bundle, @@ -122,7 +128,7 @@ def apple_symbols_file_partial( binary_artifact: The main binary artifact for this target. dependency_targets: List of targets that should be checked for files that need to be bundled. - dsym_binaries: A mapping of architectures to Files representing dsym binary outputs for each + dsym_outputs: A mapping of architectures to Files representing dsym outputs for each architecture. label_name: Name of the target being built. output_discriminator: A string to differentiate between different target intermediate files @@ -139,7 +145,7 @@ def apple_symbols_file_partial( actions = actions, binary_artifact = binary_artifact, dependency_targets = dependency_targets, - dsym_binaries = dsym_binaries, + dsym_outputs = dsym_outputs, include_symbols_in_bundle = include_symbols_in_bundle, label_name = label_name, output_discriminator = output_discriminator, diff --git a/apple/internal/partials/debug_symbols.bzl b/apple/internal/partials/debug_symbols.bzl index 42e32fc76d..9e93d8f618 100644 --- a/apple/internal/partials/debug_symbols.bzl +++ b/apple/internal/partials/debug_symbols.bzl @@ -40,6 +40,10 @@ load( "//apple/internal:intermediates.bzl", "intermediates", ) +load( + "//apple/internal:outputs.bzl", + "outputs", +) load( "//apple/internal:providers.bzl", "new_appledsymbundleinfo", @@ -68,14 +72,14 @@ def _declare_linkmap( """Declares a linkmap for this binary. Args: - actions: The actions provider from `ctx.actions`. - arch: The architecture specified for this particular debug output. - debug_output_filename: The base file name to use for this debug output, which will be followed - by the architecture with an underscore to make this linkmap's file name. - linkmap: The linkmap that was generated by the linking action. + actions: The actions provider from `ctx.actions`. + arch: The architecture specified for this particular debug output. + debug_output_filename: The base file name to use for this debug output, which will be + followed by the architecture with an underscore to make this linkmap's file name. + linkmap: The linkmap that was generated by the linking action. Returns: - A linkmap file for the given architecture. + A linkmap file for the given architecture. """ output_linkmap = actions.declare_file( "%s_%s.linkmap" % (debug_output_filename, arch), @@ -91,13 +95,13 @@ def _collect_linkmaps( """Collects the available linkmaps from the binary. Args: - actions: The actions provider from `ctx.actions`. - debug_output_filename: The base file name to use for this debug output, which will be followed - by each architecture with an underscore to make each linkmap's file name. - linkmaps: A mapping of architectures to Files representing linkmaps for each architecture. + actions: The actions provider from `ctx.actions`. + debug_output_filename: The base file name to use for this debug output, which will be + followed by each architecture with an underscore to make each linkmap's file name. + linkmaps: A mapping of architectures to Files representing linkmaps for each architecture. Returns: - A list of linkmap files, one per linked architecture. + A list of linkmap files, one per linked architecture. """ outputs = [] @@ -121,17 +125,17 @@ def _copy_dsyms_into_declared_bundle( """Declares the dSYM binary file and copies it into the preferred .dSYM bundle location. Args: - actions: The actions provider from `ctx.actions`. - debug_output_filename: The base file name to use for this debug output, which will be followed - by the architecture with an underscore to make the dSYM binary file name or with the bundle - extension following it for the dSYM bundle file name. - dsym_bundle_name: The full name of the dSYM bundle, including its extension. - found_binaries_by_arch: A mapping of architectures to Files representing dsym binary outputs - for each architecture. + actions: The actions provider from `ctx.actions`. + debug_output_filename: The base file name to use for this debug output, which will be + followed by the architecture with an underscore to make the dSYM binary file name or + with the bundle extension following it for the dSYM bundle file name. + dsym_bundle_name: The full name of the dSYM bundle, including its extension. + found_binaries_by_arch: A mapping of architectures to Files representing dsym binary outputs + for each architecture. Returns: - A list of Files representing the copied dSYM binary which is located in the preferred .dSYM - bundle locations. + A list of Files representing the copied dSYM binaries located in the preferred .dSYM bundle + locations. """ output_binaries = [] @@ -173,42 +177,78 @@ cp $flags "{src}" "{dst}" def _lipo_command_for_dsyms( *, - debug_output_filename, - found_binaries_by_arch): + bundle_inputs, + found_dsyms_by_arch, + main_binary_basename): """Returns a shell command to invoke lipo against all provided dSYMs for a given bundle. Args: - debug_output_filename: The base file name to use for this debug output, which will be followed - by the architecture with an underscore to make the dSYM binary file name or with the bundle - extension following it for the dSYM bundle file name. - found_binaries_by_arch: A mapping of architectures to Files representing dsym binary outputs - for each architecture. + bundle_inputs: Wheither the found binaries are actually dSYM bundles. + found_dsyms_by_arch: A mapping of architectures to Files representing dsym outputs for each + architecture. + main_binary_basename: The basename of the main unstripped binary that was linked to generate + the dSYM. Returns: - A String representing the shell command to invoke lipo, referencing an OUTPUT_DIR shell - variable that is expected to represent the dSYM bundle root. + A String representing the shell command to invoke lipo, referencing an OUTPUT_DIR shell + variable that is expected to represent the dSYM bundle root. """ found_binary_paths = [] - for dsym_binary in found_binaries_by_arch.values(): - found_binary_paths.append(dsym_binary.path) + if bundle_inputs: + for dsym_bundle in found_dsyms_by_arch.values(): + found_binary = dsym_bundle.path + paths.join( + "/Contents/Resources/DWARF", + main_binary_basename, + ) + found_binary_paths.append(found_binary) + else: + for dsym_binary in found_dsyms_by_arch.values(): + found_binary_paths.append(dsym_binary.path) lipo_command = ( + "mkdir -p ${{OUTPUT_DIR}}/Contents/Resources/DWARF && " + "/usr/bin/lipo " + "-create {found_binary_inputs} " + - "-output \"${{OUTPUT_DIR}}/Contents/Resources/DWARF/{debug_output_filename}\"" + "-output ${{OUTPUT_DIR}}/Contents/Resources/DWARF/{main_binary_basename}" ).format( found_binary_inputs = " ".join([shell.quote(path) for path in found_binary_paths]), - debug_output_filename = debug_output_filename, + main_binary_basename = main_binary_basename, ) return lipo_command +def _ditto_command_for_dsyms(*, found_binaries_by_arch): + """Returns a shell command to invoke ditto against the provided dSYMs for a given bundle. + + Args: + found_binaries_by_arch: A mapping of architectures to Files representing dsym outputs for + each architecture. + + Returns: + A String representing the shell command to invoke ditto, referencing an OUTPUT_DIR shell + variable that is expected to represent the dSYM bundle root. + """ + found_binary_paths = [] + + for dsym_binary in found_binaries_by_arch.values(): + found_binary_paths.append(dsym_binary.path + "/Contents/Resources/Relocations") + + ditto_command = ( + "mkdir -p \"${{OUTPUT_DIR}}/Contents/Resources/Relocations\" && " + + "/usr/bin/ditto " + + "{found_binary_inputs} " + + "\"${{OUTPUT_DIR}}/Contents/Resources/Relocations\"" + ).format( + found_binary_inputs = " ".join([shell.quote(path) for path in found_binary_paths]), + ) + + return ditto_command + def _generate_dsym_info_plist( actions, dsym_bundle_name, dsym_info_plist_template, - mac_exec_group, output_discriminator, platform_prerequisites, plisttool, @@ -217,19 +257,18 @@ def _generate_dsym_info_plist( """Generates an XML Info.plist appropriate for a dSYM bundle. Args: - actions: The actions provider from `ctx.actions`. - dsym_bundle_name: The full name of the dSYM bundle, including its extension. - dsym_info_plist_template: File referencing a plist template for dSYM bundles. - mac_exec_group: The exec_group associated with plisttool. - output_discriminator: A string to differentiate between different target intermediate files - or `None`. - platform_prerequisites: Struct containing information on the platform being targeted. - plisttool: A files_to_run for the plist tool. - rule_label: The label of the target being analyzed. - version: A label referencing AppleBundleVersionInfo, if provided by the rule. + actions: The actions provider from `ctx.actions`. + dsym_bundle_name: The full name of the dSYM bundle, including its extension. + dsym_info_plist_template: File referencing a plist template for dSYM bundles. + output_discriminator: A string to differentiate between different target intermediate files + or `None`. + platform_prerequisites: Struct containing information on the platform being targeted. + plisttool: A files_to_run for the plist tool. + rule_label: The label of the target being analyzed. + version: A label referencing AppleBundleVersionInfo, if provided by the rule. Returns: - A File representing the generated Info.plist for the dSYM bundle. + A File representing the generated Info.plist for the dSYM bundle. """ plisttool_input_files = [dsym_info_plist_template] @@ -273,7 +312,6 @@ def _generate_dsym_info_plist( actions = actions, control_file = control_file, inputs = plisttool_input_files, - mac_exec_group = mac_exec_group, mnemonic = "CompileDSYMInfoPlist", outputs = [dsym_plist], platform_prerequisites = platform_prerequisites, @@ -286,9 +324,8 @@ def _bundle_dsym_files( actions, bundle_extension = "", debug_output_filename, - dsym_binaries = {}, + dsym_inputs = {}, dsym_info_plist_template, - mac_exec_group, label_name, output_discriminator, platform_prerequisites, @@ -305,27 +342,33 @@ def _bundle_dsym_files( an empty list. Args: - actions: The actions provider from `ctx.actions`. - bundle_extension: The extension for the bundle. - debug_output_filename: The base file name to use for this debug output, which will be followed - by each architecture with an underscore to make each dSYM binary file name or with the - bundle extension following it for the dSYM bundle file name. - dsym_binaries: A mapping of architectures to Files representing dSYM binary outputs for each - architecture. - dsym_info_plist_template: File referencing a plist template for dSYM bundles. - mac_exec_group: The exec_group associated with plisttool. - label_name: The name of the target. - output_discriminator: A string to differentiate between different target intermediate files - or `None`. - platform_prerequisites: Struct containing information on the platform being targeted. - plisttool: A files_to_run for the plist tool. - rule_label: The label of the target being analyzed. - version: A label referencing AppleBundleVersionInfo, if provided by the rule. + actions: The actions provider from `ctx.actions`. + bundle_extension: The extension for the bundle. + debug_output_filename: The base file name to use for this debug output, which will be + followed by each architecture with an underscore to make each dSYM binary file name or + with the bundle extension following it for the dSYM bundle file name. + dsym_inputs: A mapping of architectures to Files representing dSYM outputs for each + architecture. + dsym_info_plist_template: File referencing a plist template for dSYM bundles. + label_name: The name of the target. + output_discriminator: A string to differentiate between different target intermediate files + or `None`. + platform_prerequisites: Struct containing information on the platform being targeted. + plisttool: A files_to_run for the plist tool. + rule_label: The label of the target being analyzed. + version: A label referencing AppleBundleVersionInfo, if provided by the rule. Returns: - A tuple where the first argument is a list of files that comprise the .dSYM bundle, which - should be returned as additional outputs from the target, and the second argument is a tree - artifact representation of a .dSYM bundle with the binaries lipoed together as one binary. + A two parameter tuple of the following form: + + 1. If `dsym_variant_flag` is "flat", a List of Files that comprise the .dSYM bundle, + which should be returned as additional outputs from the target. If `dsym_variant_flag` + is "bundle" this will be an empty List. + 2. A File representing the tree artifact representation of the .dSYM bundle with the + dSYM binaries lipoed together as one binary, if any dsym_inputs were provided. If + `dsym_variant_flag` is "bundle" and only one dSYM bundle in the dictionary of + dsym_inputs was provided, the tree artifact returned will be an unmodified reference to + that dSYM bundle. """ dsym_bundle_name_with_extension = debug_output_filename + bundle_extension if debug_output_filename != label_name.split(".__internal__.")[0]: @@ -336,21 +379,66 @@ def _bundle_dsym_files( output_files = [] dsym_bundle_dir = None - found_binaries_by_arch = {} + if not dsym_inputs: + return [], None + + # The dSYM binary file names are expected to match the unstripped binaries that they were based + # on from the original crosstool dsymutil invocation; this is more imperative to get right when + # referencing dSYM binaries from a dSYM bundle. + main_binary_basename = outputs.main_binary_basename( + cpp_fragment = platform_prerequisites.cpp_fragment, + label_name = rule_label.name, + unstripped = True, + ) + + command_inputs = dsym_inputs.values() + + dsym_variants = platform_prerequisites.build_settings.dsym_variant_flag + + if dsym_variants == "bundle": + if len(dsym_inputs) == 1: + # If we only have one dSYM binary, we can just use it as-is, no need to merge + lipo its + # contents. + return [], dsym_inputs.values()[0] + + # 1. Lipo the binaries (Resources/DWARF/{main_binary_basename}). + lipo_command = _lipo_command_for_dsyms( + bundle_inputs = True, + found_dsyms_by_arch = dsym_inputs, + main_binary_basename = main_binary_basename, + ) + + # 2. Merge the files within (Resources/Relocations, Info.plist). + ditto_command = _ditto_command_for_dsyms(found_binaries_by_arch = dsym_inputs) + + # We expect any given Info.plist from the splits to be as good as any, no need to merge + # them, but we can do that with plisttool if and when it's needed. + plist_command = ( + "cp {dsym_plist_path} ${{OUTPUT_DIR}}/Contents/Info.plist" + ).format( + dsym_plist_path = dsym_inputs.values()[0].path + "/Contents/Info.plist", + ) + + command = ( + "rm -rf ${OUTPUT_DIR} && " + + lipo_command + " && " + + ditto_command + " && " + + plist_command + ) - if dsym_binaries: - found_binaries_by_arch.update(dsym_binaries) + dsym_bundle_dir = actions.declare_directory(dsym_bundle_name) - if found_binaries_by_arch: + elif dsym_variants == "flat": output_files = _copy_dsyms_into_declared_bundle( actions = actions, debug_output_filename = debug_output_filename, dsym_bundle_name = dsym_bundle_name, - found_binaries_by_arch = found_binaries_by_arch, + found_binaries_by_arch = dsym_inputs, ) lipo_command = _lipo_command_for_dsyms( - debug_output_filename = debug_output_filename, - found_binaries_by_arch = found_binaries_by_arch, + bundle_inputs = False, + found_dsyms_by_arch = dsym_inputs, + main_binary_basename = main_binary_basename, ) # If we found any binaries, create the Info.plist for the bundle as well. @@ -359,34 +447,39 @@ def _bundle_dsym_files( dsym_bundle_name = dsym_bundle_name, dsym_info_plist_template = dsym_info_plist_template, output_discriminator = output_discriminator, - mac_exec_group = mac_exec_group, platform_prerequisites = platform_prerequisites, plisttool = plisttool, rule_label = rule_label, version = version, ) + command_inputs.append(dsym_plist) output_files.append(dsym_plist) plist_command = ("cp \"{dsym_plist_path}\" \"${{OUTPUT_DIR}}/Contents/Info.plist\"").format( dsym_plist_path = dsym_plist.path, ) - # Put the tree artifact dSYMs in a subdirectory to avoid conflicts with the legacy dSYMs - # provided through existing APIs such as --output_groups=+dsyms. + command = "rm -rf ${OUTPUT_DIR} && " + lipo_command + " && " + plist_command + + # Put the tree artifact dSYMs in a subdirectory to avoid conflicts with any legacy dSYMs + # provided through existing APIs such as --output_groups=+dsyms; note that legacy "flat + # file" dSYMs won't be present if the dsym_variants are set to "bundle" and the bundles will + # be sent through the output group instead, so the workaround is not needed in that case. dsym_bundle_dir = actions.declare_directory("dSYMs/" + dsym_bundle_name) + else: + fail("Internal Error: Unsupported dsym_variant_flag: {}".format(dsym_variants)) - apple_support.run_shell( - actions = actions, - apple_fragment = platform_prerequisites.apple_fragment, - inputs = [dsym_plist] + found_binaries_by_arch.values(), - outputs = [dsym_bundle_dir], - command = ("mkdir -p \"${OUTPUT_DIR}/Contents/Resources/DWARF\" && " + lipo_command + - " && " + plist_command), - env = { - "OUTPUT_DIR": dsym_bundle_dir.path, - }, - mnemonic = "DSYMBundleCopy", - xcode_config = platform_prerequisites.xcode_version_config, - ) + apple_support.run_shell( + actions = actions, + apple_fragment = platform_prerequisites.apple_fragment, + inputs = command_inputs, + outputs = [dsym_bundle_dir], + command = command, + env = { + "OUTPUT_DIR": dsym_bundle_dir.path, + }, + mnemonic = "DSYMBundleCopy", + xcode_config = platform_prerequisites.xcode_version_config, + ) return output_files, dsym_bundle_dir @@ -397,11 +490,10 @@ def _debug_symbols_partial_impl( bundle_name, debug_dependencies = [], debug_discriminator = None, - dsym_binaries = {}, + dsym_outputs = {}, dsym_info_plist_template, label_name, linkmaps = {}, - mac_exec_group, output_discriminator = None, platform_prerequisites, plisttool, @@ -446,9 +538,8 @@ def _debug_symbols_partial_impl( actions = actions, bundle_extension = bundle_extension, debug_output_filename = debug_output_filename, - dsym_binaries = dsym_binaries, + dsym_inputs = dsym_outputs, dsym_info_plist_template = dsym_info_plist_template, - mac_exec_group = mac_exec_group, label_name = label_name, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, @@ -456,9 +547,10 @@ def _debug_symbols_partial_impl( rule_label = rule_label, version = version, ) + if dsym_files: + direct_dsyms.extend(dsym_files) if dsym_bundle_dir: direct_dsym_bundles.append(dsym_bundle_dir) - direct_dsyms.extend(dsym_files) if platform_prerequisites.cpp_fragment.objc_generate_linkmap: linkmaps = _collect_linkmaps( @@ -475,17 +567,10 @@ def _debug_symbols_partial_impl( default = False, ) - # Output the tree artifact dSYMs as the default outputs if requested. - tree_artifact_dsym_files = defines.bool_value( - config_vars = platform_prerequisites.config_vars, - define_name = "apple.tree_artifact_dsym_files", - default = False, - ) - dsyms_group = depset(direct_dsyms, transitive = transitive_dsyms) linkmaps_group = depset(direct_linkmaps, transitive = transitive_linkmaps) - if tree_artifact_dsym_files: + if platform_prerequisites.build_settings.dsym_variant_flag == "bundle": all_output_dsyms = depset(direct_dsym_bundles, transitive = transitive_dsym_bundles) direct_output_dsyms = direct_dsym_bundles else: @@ -524,11 +609,10 @@ def debug_symbols_partial( bundle_name, debug_dependencies = [], debug_discriminator = None, - dsym_binaries = {}, + dsym_outputs = {}, dsym_info_plist_template, label_name, linkmaps = {}, - mac_exec_group, output_discriminator = None, platform_prerequisites, plisttool, @@ -545,27 +629,27 @@ def debug_symbols_partial( section of a successful build. Args: - actions: The actions provider from `ctx.actions`. - bundle_extension: The extension for the bundle. - bundle_name: The name of the output bundle. - debug_dependencies: List of targets from which to collect the transitive dependency debug - information to propagate them upstream. - debug_discriminator: A suffix to distinguish between different debug output files, or `None`. - dsym_binaries: A mapping of architectures to Files representing dsym binary outputs for each - architecture. - dsym_info_plist_template: File referencing a plist template for dSYM bundles. - label_name: The name of the target. - linkmaps: A mapping of architectures to Files representing linkmaps for each architecture. - mac_exec_group: The exec_group associated with plisttool. - output_discriminator: A string to differentiate between different target intermediate files - or `None`. - platform_prerequisites: Struct containing information on the platform being targeted. - plisttool: A files_to_run for the plist tool. - rule_label: The label of the target being analyzed. - version: A label referencing AppleBundleVersionInfo, if provided by the rule. + actions: The actions provider from `ctx.actions`. + bundle_extension: The extension for the bundle. + bundle_name: The name of the output bundle. + debug_dependencies: List of targets from which to collect the transitive dependency debug + information to propagate them upstream. + debug_discriminator: A suffix to distinguish between different debug output files, or + `None`. + dsym_outputs: A mapping of architectures to Files representing dsym outputs for each + architecture. + dsym_info_plist_template: File referencing a plist template for dSYM bundles. + label_name: The name of the target. + linkmaps: A mapping of architectures to Files representing linkmaps for each architecture. + output_discriminator: A string to differentiate between different target intermediate files + or `None`. + platform_prerequisites: Struct containing information on the platform being targeted. + plisttool: A files_to_run for the plist tool. + rule_label: The label of the target being analyzed. + version: A label referencing AppleBundleVersionInfo, if provided by the rule. Returns: - A partial that returns the debug output files, if any were requested. + A partial that returns the debug output files, if any were requested. """ return partial.make( _debug_symbols_partial_impl, @@ -574,11 +658,10 @@ def debug_symbols_partial( bundle_name = bundle_name, debug_dependencies = debug_dependencies, debug_discriminator = debug_discriminator, - dsym_binaries = dsym_binaries, + dsym_outputs = dsym_outputs, dsym_info_plist_template = dsym_info_plist_template, label_name = label_name, linkmaps = linkmaps, - mac_exec_group = mac_exec_group, output_discriminator = output_discriminator, platform_prerequisites = platform_prerequisites, plisttool = plisttool, diff --git a/apple/internal/resource_actions/plist.bzl b/apple/internal/resource_actions/plist.bzl index 383283b11d..35ea4fe4f0 100644 --- a/apple/internal/resource_actions/plist.bzl +++ b/apple/internal/resource_actions/plist.bzl @@ -44,7 +44,6 @@ def plisttool_action( actions, control_file, inputs, - mac_exec_group = None, mnemonic = None, outputs, platform_prerequisites, @@ -59,7 +58,6 @@ def plisttool_action( actions: The actions provider from `ctx.actions`. control_file: The `File` containing the control struct to be passed to plisttool. inputs: Any `File`s that should be treated as inputs to the underlying action. - mac_exec_group: The exec_group associated with plisttool. mnemonic: The mnemonic to display when the action executes. Defaults to None. outputs: Any `File`s that should be treated as outputs of the underlying action. platform_prerequisites: Struct containing information on the platform being targeted. @@ -71,7 +69,6 @@ def plisttool_action( arguments = [control_file.path], executable = plisttool, inputs = inputs + [control_file], - exec_group = mac_exec_group, mnemonic = mnemonic, outputs = outputs, xcode_config = platform_prerequisites.xcode_version_config, diff --git a/apple/internal/testing/apple_test_bundle_support.bzl b/apple/internal/testing/apple_test_bundle_support.bzl index b2b6b62ed0..efe1a9868d 100644 --- a/apple/internal/testing/apple_test_bundle_support.bzl +++ b/apple/internal/testing/apple_test_bundle_support.bzl @@ -481,7 +481,7 @@ def _apple_test_bundle_impl(*, ctx, product_type): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = debug_dependencies, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, executable_name = executable_name, label_name = label.name, diff --git a/apple/internal/tvos_rules.bzl b/apple/internal/tvos_rules.bzl index b9f86f6c31..ff66655edc 100644 --- a/apple/internal/tvos_rules.bzl +++ b/apple/internal/tvos_rules.bzl @@ -307,9 +307,8 @@ def _tvos_application_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = embeddable_targets + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -373,7 +372,7 @@ def _tvos_application_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -645,9 +644,8 @@ def _tvos_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -927,9 +925,8 @@ def _tvos_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -991,7 +988,7 @@ def _tvos_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1214,9 +1211,8 @@ def _tvos_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1266,7 +1262,7 @@ def _tvos_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, diff --git a/apple/internal/visionos_rules.bzl b/apple/internal/visionos_rules.bzl index 6768e96c91..a1295e3a5c 100644 --- a/apple/internal/visionos_rules.bzl +++ b/apple/internal/visionos_rules.bzl @@ -314,9 +314,8 @@ Resolved Xcode is version {xcode_version}. bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = embeddable_targets + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -374,7 +373,7 @@ Resolved Xcode is version {xcode_version}. actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -614,6 +613,7 @@ def _visionos_dynamic_framework_impl(ctx): partials.codesigning_dossier_partial( actions = actions, apple_mac_toolchain_info = apple_mac_toolchain_info, + apple_xplat_toolchain_info = apple_xplat_toolchain_info, bundle_extension = bundle_extension, bundle_location = processor.location.framework, bundle_name = bundle_name, @@ -621,6 +621,7 @@ def _visionos_dynamic_framework_impl(ctx): embedded_targets = ctx.attr.frameworks, label_name = label.name, platform_prerequisites = platform_prerequisites, + predeclared_outputs = predeclared_outputs, provisioning_profile = provisioning_profile, rule_descriptor = rule_descriptor, ), @@ -647,9 +648,8 @@ def _visionos_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -932,9 +932,8 @@ def _visionos_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -996,7 +995,7 @@ def _visionos_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1210,9 +1209,8 @@ def _visionos_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1262,7 +1260,7 @@ def _visionos_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, diff --git a/apple/internal/watchos_rules.bzl b/apple/internal/watchos_rules.bzl index 7401f4e1b5..c01a2a1366 100644 --- a/apple/internal/watchos_rules.bzl +++ b/apple/internal/watchos_rules.bzl @@ -299,9 +299,8 @@ def _watchos_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -363,7 +362,7 @@ def _watchos_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -579,9 +578,8 @@ def _watchos_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -914,7 +912,6 @@ reproducible error case.".format( bundle_name = bundle_name, debug_dependencies = [watch_extension], dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, platform_prerequisites = platform_prerequisites, plisttool = apple_mac_toolchain_info.plisttool, @@ -964,7 +961,7 @@ reproducible error case.".format( actions = actions, binary_artifact = binary_artifact, dependency_targets = [watch_extension], - dsym_binaries = {}, + dsym_outputs = {}, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1209,9 +1206,8 @@ def _watchos_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = embeddable_targets, - dsym_binaries = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1275,7 +1271,7 @@ def _watchos_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_binaries, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1677,9 +1673,8 @@ delegate is referenced in the single-target `watchos_application`'s `deps`. bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = embeddable_targets, - dsym_binaries = debug_outputs.dsym_binaries, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, linkmaps = debug_outputs.linkmaps, platform_prerequisites = platform_prerequisites, @@ -1741,7 +1736,7 @@ delegate is referenced in the single-target `watchos_application`'s `deps`. actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, diff --git a/apple/internal/xcframework_rules.bzl b/apple/internal/xcframework_rules.bzl index f0ae06e24c..76fd965d98 100644 --- a/apple/internal/xcframework_rules.bzl +++ b/apple/internal/xcframework_rules.bzl @@ -197,7 +197,7 @@ def _group_link_outputs_by_library_identifier( A list of structs with the following fields; `architectures` containing a list of the architectures that the binary was built with, `binary` referencing the output binary linked with the `lipo` tool if necessary, or referencing a symlink to the original binary if not, - `dsym_binaries` which is a mapping of architectures to dsym binaries if any were created, + `dsym_outputs` which is a mapping of architectures to dsym outputs if any were created, `environment` to reference the target environment the binary was built for, `linkmaps` which is a mapping of architectures to linkmaps if any were created, and `platform` to reference the target platform the binary was built for. @@ -228,7 +228,7 @@ def _group_link_outputs_by_library_identifier( # Iterate through the structure again, this time creating a structure equivalent to link_result # .outputs but with .architecture replaced with .architectures, .dsym_binary replaced with - # .dsym_binaries, and .linkmap replaced with .linkmaps + # .dsym_outputs, and .linkmap replaced with .linkmaps for framework_key, link_outputs in link_outputs_by_framework.items(): inputs = [getattr(output, linking_type) for output in link_outputs] filename = "{}_{}".format(label_name, framework_key) @@ -245,7 +245,7 @@ def _group_link_outputs_by_library_identifier( ) architectures = [] - dsym_binaries = {} + dsym_outputs = {} linkmaps = {} split_attr_keys = [] framework_swift_infos = {} @@ -273,9 +273,9 @@ def _group_link_outputs_by_library_identifier( if _has_non_system_swift_modules(target = dep): framework_swift_infos[link_output.architecture] = dep[SwiftInfo] - # static library linking does not support dsym, and linkmaps yet. + # dSYMs and linkmaps are exclusive to linked binaries, not static library archives. if linking_type == "binary": - dsym_binaries[link_output.architecture] = link_output.dsym_binary + dsym_outputs[link_output.architecture] = link_output.dsym_output linkmaps[link_output.architecture] = link_output.linkmap environment = link_outputs[0].environment @@ -290,7 +290,7 @@ def _group_link_outputs_by_library_identifier( link_outputs_by_library_identifier[library_identifier] = struct( architectures = architectures, binary = fat_binary, - dsym_binaries = dsym_binaries, + dsym_outputs = dsym_outputs, environment = environment, linkmaps = linkmaps, platform = platform, @@ -737,9 +737,8 @@ def _apple_xcframework_impl(ctx): bundle_extension = nested_bundle_extension, bundle_name = bundle_name, debug_discriminator = link_output.platform + "_" + link_output.environment, - dsym_binaries = link_output.dsym_binaries, + dsym_outputs = link_output.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, - executable_name = executable_name, label_name = label.name, linkmaps = link_output.linkmaps, output_discriminator = library_identifier, diff --git a/test/starlark_tests/ios_application_tests.bzl b/test/starlark_tests/ios_application_tests.bzl index 4cd03273b6..b8ef75fefd 100644 --- a/test/starlark_tests/ios_application_tests.bzl +++ b/test/starlark_tests/ios_application_tests.bzl @@ -24,6 +24,7 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( @@ -42,6 +43,7 @@ load( ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -574,6 +576,17 @@ def ios_application_test_suite(name): ], tags = [name], ) + + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:app", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + ], + tags = [name], + ) + apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:app", @@ -586,6 +599,18 @@ def ios_application_test_suite(name): tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:app", + expected_direct_dsyms = [ + "app.app.dSYM", + ], + expected_transitive_dsyms = [ + "app.app.dSYM", + ], + tags = [name], + ) + analysis_output_group_info_files_test( name = "{}_dsyms_output_group_transitive_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_ext_and_fmwk_provisioned", @@ -600,8 +625,21 @@ def ios_application_test_suite(name): ], tags = [name], ) + + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_dsymutil_bundle_transitive_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_ext_and_fmwk_provisioned", + output_group_name = "dsyms", + expected_outputs = [ + "app_with_ext_and_fmwk_provisioned.app.dSYM", + "ext_with_fmwk_provisioned.appex.dSYM", + "fmwk_with_provisioning.framework.dSYM", + ], + tags = [name], + ) + apple_dsym_bundle_info_test( - name = "{}_transitive_dsyms_test".format(name), + name = "{}_dsymutil_bundle_transitive_dsyms_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_ext_and_fmwk_provisioned", expected_direct_dsyms = [ "dSYMs/app_with_ext_and_fmwk_provisioned.app.dSYM", @@ -614,6 +652,20 @@ def ios_application_test_suite(name): tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_transitive_dsyms_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_ext_and_fmwk_provisioned", + expected_direct_dsyms = [ + "app_with_ext_and_fmwk_provisioned.app.dSYM", + ], + expected_transitive_dsyms = [ + "fmwk_with_provisioning.framework.dSYM", + "ext_with_fmwk_provisioned.appex.dSYM", + "app_with_ext_and_fmwk_provisioned.app.dSYM", + ], + tags = [name], + ) + apple_dsym_bundle_info_test( name = "{}_custom_executable_name_dsyms_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_custom_executable_name", @@ -1012,6 +1064,22 @@ def ios_application_test_suite(name): ], tags = [name], ) + + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_with_runtime_framework_transitive_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data", + output_group_name = "dsyms", + expected_outputs = [ + "app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data.app.dSYM", + # Frameworks + "fmwk.framework.dSYM", + "fmwk_min_os_baseline_with_bundle.framework.dSYM", + "fmwk_no_version.framework.dSYM", + "fmwk_with_resources.framework.dSYM", + ], + tags = [name], + ) + analysis_output_group_info_files_test( name = "{}_with_runtime_framework_transitive_linkmaps_output_group_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data", @@ -1048,6 +1116,22 @@ def ios_application_test_suite(name): tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_with_runtime_framework_dsym_bundle_info_files_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data", + expected_direct_dsyms = [ + "app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data.app.dSYM", + ], + expected_transitive_dsyms = [ + "app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data.app.dSYM", + "fmwk.framework.dSYM", + "fmwk_min_os_baseline_with_bundle.framework.dSYM", + "fmwk_no_version.framework.dSYM", + "fmwk_with_resources.framework.dSYM", + ], + tags = [name], + ) + analysis_failure_message_test( name = "{}_no_bundle_id_fail_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:app_with_no_bundle_id", diff --git a/test/starlark_tests/rules/analysis_output_group_info_files_test.bzl b/test/starlark_tests/rules/analysis_output_group_info_files_test.bzl index 78f8945f37..3f36eb2268 100644 --- a/test/starlark_tests/rules/analysis_output_group_info_files_test.bzl +++ b/test/starlark_tests/rules/analysis_output_group_info_files_test.bzl @@ -14,6 +14,10 @@ """Starlark test rule for OutputGroupInfo output group files.""" +load( + "//apple/build_settings:build_settings.bzl", + "build_settings_labels", +) load( "//test/starlark_tests/rules:analysis_provider_test.bzl", "make_provider_test_rule", @@ -61,6 +65,7 @@ def make_analysis_output_group_info_files_test(config_settings = {}): ), }, config_settings = { + build_settings_labels.dsym_variant_flag: "flat", "//command_line_option:objc_generate_linkmap": "true", # output_group: linkmaps "//command_line_option:apple_generate_dsym": "true", # output_group: dsyms "//command_line_option:macos_cpus": "arm64,x86_64", @@ -72,3 +77,29 @@ def make_analysis_output_group_info_files_test(config_settings = {}): ) analysis_output_group_info_files_test = make_analysis_output_group_info_files_test() + +analysis_output_group_info_dsymutil_bundle_files_test = make_provider_test_rule( + provider = OutputGroupInfo, + provider_fn = _get_output_group_files, + assertion_fn = _analysis_output_group_info_files_test_assertion, + attrs = { + "output_group_name": attr.string( + mandatory = True, + doc = "Name of the output group to source files from.", + ), + "expected_outputs": attr.string_list( + mandatory = True, + doc = "List of relative output file paths expected as outputs of the output group.", + ), + }, + config_settings = { + build_settings_labels.dsym_variant_flag: "bundle", + "//command_line_option:objc_generate_linkmap": "true", # output_group: linkmaps + "//command_line_option:apple_generate_dsym": "true", # output_group: dsyms + "//command_line_option:macos_cpus": "arm64,x86_64", + "//command_line_option:ios_multi_cpus": "sim_arm64,x86_64", + "//command_line_option:tvos_cpus": "sim_arm64,x86_64", + "//command_line_option:visionos_cpus": "sim_arm64", + "//command_line_option:watchos_cpus": "arm64,x86_64", + }, +) diff --git a/test/starlark_tests/rules/apple_dsym_bundle_info_test.bzl b/test/starlark_tests/rules/apple_dsym_bundle_info_test.bzl index ef00baa7bf..6f15a489a6 100644 --- a/test/starlark_tests/rules/apple_dsym_bundle_info_test.bzl +++ b/test/starlark_tests/rules/apple_dsym_bundle_info_test.bzl @@ -18,6 +18,10 @@ load( "//apple:providers.bzl", "AppleDsymBundleInfo", ) +load( + "//apple/build_settings:build_settings.bzl", + "build_settings_labels", +) load( "//test/starlark_tests/rules:analysis_provider_test.bzl", "make_provider_test_rule", @@ -45,26 +49,44 @@ def _assert_contains_expected_direct_and_transitive_dsyms( actual_files = apple_dsym_bundle_info.transitive_dsyms.to_list(), ) -apple_dsym_bundle_info_test = make_provider_test_rule( - provider = AppleDsymBundleInfo, - assertion_fn = _assert_contains_expected_direct_and_transitive_dsyms, - attrs = { - "expected_direct_dsyms": attr.string_list( - mandatory = True, - doc = """ +_SHARED_ATTRS = { + "expected_direct_dsyms": attr.string_list( + mandatory = True, + doc = """ List of bundle names in the format . to verify that dSYM bundles are created for them as direct dependencies of the given providers. """, - ), - "expected_transitive_dsyms": attr.string_list( - mandatory = True, - doc = """ + ), + "expected_transitive_dsyms": attr.string_list( + mandatory = True, + doc = """ List of bundle names in the format . to verify that dSYM bundles are created for them as transitive dependencies of the given providers. """, - ), + ), +} + +apple_dsym_bundle_info_test = make_provider_test_rule( + provider = AppleDsymBundleInfo, + assertion_fn = _assert_contains_expected_direct_and_transitive_dsyms, + attrs = _SHARED_ATTRS, + config_settings = { + build_settings_labels.dsym_variant_flag: "flat", + "//command_line_option:apple_generate_dsym": "true", + "//command_line_option:macos_cpus": "arm64,x86_64", + "//command_line_option:ios_multi_cpus": "sim_arm64,x86_64", + "//command_line_option:tvos_cpus": "sim_arm64,x86_64", + "//command_line_option:visionos_cpus": "sim_arm64", + "//command_line_option:watchos_cpus": "arm64,x86_64", }, +) + +apple_dsym_bundle_info_dsymutil_bundle_test = make_provider_test_rule( + provider = AppleDsymBundleInfo, + assertion_fn = _assert_contains_expected_direct_and_transitive_dsyms, + attrs = _SHARED_ATTRS, config_settings = { + build_settings_labels.dsym_variant_flag: "bundle", "//command_line_option:apple_generate_dsym": "true", "//command_line_option:macos_cpus": "arm64,x86_64", "//command_line_option:ios_multi_cpus": "sim_arm64,x86_64", From a9089dcf323d1e64e7ed4e1b67147e1ef0acc53a Mon Sep 17 00:00:00 2001 From: Nicholas Levin Date: Tue, 29 Apr 2025 05:07:37 -0700 Subject: [PATCH 06/13] Update outputs.dsyms(...) to be able to handle the new dsymutil bundle outputs. Add tests for macos_application and macos_command_line_application. Use build_setting_labels flags to reference dsym_variant_flag in test rules when possible. Cherry-pick: b27541a936ecac369a4453bff4fd5dde185b08d9 --- apple/internal/ios_rules.bzl | 5 ++- apple/internal/macos_rules.bzl | 10 ++++-- apple/internal/outputs.bzl | 25 +++++++++++---- .../testing/apple_test_bundle_support.bzl | 5 ++- apple/internal/visionos_rules.bzl | 5 ++- apple/internal/xcframework_rules.bzl | 14 +++++--- .../macos_application_tests.bzl | 32 +++++++++++++++++++ .../macos_command_line_application_tests.bzl | 28 ++++++++++++++++ .../rules/analysis_runfiles_test.bzl | 14 +++++++- 9 files changed, 121 insertions(+), 17 deletions(-) diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index 35d6cd22c0..e070569c4a 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -514,7 +514,10 @@ def _ios_application_impl(ctx): rule_descriptor = rule_descriptor, ) - dsyms = outputs.dsyms(processor_result = processor_result) + dsyms = outputs.dsyms( + platform_prerequisites = platform_prerequisites, + processor_result = processor_result, + ) return [ # TODO(b/121155041): Should we do the same for ios_framework and ios_extension? diff --git a/apple/internal/macos_rules.bzl b/apple/internal/macos_rules.bzl index 37acb831b7..027a893195 100644 --- a/apple/internal/macos_rules.bzl +++ b/apple/internal/macos_rules.bzl @@ -433,7 +433,10 @@ def _macos_application_impl(ctx): predeclared_outputs = predeclared_outputs, rule_descriptor = rule_descriptor, ) - dsyms = outputs.dsyms(processor_result = processor_result) + dsyms = outputs.dsyms( + platform_prerequisites = platform_prerequisites, + processor_result = processor_result, + ) run_support.register_macos_executable( actions = actions, @@ -2089,7 +2092,10 @@ def _macos_command_line_application_impl(ctx): if clang_rt_dylibs.should_package_clang_runtime(features = features): runfiles = clang_rt_dylibs.get_from_toolchain(ctx) - dsyms = outputs.dsyms(processor_result = processor_result) + dsyms = outputs.dsyms( + platform_prerequisites = platform_prerequisites, + processor_result = processor_result, + ) return [ new_applebinaryinfo( diff --git a/apple/internal/outputs.bzl b/apple/internal/outputs.bzl index a57dd73480..b83ec31cef 100644 --- a/apple/internal/outputs.bzl +++ b/apple/internal/outputs.bzl @@ -114,13 +114,26 @@ def _executable(*, actions, label_name): """Returns a file reference for the executable that would be invoked with `bazel run`.""" return actions.declare_file(label_name) -def _dsyms(*, processor_result): +def _dsyms(*, platform_prerequisites, processor_result): """Returns a depset of all of the dsyms from the result.""" - dsyms = [] - for provider in processor_result.providers: - if getattr(provider, "dsyms", None): - dsyms.append(provider.dsyms) - return depset(transitive = dsyms) + direct_dsyms = [] + transitive_dsyms = [] + dsym_variant_flag = platform_prerequisites.build_settings.dsym_variant_flag + if dsym_variant_flag == "bundle": + for provider in processor_result.providers: + # Sourcing fields from the public AppleDsymBundleInfo provider. + if getattr(provider, "direct_dsyms", None): + direct_dsyms.extend(provider.direct_dsyms) + if getattr(provider, "transitive_dsyms", None): + transitive_dsyms.append(provider.transitive_dsyms) + elif dsym_variant_flag == "flat": + for provider in processor_result.providers: + # Sourcing fields from the AppleDebugInfo provider, only visible to the rules. + if getattr(provider, "dsyms", None): + transitive_dsyms.append(provider.dsyms) + else: + fail("Internal Error: Unsupported dsym_variant_flag: {}".format(dsym_variant_flag)) + return depset(direct_dsyms, transitive = transitive_dsyms) def _infoplist(*, actions, label_name, output_discriminator): """Returns a file reference for this target's Info.plist file.""" diff --git a/apple/internal/testing/apple_test_bundle_support.bzl b/apple/internal/testing/apple_test_bundle_support.bzl index efe1a9868d..4014542b3b 100644 --- a/apple/internal/testing/apple_test_bundle_support.bzl +++ b/apple/internal/testing/apple_test_bundle_support.bzl @@ -572,7 +572,10 @@ def _apple_test_bundle_impl(*, ctx, product_type): rule_descriptor = rule_descriptor, ) - dsyms = outputs.dsyms(processor_result = processor_result) + dsyms = outputs.dsyms( + platform_prerequisites = platform_prerequisites, + processor_result = processor_result, + ) # The processor outputs has all the extra outputs like dSYM files that we want to propagate, but # it also includes the archive artifact. This collects all the files that should be output from diff --git a/apple/internal/visionos_rules.bzl b/apple/internal/visionos_rules.bzl index a1295e3a5c..84bb1d3344 100644 --- a/apple/internal/visionos_rules.bzl +++ b/apple/internal/visionos_rules.bzl @@ -450,7 +450,10 @@ Resolved Xcode is version {xcode_version}. rule_descriptor = rule_descriptor, ) - dsyms = outputs.dsyms(processor_result = processor_result) + dsyms = outputs.dsyms( + platform_prerequisites = platform_prerequisites, + processor_result = processor_result, + ) return [ DefaultInfo( diff --git a/apple/internal/xcframework_rules.bzl b/apple/internal/xcframework_rules.bzl index 76fd965d98..d13eb5e6ad 100644 --- a/apple/internal/xcframework_rules.bzl +++ b/apple/internal/xcframework_rules.bzl @@ -842,16 +842,20 @@ def _apple_xcframework_impl(ctx): # Save a reference to those archives as file-friendly inputs to the bundler action. framework_archive_files.append(depset([provider.archive])) - # Save the dSYMs. - if getattr(provider, "dsyms", None): - framework_output_files.append(depset(transitive = [provider.dsyms])) - framework_output_groups.append({"dsyms": provider.dsyms}) - # Save the linkmaps. if getattr(provider, "linkmaps", None): framework_output_files.append(depset(transitive = [provider.linkmaps])) framework_output_groups.append({"linkmaps": provider.linkmaps}) + dsyms = outputs.dsyms( + platform_prerequisites = platform_prerequisites, + processor_result = processor_result, + ) + if dsyms: + # Save the dSYMs. + framework_output_files.append(depset(transitive = [dsyms])) + framework_output_groups.append({"dsyms": dsyms}) + # Save additional library details for the XCFramework's root info plist. available_libraries.append(_available_library_dictionary( architectures = link_output.architectures, diff --git a/test/starlark_tests/macos_application_tests.bzl b/test/starlark_tests/macos_application_tests.bzl index 89de58c569..e90adf7af8 100644 --- a/test/starlark_tests/macos_application_tests.bzl +++ b/test/starlark_tests/macos_application_tests.bzl @@ -20,11 +20,13 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:analysis_runfiles_test.bzl", "analysis_runfiles_dsym_test", + "analysis_runfiles_dsymutil_bundle_test", ) load( "//test/starlark_tests/rules:analysis_target_actions_test.bzl", @@ -33,6 +35,7 @@ load( ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -326,6 +329,15 @@ def macos_application_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:app", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/macos:app", @@ -337,6 +349,17 @@ def macos_application_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:app", + expected_direct_dsyms = [ + "app.app.dSYM", + ], + expected_transitive_dsyms = [ + "app.app.dSYM", + ], + tags = [name], + ) analysis_runfiles_dsym_test( name = "{}_runfiles_dsym_test".format(name), @@ -348,6 +371,15 @@ def macos_application_test_suite(name): tags = [name], ) + analysis_runfiles_dsymutil_bundle_test( + name = "{}_runfiles_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:app", + expected_runfiles = [ + "third_party/bazel_rules/rules_apple/test/starlark_tests/targets_under_test/macos/darwin_arm64/app.app.dSYM", + ], + tags = [name], + ) + infoplist_contents_test( name = "{}_plist_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/macos:app", diff --git a/test/starlark_tests/macos_command_line_application_tests.bzl b/test/starlark_tests/macos_command_line_application_tests.bzl index 1f14b507e5..f871c536af 100644 --- a/test/starlark_tests/macos_command_line_application_tests.bzl +++ b/test/starlark_tests/macos_command_line_application_tests.bzl @@ -16,11 +16,13 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:analysis_runfiles_test.bzl", "analysis_runfiles_dsym_test", + "analysis_runfiles_dsymutil_bundle_test", ) load( "//test/starlark_tests/rules:analysis_target_actions_test.bzl", @@ -28,6 +30,7 @@ load( ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -216,6 +219,15 @@ def macos_command_line_application_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:cmd_app_basic", + output_group_name = "dsyms", + expected_outputs = [ + "cmd_app_basic.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/macos:cmd_app_basic", @@ -223,6 +235,13 @@ def macos_command_line_application_test_suite(name): expected_transitive_dsyms = ["dSYMs/cmd_app_basic.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:cmd_app_basic", + expected_direct_dsyms = ["cmd_app_basic.dSYM"], + expected_transitive_dsyms = ["cmd_app_basic.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_infoplist_test".format(name), @@ -257,6 +276,15 @@ def macos_command_line_application_test_suite(name): tags = [name], ) + analysis_runfiles_dsymutil_bundle_test( + name = "{}_runfiles_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:cmd_app_basic", + expected_runfiles = [ + "third_party/bazel_rules/rules_apple/test/starlark_tests/targets_under_test/macos/darwin_arm64/cmd_app_basic.dSYM", + ], + tags = [name], + ) + binary_contents_test( name = "{}_version_plist_test".format(name), build_type = "device", diff --git a/test/starlark_tests/rules/analysis_runfiles_test.bzl b/test/starlark_tests/rules/analysis_runfiles_test.bzl index 98a26a1fdf..9451e1a367 100644 --- a/test/starlark_tests/rules/analysis_runfiles_test.bzl +++ b/test/starlark_tests/rules/analysis_runfiles_test.bzl @@ -19,6 +19,10 @@ load( "analysistest", "unittest", ) +load( + "//apple/build_settings:build_settings.bzl", + "build_settings_labels", +) def _analysis_runfiles_test_impl(ctx): "Test that runfiles of the given target under test is properly set." @@ -62,7 +66,15 @@ def make_analysis_runfiles_test_rule( # A generic analysis_runfiles_test with no custom settings. analysis_runfiles_test = make_analysis_runfiles_test_rule() -# An analysis_runfiles_test that generates dsyms. +# An analysis_runfiles_test that generates "flat file" dSYMs. analysis_runfiles_dsym_test = make_analysis_runfiles_test_rule(config_settings = { + build_settings_labels.dsym_variant_flag: "flat", + "//command_line_option:apple_generate_dsym": "true", + "//command_line_option:macos_cpus": "arm64", +}) + +# An analysis_runfiles_test that generates dSYMs bundles using dsymutil. +analysis_runfiles_dsymutil_bundle_test = make_analysis_runfiles_test_rule(config_settings = { + build_settings_labels.dsym_variant_flag: "bundle", "//command_line_option:apple_generate_dsym": "true", }) From 553ee6ec5cf6e44901561ec0cde76344063aab6f Mon Sep 17 00:00:00 2001 From: Nicholas Levin Date: Tue, 29 Apr 2025 05:15:05 -0700 Subject: [PATCH 07/13] Rounding out testing support for dsymutil generated dSYMs in rules_apple starlark tests. PiperOrigin-RevId: 752690208 --- .../apple_xcframework_tests.bzl | 21 ++++++ test/starlark_tests/ios_app_clip_tests.bzl | 28 ++++++++ test/starlark_tests/ios_extension_tests.bzl | 45 ++++++++++++ test/starlark_tests/ios_framework_tests.bzl | 28 ++++++++ test/starlark_tests/ios_ui_test_tests.bzl | 19 +++++ test/starlark_tests/ios_unit_test_tests.bzl | 19 +++++ test/starlark_tests/macos_bundle_tests.bzl | 18 +++++ test/starlark_tests/macos_dylib_tests.bzl | 18 +++++ test/starlark_tests/macos_ui_test_tests.bzl | 19 +++++ test/starlark_tests/macos_unit_test_tests.bzl | 19 +++++ .../starlark_tests/tvos_application_tests.bzl | 70 +++++++++++++++++++ test/starlark_tests/tvos_extension_tests.bzl | 42 +++++++++++ test/starlark_tests/tvos_framework_tests.bzl | 26 +++++++ test/starlark_tests/tvos_ui_test_tests.bzl | 19 +++++ test/starlark_tests/tvos_unit_test_tests.bzl | 19 +++++ .../visionos_application_tests.bzl | 26 +++++++ .../watchos_single_target_ui_test_tests.bzl | 18 +++++ 17 files changed, 454 insertions(+) diff --git a/test/starlark_tests/apple_xcframework_tests.bzl b/test/starlark_tests/apple_xcframework_tests.bzl index 27b1df3913..c153a75ea1 100644 --- a/test/starlark_tests/apple_xcframework_tests.bzl +++ b/test/starlark_tests/apple_xcframework_tests.bzl @@ -24,6 +24,7 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( @@ -343,6 +344,16 @@ def apple_xcframework_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/apple:ios_dynamic_xcframework", + output_group_name = "dsyms", + expected_outputs = [ + "ios_arm64_device/ios_dynamic_xcframework.dSYM", + "ios_x86_64_simulator/ios_dynamic_xcframework.dSYM", + ], + tags = [name], + ) analysis_output_group_info_files_test( name = "{}_fat_frameworks_dsyms_output_group_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/apple:ios_dynamic_lipoed_xcframework", @@ -355,6 +366,16 @@ def apple_xcframework_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_fat_frameworks_dsyms_output_group_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/apple:ios_dynamic_lipoed_xcframework", + output_group_name = "dsyms", + expected_outputs = [ + "ios_dynamic_lipoed_xcframework_ios_device.framework.dSYM", + "ios_dynamic_lipoed_xcframework_ios_simulator.framework.dSYM", + ], + tags = [name], + ) linkmap_test( name = "{}_device_linkmap_test".format(name), diff --git a/test/starlark_tests/ios_app_clip_tests.bzl b/test/starlark_tests/ios_app_clip_tests.bzl index 5d95b9203e..e40621293e 100644 --- a/test/starlark_tests/ios_app_clip_tests.bzl +++ b/test/starlark_tests/ios_app_clip_tests.bzl @@ -16,10 +16,12 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -195,6 +197,18 @@ def ios_app_clip_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_with_runtime_framework_transitive_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:app_clip_with_fmwks_from_objc_swift_libraries_using_data", + output_group_name = "dsyms", + expected_outputs = [ + "app_clip_with_fmwks_from_objc_swift_libraries_using_data.app.dSYM", + "fmwk_min_os_baseline_with_bundle.framework.dSYM", + "fmwk_no_version.framework.dSYM", + "fmwk_with_resources.framework.dSYM", + ], + tags = [name], + ) analysis_output_group_info_files_test( name = "{}_with_runtime_framework_transitive_linkmaps_output_group_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:app_clip_with_fmwks_from_objc_swift_libraries_using_data", @@ -227,6 +241,20 @@ def ios_app_clip_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_with_runtime_framework_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:app_clip_with_fmwks_from_objc_swift_libraries_using_data", + expected_direct_dsyms = [ + "app_clip_with_fmwks_from_objc_swift_libraries_using_data.app.dSYM", + ], + expected_transitive_dsyms = [ + "app_clip_with_fmwks_from_objc_swift_libraries_using_data.app.dSYM", + "fmwk_min_os_baseline_with_bundle.framework.dSYM", + "fmwk_no_version.framework.dSYM", + "fmwk_with_resources.framework.dSYM", + ], + tags = [name], + ) # Tests inclusion of extensions. archive_contents_test( diff --git a/test/starlark_tests/ios_extension_tests.bzl b/test/starlark_tests/ios_extension_tests.bzl index 551a966d1f..5ebcb32d75 100644 --- a/test/starlark_tests/ios_extension_tests.bzl +++ b/test/starlark_tests/ios_extension_tests.bzl @@ -16,10 +16,12 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -101,6 +103,16 @@ def ios_extension_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:ext", + output_group_name = "dsyms", + expected_outputs = [ + "ext.appex.dSYM", + ], + tags = [name], + ) + apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:ext", @@ -108,6 +120,13 @@ def ios_extension_test_suite(name): expected_transitive_dsyms = ["dSYMs/ext.appex.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:ext", + expected_direct_dsyms = ["ext.appex.dSYM"], + expected_transitive_dsyms = ["ext.appex.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_plist_test".format(name), @@ -289,6 +308,18 @@ def ios_extension_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_with_runtime_framework_transitive_dsyms_output_group_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:ext_with_fmwks_from_objc_swift_libraries_using_data", + output_group_name = "dsyms", + expected_outputs = [ + "ext_with_fmwks_from_objc_swift_libraries_using_data.appex.dSYM", + "fmwk_min_os_baseline_with_bundle.framework.dSYM", + "fmwk_no_version.framework.dSYM", + "fmwk_with_resources.framework.dSYM", + ], + tags = [name], + ) analysis_output_group_info_files_test( name = "{}_with_runtime_framework_transitive_linkmaps_output_group_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:ext_with_fmwks_from_objc_swift_libraries_using_data", @@ -321,6 +352,20 @@ def ios_extension_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_with_runtime_framework_dsym_bundle_info_dsymutil_bundle_files_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:ext_with_fmwks_from_objc_swift_libraries_using_data", + expected_direct_dsyms = [ + "ext_with_fmwks_from_objc_swift_libraries_using_data.appex.dSYM", + ], + expected_transitive_dsyms = [ + "ext_with_fmwks_from_objc_swift_libraries_using_data.appex.dSYM", + "fmwk_min_os_baseline_with_bundle.framework.dSYM", + "fmwk_no_version.framework.dSYM", + "fmwk_with_resources.framework.dSYM", + ], + tags = [name], + ) infoplist_contents_test( name = "{}_capability_set_derived_bundle_id_plist_test".format(name), diff --git a/test/starlark_tests/ios_framework_tests.bzl b/test/starlark_tests/ios_framework_tests.bzl index a45011eec9..c6992247ea 100644 --- a/test/starlark_tests/ios_framework_tests.bzl +++ b/test/starlark_tests/ios_framework_tests.bzl @@ -20,10 +20,12 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -648,6 +650,18 @@ def ios_framework_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_with_runtime_framework_transitive_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:fmwk_with_fmwks_from_objc_swift_libraries_using_data", + output_group_name = "dsyms", + expected_outputs = [ + "fmwk_with_fmwks_from_objc_swift_libraries_using_data.framework.dSYM", + "fmwk_min_os_baseline_with_bundle.framework.dSYM", + "fmwk_no_version.framework.dSYM", + "fmwk_with_resources.framework.dSYM", + ], + tags = [name], + ) analysis_output_group_info_files_test( name = "{}_with_runtime_framework_transitive_linkmaps_output_group_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:fmwk_with_fmwks_from_objc_swift_libraries_using_data", @@ -680,6 +694,20 @@ def ios_framework_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_with_runtime_framework_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:fmwk_with_fmwks_from_objc_swift_libraries_using_data", + expected_direct_dsyms = [ + "fmwk_with_fmwks_from_objc_swift_libraries_using_data.framework.dSYM", + ], + expected_transitive_dsyms = [ + "fmwk_with_fmwks_from_objc_swift_libraries_using_data.framework.dSYM", + "fmwk_min_os_baseline_with_bundle.framework.dSYM", + "fmwk_no_version.framework.dSYM", + "fmwk_with_resources.framework.dSYM", + ], + tags = [name], + ) infoplist_contents_test( name = "{}_base_bundle_id_derived_bundle_id_plist_test".format(name), diff --git a/test/starlark_tests/ios_ui_test_tests.bzl b/test/starlark_tests/ios_ui_test_tests.bzl index 7dde2c7c1b..054263ad65 100644 --- a/test/starlark_tests/ios_ui_test_tests.bzl +++ b/test/starlark_tests/ios_ui_test_tests.bzl @@ -20,10 +20,12 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -93,6 +95,16 @@ def ios_ui_test_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:ui_test", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + "ui_test.xctest.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_apple_dsym_bundle_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:ui_test", @@ -100,6 +112,13 @@ def ios_ui_test_test_suite(name): expected_transitive_dsyms = ["dSYMs/app.app.dSYM", "dSYMs/ui_test.xctest.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_apple_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:ui_test", + expected_direct_dsyms = ["ui_test.xctest.dSYM"], + expected_transitive_dsyms = ["app.app.dSYM", "ui_test.xctest.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_test_bundle_id_override".format(name), diff --git a/test/starlark_tests/ios_unit_test_tests.bzl b/test/starlark_tests/ios_unit_test_tests.bzl index 77af37c9b9..1ccfaa0c49 100644 --- a/test/starlark_tests/ios_unit_test_tests.bzl +++ b/test/starlark_tests/ios_unit_test_tests.bzl @@ -24,10 +24,12 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -103,6 +105,16 @@ def ios_unit_test_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:unit_test", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + "unit_test.xctest.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_apple_dsym_bundle_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/ios:unit_test", @@ -110,6 +122,13 @@ def ios_unit_test_test_suite(name): expected_transitive_dsyms = ["dSYMs/app.app.dSYM", "dSYMs/unit_test.xctest.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_apple_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/ios:unit_test", + expected_direct_dsyms = ["unit_test.xctest.dSYM"], + expected_transitive_dsyms = ["app.app.dSYM", "unit_test.xctest.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_test_bundle_id_override".format(name), diff --git a/test/starlark_tests/macos_bundle_tests.bzl b/test/starlark_tests/macos_bundle_tests.bzl index d336f8df81..d8e8635933 100644 --- a/test/starlark_tests/macos_bundle_tests.bzl +++ b/test/starlark_tests/macos_bundle_tests.bzl @@ -16,10 +16,12 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -163,6 +165,15 @@ def macos_bundle_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:bundle", + output_group_name = "dsyms", + expected_outputs = [ + "bundle.bundle.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/macos:bundle", @@ -170,6 +181,13 @@ def macos_bundle_test_suite(name): expected_transitive_dsyms = ["dSYMs/bundle.bundle.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:bundle", + expected_direct_dsyms = ["bundle.bundle.dSYM"], + expected_transitive_dsyms = ["bundle.bundle.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_capability_set_derived_bundle_id_plist_test".format(name), diff --git a/test/starlark_tests/macos_dylib_tests.bzl b/test/starlark_tests/macos_dylib_tests.bzl index e597b7b50f..2484616057 100644 --- a/test/starlark_tests/macos_dylib_tests.bzl +++ b/test/starlark_tests/macos_dylib_tests.bzl @@ -16,10 +16,12 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -97,6 +99,15 @@ def macos_dylib_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:dylib", + output_group_name = "dsyms", + expected_outputs = [ + "dylib.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/macos:dylib", @@ -104,6 +115,13 @@ def macos_dylib_test_suite(name): expected_transitive_dsyms = ["dSYMs/dylib.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:dylib", + expected_direct_dsyms = ["dylib.dSYM"], + expected_transitive_dsyms = ["dylib.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_infoplist_test".format(name), diff --git a/test/starlark_tests/macos_ui_test_tests.bzl b/test/starlark_tests/macos_ui_test_tests.bzl index 9d27d63d6e..d49f029723 100644 --- a/test/starlark_tests/macos_ui_test_tests.bzl +++ b/test/starlark_tests/macos_ui_test_tests.bzl @@ -20,10 +20,12 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -99,6 +101,16 @@ def macos_ui_test_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:ui_test", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + "ui_test.xctest.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_apple_dsym_bundle_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/macos:ui_test", @@ -106,6 +118,13 @@ def macos_ui_test_test_suite(name): expected_transitive_dsyms = ["dSYMs/app.app.dSYM", "dSYMs/ui_test.xctest.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_apple_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:ui_test", + expected_direct_dsyms = ["ui_test.xctest.dSYM"], + expected_transitive_dsyms = ["app.app.dSYM", "ui_test.xctest.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_test_bundle_id_override".format(name), diff --git a/test/starlark_tests/macos_unit_test_tests.bzl b/test/starlark_tests/macos_unit_test_tests.bzl index ae7e1510d7..fffc847f52 100644 --- a/test/starlark_tests/macos_unit_test_tests.bzl +++ b/test/starlark_tests/macos_unit_test_tests.bzl @@ -20,6 +20,7 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( @@ -28,6 +29,7 @@ load( ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -103,6 +105,16 @@ def macos_unit_test_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:unit_test", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + "unit_test.xctest.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_apple_dsym_bundle_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/macos:unit_test", @@ -110,6 +122,13 @@ def macos_unit_test_test_suite(name): expected_transitive_dsyms = ["dSYMs/app.app.dSYM", "dSYMs/unit_test.xctest.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_apple_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/macos:unit_test", + expected_direct_dsyms = ["unit_test.xctest.dSYM"], + expected_transitive_dsyms = ["app.app.dSYM", "unit_test.xctest.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_test_bundle_id_override".format(name), diff --git a/test/starlark_tests/tvos_application_tests.bzl b/test/starlark_tests/tvos_application_tests.bzl index 5444ab893e..0064b52316 100644 --- a/test/starlark_tests/tvos_application_tests.bzl +++ b/test/starlark_tests/tvos_application_tests.bzl @@ -20,6 +20,7 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( @@ -29,6 +30,7 @@ load( ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -239,6 +241,15 @@ def tvos_application_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:app", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/tvos:app", @@ -250,6 +261,17 @@ def tvos_application_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:app", + expected_direct_dsyms = [ + "app.app.dSYM", + ], + expected_transitive_dsyms = [ + "app.app.dSYM", + ], + tags = [name], + ) analysis_output_group_info_files_test( name = "{}_dsyms_output_group_transitive_files_test".format(name), @@ -263,6 +285,16 @@ def tvos_application_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_transitive_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:app_with_fmwk_with_fmwk_provisioned", + output_group_name = "dsyms", + expected_outputs = [ + "app_with_fmwk_with_fmwk_provisioned.app.dSYM", + "fmwk_with_provisioning.framework.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_transitive_dsyms_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/tvos:app_with_fmwk_with_fmwk_provisioned", @@ -275,6 +307,18 @@ def tvos_application_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_transitive_dsyms_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:app_with_fmwk_with_fmwk_provisioned", + expected_direct_dsyms = [ + "app_with_fmwk_with_fmwk_provisioned.app.dSYM", + ], + expected_transitive_dsyms = [ + "fmwk_with_provisioning.framework.dSYM", + "app_with_fmwk_with_fmwk_provisioned.app.dSYM", + ], + tags = [name], + ) infoplist_contents_test( name = "{}_plist_test".format(name), @@ -696,6 +740,18 @@ def tvos_application_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_with_runtime_framework_transitive_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data", + output_group_name = "dsyms", + expected_outputs = [ + "app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data.app.dSYM", + "fmwk.framework.dSYM", + "fmwk_with_resource_bundles.framework.dSYM", + "fmwk_with_structured_resources.framework.dSYM", + ], + tags = [name], + ) analysis_output_group_info_files_test( name = "{}_with_runtime_framework_transitive_linkmaps_output_group_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/tvos:app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data", @@ -728,6 +784,20 @@ def tvos_application_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_with_runtime_framework_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data", + expected_direct_dsyms = [ + "app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data.app.dSYM", + ], + expected_transitive_dsyms = [ + "app_with_fmwks_from_frameworks_and_objc_swift_libraries_using_data.app.dSYM", + "fmwk.framework.dSYM", + "fmwk_with_resource_bundles.framework.dSYM", + "fmwk_with_structured_resources.framework.dSYM", + ], + tags = [name], + ) infoplist_contents_test( name = "{}_capability_set_derived_bundle_id_plist_test".format(name), diff --git a/test/starlark_tests/tvos_extension_tests.bzl b/test/starlark_tests/tvos_extension_tests.bzl index b1ee679c49..2833163cb6 100644 --- a/test/starlark_tests/tvos_extension_tests.bzl +++ b/test/starlark_tests/tvos_extension_tests.bzl @@ -16,10 +16,12 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -64,6 +66,15 @@ def tvos_extension_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:ext", + output_group_name = "dsyms", + expected_outputs = [ + "ext.appex.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/tvos:ext", @@ -71,6 +82,13 @@ def tvos_extension_test_suite(name): expected_transitive_dsyms = ["dSYMs/ext.appex.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:ext", + expected_direct_dsyms = ["ext.appex.dSYM"], + expected_transitive_dsyms = ["ext.appex.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_plist_test".format(name), @@ -158,6 +176,17 @@ def tvos_extension_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_with_runtime_framework_transitive_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:ext_with_fmwks_from_objc_swift_libraries_using_data", + output_group_name = "dsyms", + expected_outputs = [ + "ext_with_fmwks_from_objc_swift_libraries_using_data.appex.dSYM", + "fmwk_with_resource_bundles.framework.dSYM", + "fmwk_with_structured_resources.framework.dSYM", + ], + tags = [name], + ) analysis_output_group_info_files_test( name = "{}_with_runtime_framework_transitive_linkmaps_output_group_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/tvos:ext_with_fmwks_from_objc_swift_libraries_using_data", @@ -187,6 +216,19 @@ def tvos_extension_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_with_runtime_framework_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:ext_with_fmwks_from_objc_swift_libraries_using_data", + expected_direct_dsyms = [ + "ext_with_fmwks_from_objc_swift_libraries_using_data.appex.dSYM", + ], + expected_transitive_dsyms = [ + "ext_with_fmwks_from_objc_swift_libraries_using_data.appex.dSYM", + "fmwk_with_resource_bundles.framework.dSYM", + "fmwk_with_structured_resources.framework.dSYM", + ], + tags = [name], + ) infoplist_contents_test( name = "{}_capability_set_derived_bundle_id_plist_test".format(name), diff --git a/test/starlark_tests/tvos_framework_tests.bzl b/test/starlark_tests/tvos_framework_tests.bzl index 3a63e09be4..fd03c16201 100644 --- a/test/starlark_tests/tvos_framework_tests.bzl +++ b/test/starlark_tests/tvos_framework_tests.bzl @@ -16,10 +16,12 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -284,6 +286,17 @@ def tvos_framework_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_with_runtime_framework_transitive_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:fmwk_with_fmwks_from_objc_swift_libraries_using_data", + output_group_name = "dsyms", + expected_outputs = [ + "fmwk_with_fmwks_from_objc_swift_libraries_using_data.framework.dSYM", + "fmwk_with_resource_bundles.framework.dSYM", + "fmwk_with_structured_resources.framework.dSYM", + ], + tags = [name], + ) analysis_output_group_info_files_test( name = "{}_with_runtime_framework_transitive_linkmaps_output_group_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/tvos:fmwk_with_fmwks_from_objc_swift_libraries_using_data", @@ -313,6 +326,19 @@ def tvos_framework_test_suite(name): ], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_with_runtime_framework_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:fmwk_with_fmwks_from_objc_swift_libraries_using_data", + expected_direct_dsyms = [ + "fmwk_with_fmwks_from_objc_swift_libraries_using_data.framework.dSYM", + ], + expected_transitive_dsyms = [ + "fmwk_with_fmwks_from_objc_swift_libraries_using_data.framework.dSYM", + "fmwk_with_resource_bundles.framework.dSYM", + "fmwk_with_structured_resources.framework.dSYM", + ], + tags = [name], + ) # Test that if a tvos_framework target depends on a prebuilt static library (i.e., # apple_static_framework_import), that the static library is defined in the tvos_framework. diff --git a/test/starlark_tests/tvos_ui_test_tests.bzl b/test/starlark_tests/tvos_ui_test_tests.bzl index 3a227f08e3..599e678b74 100644 --- a/test/starlark_tests/tvos_ui_test_tests.bzl +++ b/test/starlark_tests/tvos_ui_test_tests.bzl @@ -20,10 +20,12 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -65,6 +67,16 @@ def tvos_ui_test_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:ui_test", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + "ui_test.xctest.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_apple_dsym_bundle_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/tvos:ui_test", @@ -72,6 +84,13 @@ def tvos_ui_test_test_suite(name): expected_transitive_dsyms = ["dSYMs/app.app.dSYM", "dSYMs/ui_test.xctest.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_apple_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:ui_test", + expected_direct_dsyms = ["ui_test.xctest.dSYM"], + expected_transitive_dsyms = ["app.app.dSYM", "ui_test.xctest.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_plist_test".format(name), diff --git a/test/starlark_tests/tvos_unit_test_tests.bzl b/test/starlark_tests/tvos_unit_test_tests.bzl index 01fd11ebb9..9ff38ff6b8 100644 --- a/test/starlark_tests/tvos_unit_test_tests.bzl +++ b/test/starlark_tests/tvos_unit_test_tests.bzl @@ -20,10 +20,12 @@ load( ) load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -69,6 +71,16 @@ def tvos_unit_test_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:unit_test", + output_group_name = "dsyms", + expected_outputs = [ + "app.app.dSYM", + "unit_test.xctest.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_apple_dsym_bundle_info_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/tvos:unit_test", @@ -76,6 +88,13 @@ def tvos_unit_test_test_suite(name): expected_transitive_dsyms = ["dSYMs/app.app.dSYM", "dSYMs/unit_test.xctest.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_apple_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/tvos:unit_test", + expected_direct_dsyms = ["unit_test.xctest.dSYM"], + expected_transitive_dsyms = ["app.app.dSYM", "unit_test.xctest.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_plist_test".format(name), diff --git a/test/starlark_tests/visionos_application_tests.bzl b/test/starlark_tests/visionos_application_tests.bzl index b7c83327cd..d44c18a2b5 100644 --- a/test/starlark_tests/visionos_application_tests.bzl +++ b/test/starlark_tests/visionos_application_tests.bzl @@ -16,6 +16,7 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( @@ -33,6 +34,7 @@ load( ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -236,6 +238,17 @@ def visionos_application_test_suite(name): name, ], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/visionos:app", + output_group_name = "dsyms", + expected_outputs = [ + "visionos_sim_arm64/app.app.dSYM", + ], + tags = [ + name, + ], + ) apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), @@ -250,6 +263,19 @@ def visionos_application_test_suite(name): name, ], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/visionos:app", + expected_direct_dsyms = [ + "visionos_sim_arm64/app.app.dSYM", + ], + expected_transitive_dsyms = [ + "visionos_sim_arm64/app.app.dSYM", + ], + tags = [ + name, + ], + ) infoplist_contents_test( name = "{}_plist_test".format(name), diff --git a/test/starlark_tests/watchos_single_target_ui_test_tests.bzl b/test/starlark_tests/watchos_single_target_ui_test_tests.bzl index 909908839c..2bdd4c8eec 100644 --- a/test/starlark_tests/watchos_single_target_ui_test_tests.bzl +++ b/test/starlark_tests/watchos_single_target_ui_test_tests.bzl @@ -16,10 +16,12 @@ load( "//test/starlark_tests/rules:analysis_output_group_info_files_test.bzl", + "analysis_output_group_info_dsymutil_bundle_files_test", "analysis_output_group_info_files_test", ) load( "//test/starlark_tests/rules:apple_dsym_bundle_info_test.bzl", + "apple_dsym_bundle_info_dsymutil_bundle_test", "apple_dsym_bundle_info_test", ) load( @@ -62,6 +64,15 @@ def watchos_single_target_ui_test_test_suite(name): ], tags = [name], ) + analysis_output_group_info_dsymutil_bundle_files_test( + name = "{}_dsyms_output_group_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/watchos:single_target_ui_test", + output_group_name = "dsyms", + expected_outputs = [ + "single_target_ui_test.xctest.dSYM", + ], + tags = [name], + ) apple_dsym_bundle_info_test( name = "{}_dsym_bundle_info_files_test".format(name), target_under_test = "//test/starlark_tests/targets_under_test/watchos:single_target_ui_test", @@ -69,6 +80,13 @@ def watchos_single_target_ui_test_test_suite(name): expected_transitive_dsyms = ["dSYMs/single_target_ui_test.xctest.dSYM"], tags = [name], ) + apple_dsym_bundle_info_dsymutil_bundle_test( + name = "{}_dsym_bundle_info_dsymutil_bundle_test".format(name), + target_under_test = "//test/starlark_tests/targets_under_test/watchos:single_target_ui_test", + expected_direct_dsyms = ["single_target_ui_test.xctest.dSYM"], + expected_transitive_dsyms = ["single_target_ui_test.xctest.dSYM"], + tags = [name], + ) infoplist_contents_test( name = "{}_plist_test".format(name), From c4942add1550420c864bbeb8dc5c66f30b7b0c9c Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Thu, 2 Apr 2026 01:02:52 -0400 Subject: [PATCH 08/13] fix: use hasattr instead of bazel_features and correct toolchains path The cherry-pick of upstream commit brought in `bazel_features.cc.objc_fragment_has_builtin_objc_strip_action` which doesn't exist in the open-source build. Use `hasattr(ctx.fragments.objc, "builtin_objc_strip_action")` instead, matching the pattern used elsewhere in the codebase. Also fix `//apple/internal/toolchains:apple_toolchains` to `//apple/internal:apple_toolchains` to match the open-source package layout. --- apple/BUILD | 2 +- apple/internal/compilation_support.bzl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apple/BUILD b/apple/BUILD index ef778fd902..0b6b410617 100644 --- a/apple/BUILD +++ b/apple/BUILD @@ -73,11 +73,11 @@ bzl_library( name = "apple_binary", srcs = ["apple_binary.bzl"], deps = [ + "//apple/internal:apple_toolchains", "//apple/internal:linking_support", "//apple/internal:rule_attrs", "//apple/internal:rule_factory", "//apple/internal:transition_support", - "//apple/internal/toolchains:apple_toolchains", "@build_bazel_apple_support//lib:apple_support", ], ) diff --git a/apple/internal/compilation_support.bzl b/apple/internal/compilation_support.bzl index b02986503d..f2b1ace030 100644 --- a/apple/internal/compilation_support.bzl +++ b/apple/internal/compilation_support.bzl @@ -275,8 +275,8 @@ def _register_configuration_specific_link_actions( ctx = common_variables.ctx feature_configuration = _build_feature_configuration(common_variables) - # TODO: Remove when we drop Bazel 8 - if bazel_features.cc.objc_fragment_has_builtin_objc_strip_action: + # TODO: Remove hasattr check when we drop Bazel 8 + if hasattr(ctx.fragments.objc, "builtin_objc_strip_action"): unstripped = ctx.fragments.objc.builtin_objc_strip_action else: unstripped = False @@ -377,8 +377,8 @@ def _register_configuration_specific_link_actions_with_cpp_variables( variables_extension = user_variable_extensions, ) - # TODO: Remove bazel_features check when we drop Baze 8 - if bazel_features.cc.objc_fragment_has_builtin_objc_strip_action and \ + # TODO: Remove hasattr check when we drop Bazel 8 + if hasattr(ctx.fragments.objc, "builtin_objc_strip_action") and \ fragment_support.is_objc_strip_action_enabled( cpp_fragment = ctx.fragments.cpp, ) and \ From a9c16f636a3a90620bbb4d7edba839cd94389f72 Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Thu, 2 Apr 2026 01:07:33 -0400 Subject: [PATCH 09/13] chore: regenerate docs after provider field removal The removal of AppleDynamicFrameworkInfo fields (framework_dirs, framework_files, binary) requires updating the generated docs. --- doc/providers.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/providers.md b/doc/providers.md index 9cacca33c6..ff1195bc86 100644 --- a/doc/providers.md +++ b/doc/providers.md @@ -282,9 +282,6 @@ Contains information about an Apple dynamic framework. | Name | Description | | :------------- | :------------- | -| 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. | From 8462c2c23914daa3e0a80146f3d62ff3f9e350dd Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Thu, 2 Apr 2026 01:27:51 -0400 Subject: [PATCH 10/13] fix: rename debug_outputs.dsym_binaries to dsym_outputs The linking_support struct field was renamed from dsym_binaries to dsym_outputs but not all call sites in the platform rule files were updated, causing analysis failures. --- apple/internal/ios_rules.bzl | 6 +++--- apple/internal/macos_rules.bzl | 10 +++++----- apple/internal/tvos_rules.bzl | 8 ++++---- apple/internal/visionos_rules.bzl | 14 +++++++------- apple/internal/watchos_rules.bzl | 6 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index e070569c4a..caa922b717 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -408,7 +408,7 @@ def _ios_application_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets + ctx.attr.deps, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = ctx.attr.include_symbols_in_bundle, platform_prerequisites = platform_prerequisites, @@ -769,7 +769,7 @@ def _ios_app_clip_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_binaries, + dsym_binaries = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1623,7 +1623,7 @@ def _ios_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, diff --git a/apple/internal/macos_rules.bzl b/apple/internal/macos_rules.bzl index 027a893195..37b6dd47ca 100644 --- a/apple/internal/macos_rules.bzl +++ b/apple/internal/macos_rules.bzl @@ -938,7 +938,7 @@ def _macos_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = [], - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1151,7 +1151,7 @@ def _macos_quick_look_plugin_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.additional_contents.keys(), - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -2936,7 +2936,7 @@ def _macos_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -2999,7 +2999,7 @@ def _macos_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -3216,7 +3216,7 @@ def _macos_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, diff --git a/apple/internal/tvos_rules.bzl b/apple/internal/tvos_rules.bzl index ff66655edc..c7d1bc086b 100644 --- a/apple/internal/tvos_rules.bzl +++ b/apple/internal/tvos_rules.bzl @@ -372,7 +372,7 @@ def _tvos_application_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -644,7 +644,7 @@ def _tvos_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -988,7 +988,7 @@ def _tvos_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1262,7 +1262,7 @@ def _tvos_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, diff --git a/apple/internal/visionos_rules.bzl b/apple/internal/visionos_rules.bzl index 84bb1d3344..a008908c48 100644 --- a/apple/internal/visionos_rules.bzl +++ b/apple/internal/visionos_rules.bzl @@ -314,7 +314,7 @@ Resolved Xcode is version {xcode_version}. bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = embeddable_targets + ctx.attr.deps, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -373,7 +373,7 @@ Resolved Xcode is version {xcode_version}. actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -651,7 +651,7 @@ def _visionos_dynamic_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -935,7 +935,7 @@ def _visionos_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.deps, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -998,7 +998,7 @@ def _visionos_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1212,7 +1212,7 @@ def _visionos_extension_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks + ctx.attr.deps, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -1263,7 +1263,7 @@ def _visionos_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, diff --git a/apple/internal/watchos_rules.bzl b/apple/internal/watchos_rules.bzl index c01a2a1366..bc3a47e1ad 100644 --- a/apple/internal/watchos_rules.bzl +++ b/apple/internal/watchos_rules.bzl @@ -299,7 +299,7 @@ def _watchos_framework_impl(ctx): bundle_extension = bundle_extension, bundle_name = bundle_name, debug_dependencies = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, dsym_info_plist_template = apple_mac_toolchain_info.dsym_info_plist_template, label_name = label.name, linkmaps = debug_outputs.linkmaps, @@ -362,7 +362,7 @@ def _watchos_framework_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = ctx.attr.frameworks, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, @@ -1271,7 +1271,7 @@ def _watchos_extension_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets, - dsym_outputs = debug_outputs.dsym_binaries, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, From cb839837a7844f0a58e7056691693da6ba54fa1b Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Thu, 2 Apr 2026 01:55:18 -0400 Subject: [PATCH 11/13] fix: restore executable_name support in debug_symbols_partial The synced debug_symbols_partial from upstream dropped executable_name, but the open-source build uses it to allow the dSYM filename to differ from bundle_name (e.g. for test bundles). Re-add as an optional param defaulting to None, falling back to bundle_name when unset. --- apple/internal/partials/debug_symbols.bzl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apple/internal/partials/debug_symbols.bzl b/apple/internal/partials/debug_symbols.bzl index 9e93d8f618..53c0059e61 100644 --- a/apple/internal/partials/debug_symbols.bzl +++ b/apple/internal/partials/debug_symbols.bzl @@ -492,6 +492,7 @@ def _debug_symbols_partial_impl( debug_discriminator = None, dsym_outputs = {}, dsym_info_plist_template, + executable_name = None, label_name, linkmaps = {}, output_discriminator = None, @@ -516,7 +517,7 @@ def _debug_symbols_partial_impl( if AppleFrameworkImportInfo in x ] - debug_output_filename = bundle_name + debug_output_filename = executable_name or bundle_name if debug_discriminator: debug_output_filename += "_" + debug_discriminator @@ -611,6 +612,7 @@ def debug_symbols_partial( debug_discriminator = None, dsym_outputs = {}, dsym_info_plist_template, + executable_name = None, label_name, linkmaps = {}, output_discriminator = None, @@ -639,6 +641,7 @@ def debug_symbols_partial( dsym_outputs: A mapping of architectures to Files representing dsym outputs for each architecture. dsym_info_plist_template: File referencing a plist template for dSYM bundles. + executable_name: The name of the output DWARF executable, or `None` to use bundle_name. label_name: The name of the target. linkmaps: A mapping of architectures to Files representing linkmaps for each architecture. output_discriminator: A string to differentiate between different target intermediate files @@ -660,6 +663,7 @@ def debug_symbols_partial( debug_discriminator = debug_discriminator, dsym_outputs = dsym_outputs, dsym_info_plist_template = dsym_info_plist_template, + executable_name = executable_name, label_name = label_name, linkmaps = linkmaps, output_discriminator = output_discriminator, From a81f9c4a7821e870857389300e2b9facb8d5d306 Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Thu, 2 Apr 2026 02:05:17 -0400 Subject: [PATCH 12/13] fix: rename dsym_binaries kwarg to dsym_outputs in app_clip symbols partial call Missed rename in _ios_app_clip_impl's apple_symbols_file_partial call. --- apple/internal/ios_rules.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apple/internal/ios_rules.bzl b/apple/internal/ios_rules.bzl index caa922b717..8d1cd03a3d 100644 --- a/apple/internal/ios_rules.bzl +++ b/apple/internal/ios_rules.bzl @@ -769,7 +769,7 @@ def _ios_app_clip_impl(ctx): actions = actions, binary_artifact = binary_artifact, dependency_targets = embeddable_targets + ctx.attr.deps, - dsym_binaries = debug_outputs.dsym_outputs, + dsym_outputs = debug_outputs.dsym_outputs, label_name = label.name, include_symbols_in_bundle = False, platform_prerequisites = platform_prerequisites, From 1302e8a167f92a970a95b93fec0c7ce08ece4586 Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Thu, 2 Apr 2026 19:20:18 -0400 Subject: [PATCH 13/13] fix: quote OUTPUT_DIR in debug_symbols shell commands for paths with spaces The synced debug_symbols.bzl from upstream didn't quote OUTPUT_DIR references in shell commands, causing failures for targets with spaces in their bundle names (e.g. ext_with_space). The open-source repo has test targets with spaces that upstream doesn't. --- apple/internal/partials/debug_symbols.bzl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apple/internal/partials/debug_symbols.bzl b/apple/internal/partials/debug_symbols.bzl index 53c0059e61..5570a41797 100644 --- a/apple/internal/partials/debug_symbols.bzl +++ b/apple/internal/partials/debug_symbols.bzl @@ -207,10 +207,10 @@ def _lipo_command_for_dsyms( found_binary_paths.append(dsym_binary.path) lipo_command = ( - "mkdir -p ${{OUTPUT_DIR}}/Contents/Resources/DWARF && " + + "mkdir -p \"${{OUTPUT_DIR}}/Contents/Resources/DWARF\" && " + "/usr/bin/lipo " + "-create {found_binary_inputs} " + - "-output ${{OUTPUT_DIR}}/Contents/Resources/DWARF/{main_binary_basename}" + "-output \"${{OUTPUT_DIR}}/Contents/Resources/DWARF/{main_binary_basename}\"" ).format( found_binary_inputs = " ".join([shell.quote(path) for path in found_binary_paths]), main_binary_basename = main_binary_basename, @@ -414,13 +414,13 @@ def _bundle_dsym_files( # We expect any given Info.plist from the splits to be as good as any, no need to merge # them, but we can do that with plisttool if and when it's needed. plist_command = ( - "cp {dsym_plist_path} ${{OUTPUT_DIR}}/Contents/Info.plist" + "cp \"{dsym_plist_path}\" \"${{OUTPUT_DIR}}/Contents/Info.plist\"" ).format( dsym_plist_path = dsym_inputs.values()[0].path + "/Contents/Info.plist", ) command = ( - "rm -rf ${OUTPUT_DIR} && " + + "rm -rf \"${OUTPUT_DIR}\" && " + lipo_command + " && " + ditto_command + " && " + plist_command @@ -458,7 +458,7 @@ def _bundle_dsym_files( dsym_plist_path = dsym_plist.path, ) - command = "rm -rf ${OUTPUT_DIR} && " + lipo_command + " && " + plist_command + command = "rm -rf \"${OUTPUT_DIR}\" && " + lipo_command + " && " + plist_command # Put the tree artifact dSYMs in a subdirectory to avoid conflicts with any legacy dSYMs # provided through existing APIs such as --output_groups=+dsyms; note that legacy "flat