@@ -72,6 +72,12 @@ _IOS_ARCH_TO_64_BIT_WATCHOS = {
7272 "arm64" : "arm64_32" ,
7373}
7474
75+ # Set the default architecture for all platforms as 64-bit Intel.
76+ # TODO(b/246375874): Consider changing the default when a build is invoked from an Apple Silicon
77+ # Mac. The --host_cpu command line option is not guaranteed to reflect the actual host device that
78+ # dispatched the invocation.
79+ _DEFAULT_ARCH = "x86_64"
80+
7581def _platform_specific_cpu_setting_name (platform_type ):
7682 """Returns the name of a platform-specific CPU setting.
7783
@@ -433,7 +439,8 @@ def _command_line_options_for_xcframework_platform(
433439 for target_environment in target_environments :
434440 if not platform_attr .get (target_environment ):
435441 continue
436- for arch in platform_attr [target_environment ]:
442+ sorted_target_archs = sorted (platform_attr [target_environment ])
443+ for arch in sorted_target_archs :
437444 resolved_environment_arch = _resolved_environment_arch_for_arch (
438445 arch = arch ,
439446 environment = target_environment ,
@@ -727,12 +734,30 @@ _apple_platform_split_transition = transition(
727734 outputs = _apple_rule_base_transition_outputs ,
728735)
729736
730- def _xcframework_transition_impl (settings , attr ):
737+ def _xcframework_base_transition_impl (settings , _ ):
738+ """Rule transition for XCFramework rules producing SDK-adjacent artifacts."""
739+
740+ # For safety, lean on darwin_{default arch} with no incoming minimum_os_version to avoid
741+ # incoming settings meant for other platforms overriding the settings for the xcframework rule's
742+ # underlying actions, and allow for toolchain resolution in the future.
743+ return _command_line_options (
744+ environment_arch = _DEFAULT_ARCH ,
745+ minimum_os_version = None ,
746+ platform_type = "macos" ,
747+ settings = settings ,
748+ )
749+
750+ _xcframework_base_transition = transition (
751+ implementation = _xcframework_base_transition_impl ,
752+ inputs = _apple_rule_common_transition_inputs ,
753+ outputs = _apple_rule_base_transition_outputs ,
754+ )
755+
756+ def _xcframework_split_transition_impl (settings , attr ):
731757 """Starlark 1:2+ transition for generation of multiple frameworks for the current target."""
732758 output_dictionary = {}
733759
734- # TODO(b/288582842): Update for visionOS when we're ready to support it in XCFramework rules.
735- for platform_type in ["ios" , "tvos" , "visionos" , "watchos" , "macos" ]:
760+ for platform_type in ["ios" , "tvos" , "watchos" , "visionos" , "macos" ]:
736761 platform_attr = getattr (attr , platform_type , None )
737762 if not platform_attr :
738763 continue
@@ -751,7 +776,7 @@ def _xcframework_transition_impl(settings, attr):
751776 platform_attr = platform_attr ,
752777 platform_type = platform_type ,
753778 settings = settings ,
754- target_environments = target_environments ,
779+ target_environments = sorted ( target_environments ) ,
755780 )
756781 output_dictionary = dicts .add (command_line_options , output_dictionary )
757782
@@ -761,8 +786,8 @@ def _xcframework_transition_impl(settings, attr):
761786
762787 return output_dictionary
763788
764- _xcframework_transition = transition (
765- implementation = _xcframework_transition_impl ,
789+ _xcframework_split_transition = transition (
790+ implementation = _xcframework_split_transition_impl ,
766791 inputs = _apple_rule_common_transition_inputs ,
767792 outputs = _apple_rule_base_transition_outputs ,
768793)
@@ -775,5 +800,6 @@ transition_support = struct(
775800 apple_rule_transition = _apple_rule_base_transition ,
776801 apple_universal_binary_rule_transition = _apple_universal_binary_rule_transition ,
777802 xcframework_split_attr_key = _xcframework_split_attr_key ,
778- xcframework_transition = _xcframework_transition ,
803+ xcframework_base_transition = _xcframework_base_transition ,
804+ xcframework_split_transition = _xcframework_split_transition ,
779805)
0 commit comments