Skip to content

Commit

Permalink
Remove emit_swiftinterface from the Apple rule transitions.
Browse files Browse the repository at this point in the history
Instead of relying on the transition to set the flag throughout the dependency graph, users should set `library_evolution = True` on the specific libraries that they want to support library evolution.

PiperOrigin-RevId: 629760009
(cherry picked from commit 24a862d)
  • Loading branch information
allevato authored and AttilaTheFun committed Jan 10, 2025
1 parent 710570f commit 8384c24
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions apple/internal/transition_support.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def _is_arch_supported_for_target_tuple(*, environment_arch, minimum_os_version,
def _command_line_options(
*,
apple_platforms = [],
emit_swiftinterface = False,
environment_arch = None,
force_bundle_outputs = False,
minimum_os_version,
Expand All @@ -221,8 +220,6 @@ def _command_line_options(
first element will be applied to `platforms` as that will be what is resolved by the
underlying rule. Defaults to an empty list, which will signal to Bazel that platform
mapping can take place as a fallback measure.
emit_swiftinterface: Wheither to emit swift interfaces for the given target. Defaults to
`False`.
environment_arch: A valid Apple environment when applicable with its architecture as a
string (for example `sim_arm64` from `ios_sim_arm64`, or `arm64` from `ios_arm64`), or
None to infer a value from command line options passed through settings.
Expand Down Expand Up @@ -284,7 +281,6 @@ def _command_line_options(
platform = "watchos",
platform_type = platform_type,
),
"@build_bazel_rules_swift//swift:emit_swiftinterface": emit_swiftinterface,
}

def _xcframework_split_attr_key(*, arch, environment, platform_type):
Expand Down Expand Up @@ -320,7 +316,6 @@ def _resolved_environment_arch_for_arch(*, arch, environment, platform_type):

def _command_line_options_for_xcframework_platform(
*,
attr,
minimum_os_version,
platform_attr,
platform_type,
Expand All @@ -329,7 +324,6 @@ def _command_line_options_for_xcframework_platform(
"""Generates a dictionary of command line options keyed by 1:2+ transition for this platform.
Args:
attr: The attributes passed to the transition function.
minimum_os_version: A string representing the minimum OS version specified for this
platform, represented as a dotted version number (for example, `"9.0"`).
platform_attr: The attribute for the apple platform specifying in dictionary form which
Expand Down Expand Up @@ -363,10 +357,6 @@ def _command_line_options_for_xcframework_platform(
environment = target_environment,
platform_type = platform_type,
): _command_line_options(
emit_swiftinterface = _should_emit_swiftinterface(
attr,
is_xcframework = True,
),
environment_arch = resolved_environment_arch,
minimum_os_version = minimum_os_version,
platform_type = platform_type,
Expand All @@ -377,28 +367,10 @@ def _command_line_options_for_xcframework_platform(

return output_dictionary

def _should_emit_swiftinterface(attr, is_xcframework = False):
"""Determines if a .swiftinterface file should be generated for Swift dependencies.
Needed until users of the framework rules are allowed to enable
library evolution on specific targets instead of having it automatically
applied to the entire dependency subgraph.
"""

features = getattr(attr, "features", [])
if type(features) == "list" and "apple.no_legacy_swiftinterface" in features:
return False

# iOS and tvOS static frameworks require underlying swift_library targets generate a Swift
# interface file. These rules define a private attribute called `_emitswiftinterface` that
# let's this transition flip rules_swift config down the build graph.
return is_xcframework or hasattr(attr, "_emitswiftinterface")

def _apple_rule_base_transition_impl(settings, attr):
"""Rule transition for Apple rules using Bazel CPUs and a valid Apple split transition."""
platform_type = attr.platform_type
return _command_line_options(
emit_swiftinterface = _should_emit_swiftinterface(attr),
environment_arch = _environment_archs(platform_type, settings)[0],
minimum_os_version = attr.minimum_os_version,
platform_type = platform_type,
Expand Down Expand Up @@ -444,7 +416,6 @@ _apple_rule_base_transition_outputs = [
"//command_line_option:platforms",
"//command_line_option:tvos_minimum_os",
"//command_line_option:watchos_minimum_os",
"@build_bazel_rules_swift//swift:emit_swiftinterface",
]
_apple_universal_binary_rule_transition_outputs = _apple_rule_base_transition_outputs + [
"//command_line_option:ios_multi_cpus",
Expand All @@ -469,7 +440,6 @@ def _apple_platforms_rule_base_transition_impl(settings, attr):
environment_arch = _environment_archs(platform_type, settings)[0]
return _command_line_options(
apple_platforms = settings["//command_line_option:apple_platforms"],
emit_swiftinterface = _should_emit_swiftinterface(attr),
environment_arch = environment_arch,
minimum_os_version = minimum_os_version,
platform_type = platform_type,
Expand All @@ -492,7 +462,6 @@ def _apple_platforms_rule_bundle_output_base_transition_impl(settings, attr):
environment_arch = _environment_archs(platform_type, settings)[0]
return _command_line_options(
apple_platforms = settings["//command_line_option:apple_platforms"],
emit_swiftinterface = _should_emit_swiftinterface(attr),
environment_arch = environment_arch,
force_bundle_outputs = True,
minimum_os_version = minimum_os_version,
Expand Down Expand Up @@ -569,11 +538,6 @@ def _apple_platform_split_transition_impl(settings, attr):
output_dictionary = {}
invalid_requested_archs = []

# iOS and tvOS static frameworks require underlying swift_library targets generate a Swift
# interface file. These rules define a private attribute called `_emitswiftinterface` that
# let's this transition flip rules_swift config down the build graph.
emit_swiftinterface = _should_emit_swiftinterface(attr)

if settings["//command_line_option:incompatible_enable_apple_toolchain_resolution"]:
platforms = (
settings["//command_line_option:apple_platforms"] or
Expand All @@ -594,7 +558,6 @@ def _apple_platform_split_transition_impl(settings, attr):
if str(platform) not in output_dictionary:
output_dictionary[str(platform)] = _command_line_options(
apple_platforms = apple_platforms,
emit_swiftinterface = emit_swiftinterface,
minimum_os_version = attr.minimum_os_version,
platform_type = attr.platform_type,
settings = settings,
Expand Down Expand Up @@ -643,7 +606,6 @@ def _apple_platform_split_transition_impl(settings, attr):
continue

output_dictionary[found_cpu] = _command_line_options(
emit_swiftinterface = emit_swiftinterface,
environment_arch = environment_arch,
minimum_os_version = minimum_os_version,
platform_type = platform_type,
Expand Down Expand Up @@ -694,7 +656,6 @@ def _xcframework_transition_impl(settings, attr):
target_environments.append("simulator")

command_line_options = _command_line_options_for_xcframework_platform(
attr = attr,
minimum_os_version = attr.minimum_os_versions.get(platform_type),
platform_attr = platform_attr,
platform_type = platform_type,
Expand Down

0 comments on commit 8384c24

Please sign in to comment.