Skip to content

Commit fe4feac

Browse files
nglevinluispadron
authored andcommitted
Remove Xcode 15.1/15.2 support for App Intents ahead of implementing support for AppIntentsPackage.
Cherry-pick: 29eb94c
1 parent 105a261 commit fe4feac

File tree

10 files changed

+36
-241
lines changed

10 files changed

+36
-241
lines changed

apple/internal/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ bzl_library(
342342
],
343343
deps = [
344344
":apple_toolchains",
345-
":cc_toolchain_info_support",
346345
":compilation_support",
347346
":entitlements_support",
348347
":intermediates",

apple/internal/ios_rules.bzl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,7 @@ def _ios_application_impl(ctx):
280280
partials.app_intents_metadata_bundle_partial(
281281
actions = actions,
282282
cc_toolchains = cc_toolchain_forwarder,
283-
ctx = ctx,
284283
deps = ctx.split_attr.app_intents,
285-
disabled_features = ctx.disabled_features,
286-
features = features,
287284
label = label,
288285
platform_prerequisites = platform_prerequisites,
289286
json_tool = apple_xplat_toolchain_info.json_tool,
@@ -1317,10 +1314,7 @@ def _ios_extension_impl(ctx):
13171314
partials.app_intents_metadata_bundle_partial(
13181315
actions = actions,
13191316
cc_toolchains = ctx.split_attr._cc_toolchain_forwarder,
1320-
ctx = ctx,
13211317
deps = ctx.split_attr.app_intents,
1322-
disabled_features = ctx.disabled_features,
1323-
features = features,
13241318
label = label,
13251319
platform_prerequisites = platform_prerequisites,
13261320
json_tool = apple_xplat_toolchain_info.json_tool,

apple/internal/linking_support.bzl

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ load(
2121
"@rules_cc//cc/private/rules_impl:objc_compilation_support.bzl",
2222
objc_compilation_support = "compilation_support",
2323
) # buildifier: disable=bzl-visibility
24-
load(
25-
"//apple/internal:cc_toolchain_info_support.bzl",
26-
"cc_toolchain_info_support",
27-
)
2824
load(
2925
"//apple/internal:compilation_support.bzl",
3026
"compilation_support",
@@ -681,139 +677,8 @@ def _lipo_or_symlink_inputs(*, actions, inputs, output, apple_fragment, xcode_co
681677
# Symlink if there was only a single architecture created; it's faster.
682678
actions.symlink(target_file = inputs[0], output = output)
683679

684-
# TODO: Delete when we take https://github.com/bazelbuild/rules_apple/commit/29eb94cbc9b1a898582e1e238cc2551ddbeaa58b
685-
def _legacy_link_multi_arch_binary(
686-
*,
687-
actions,
688-
additional_inputs = [],
689-
cc_toolchains,
690-
ctx,
691-
deps,
692-
disabled_features,
693-
features,
694-
label,
695-
stamp = -1,
696-
user_link_flags = []):
697-
"""Experimental Starlark version of multiple architecture binary linking action.
698-
699-
This Stalark version is an experimental re-write of the apple_common.link_multi_arch_binary API
700-
with minimal support for linking multiple architecture binaries from split dependencies.
701-
702-
Specifically, this lacks support for:
703-
- Generating Apple dSYM binaries.
704-
- Generating Objective-C linkmaps.
705-
- Avoid linking symbols from Objective-C(++) dependencies (i.e. avoid_deps).
706-
707-
Args:
708-
actions: The actions provider from `ctx.actions`.
709-
additional_inputs: List of additional `File`s required for the C++ linking action (e.g.
710-
linking scripts).
711-
cc_toolchains: Dictionary of targets (`ctx.split_attr`) containing CcToolchainInfo
712-
providers to use for C++ actions.
713-
ctx: The Starlark context for a rule target being built.
714-
deps: Dictionary of targets (`ctx.split_attr`) referencing dependencies for a given target
715-
to retrieve transitive CcInfo providers for C++ linking action.
716-
disabled_features: List of features to be disabled for C++ actions.
717-
features: List of features to be enabled for C++ actions.
718-
label: Label for the current target (`ctx.label`).
719-
stamp: Boolean to indicate whether to include build information in the linked binary.
720-
If 1, build information is always included.
721-
If 0, the default build information is always excluded.
722-
If -1, uses the default behavior, which may be overridden by the --[no]stamp flag.
723-
This should be set to 0 when generating the executable output for test rules.
724-
user_link_flags: List of `str` user link flags to add to the C++ linking action.
725-
Returns:
726-
A struct containing the following information:
727-
- cc_info: Merged CcInfo providers from each linked binary CcInfo provider.
728-
- output_groups: OutputGroupInfo provider with CcInfo validation artifacts.
729-
- outputs: List of `struct`s containing the linking output information below.
730-
- architecture: The target Apple architecture.
731-
- binary: `File` referencing the linked binary.
732-
- environment: The target Apple environment.
733-
- platform: The target Apple platform/os.
734-
"""
735-
if type(deps) != "dict" or type(cc_toolchains) != "dict":
736-
fail(
737-
"Expected deps and cc_toolchains to be split attributes (dictionaries).\n",
738-
"deps: %s\n" % deps,
739-
"cc_toolchains: %s" % cc_toolchains,
740-
)
741-
742-
if deps.keys() != cc_toolchains.keys():
743-
fail(
744-
"Expected deps and cc_toolchains split attribute keys to match",
745-
"deps: %s\n" % deps.keys(),
746-
"cc_toolchains: %s\n" % cc_toolchains.keys(),
747-
)
748-
749-
all_cc_infos = []
750-
linking_outputs = []
751-
validation_artifacts = []
752-
for split_attr_key, cc_toolchain_target in cc_toolchains.items():
753-
cc_toolchain = cc_toolchain_target[cc_common.CcToolchainInfo]
754-
target_triple = cc_toolchain_info_support.get_apple_clang_triplet(cc_toolchain)
755-
756-
feature_configuration = cc_common.configure_features(
757-
cc_toolchain = cc_toolchain,
758-
ctx = ctx,
759-
language = "objc",
760-
requested_features = features,
761-
unsupported_features = disabled_features,
762-
)
763-
764-
cc_infos = [
765-
dep[CcInfo]
766-
for dep in deps[split_attr_key]
767-
if CcInfo in dep
768-
]
769-
all_cc_infos.extend(cc_infos)
770-
771-
cc_linking_contexts = [cc_info.linking_context for cc_info in cc_infos]
772-
output_name = "{label}_{os}_{architecture}_bin".format(
773-
architecture = target_triple.architecture,
774-
label = label.name,
775-
os = target_triple.os,
776-
)
777-
linking_output = cc_common.link(
778-
actions = actions,
779-
additional_inputs = additional_inputs,
780-
cc_toolchain = cc_toolchain,
781-
feature_configuration = feature_configuration,
782-
linking_contexts = cc_linking_contexts,
783-
name = output_name,
784-
stamp = stamp,
785-
user_link_flags = user_link_flags,
786-
)
787-
788-
validation_artifacts.extend([
789-
cc_info.compilation_context.validation_artifacts
790-
for cc_info in cc_infos
791-
])
792-
793-
linking_outputs.append(
794-
struct(
795-
architecture = target_triple.architecture,
796-
binary = linking_output.executable,
797-
environment = target_triple.environment,
798-
platform = target_triple.os,
799-
),
800-
)
801-
802-
return struct(
803-
cc_info = cc_common.merge_cc_infos(
804-
cc_infos = all_cc_infos,
805-
),
806-
output_groups = {
807-
"_validation": depset(
808-
transitive = validation_artifacts,
809-
),
810-
},
811-
outputs = linking_outputs,
812-
)
813-
814680
linking_support = struct(
815681
debug_outputs_by_architecture = _debug_outputs_by_architecture,
816-
legacy_link_multi_arch_binary = _legacy_link_multi_arch_binary,
817682
link_multi_arch_binary = _link_multi_arch_binary,
818683
lipo_or_symlink_inputs = _lipo_or_symlink_inputs,
819684
register_binary_linking_action = _register_binary_linking_action,

apple/internal/macos_rules.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,7 @@ def _macos_application_impl(ctx):
254254
partials.app_intents_metadata_bundle_partial(
255255
actions = actions,
256256
cc_toolchains = cc_toolchain_forwarder,
257-
ctx = ctx,
258257
deps = ctx.split_attr.app_intents,
259-
disabled_features = ctx.disabled_features,
260-
features = features,
261258
label = label,
262259
platform_prerequisites = platform_prerequisites,
263260
json_tool = apple_xplat_toolchain_info.json_tool,

apple/internal/partials/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ bzl_library(
2626
"//apple/internal:__pkg__",
2727
],
2828
deps = [
29-
"//apple/internal:linking_support",
3029
"//apple/internal:processor",
3130
"//apple/internal/providers:app_intents_info",
3231
"//apple/internal/resource_actions:app_intents",

apple/internal/partials/app_intents_metadata_bundle.bzl

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
load("@bazel_skylib//lib:partial.bzl", "partial")
1818
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
19-
load("//apple/internal:intermediates.bzl", "intermediates")
20-
load("//apple/internal:linking_support.bzl", "linking_support")
2119
load("//apple/internal:processor.bzl", "processor")
2220
load(
2321
"//apple/internal/providers:app_intents_info.bzl",
@@ -32,10 +30,7 @@ def _app_intents_metadata_bundle_partial_impl(
3230
*,
3331
actions,
3432
cc_toolchains,
35-
ctx,
3633
deps,
37-
disabled_features,
38-
features,
3934
label,
4035
platform_prerequisites,
4136
json_tool):
@@ -44,52 +39,6 @@ def _app_intents_metadata_bundle_partial_impl(
4439
# No `app_intents` were set by the rule calling this partial.
4540
return struct()
4641

47-
# Link 'stub' binary to use for app intents metadata processing.
48-
# This binary should only contain symbols for structs implementing the AppIntents protocol.
49-
# Instead of containing all the application/extension/framework binary symbols, allowing
50-
# the action to run faster and avoid depending on the application binary linking step.
51-
#
52-
# TODO(b/295227222): Avoid this linker step for Xcode 15.0+ when rules_swift supports the new
53-
# swiftconstvalues-based manner of handling App Intents metadata.
54-
link_result = linking_support.legacy_link_multi_arch_binary(
55-
actions = actions,
56-
cc_toolchains = cc_toolchains,
57-
ctx = ctx,
58-
deps = deps,
59-
disabled_features = disabled_features,
60-
features = features,
61-
label = label,
62-
user_link_flags = [
63-
# Force _NSExtensionMain, which exists on all Apple platforms, to
64-
# be the main symbol for the binary, just so any main symbol will
65-
# exist. Since this binary is discarded afterwards the main symbol
66-
# doesn't actually matter. This can be removed when the TODO above
67-
# is resolved.
68-
"-Wl,-e,_NSExtensionMain",
69-
# Force the binary to link Foundation to make the hack above work.
70-
"-Wl,-framework,Foundation",
71-
],
72-
)
73-
74-
fat_stub_binary = intermediates.file(
75-
actions = actions,
76-
target_name = label.name,
77-
output_discriminator = None,
78-
file_name = "{}_app_intents_stub_binary".format(label.name),
79-
)
80-
81-
linking_support.lipo_or_symlink_inputs(
82-
actions = actions,
83-
inputs = [output.binary for output in link_result.outputs],
84-
output = fat_stub_binary,
85-
apple_fragment = platform_prerequisites.apple_fragment,
86-
xcode_config = platform_prerequisites.xcode_version_config,
87-
)
88-
89-
label.relative(
90-
label.name + "_app_intents_stub_binary",
91-
)
92-
9342
# Mirroring Xcode 15+ behavior, the metadata tool only looks at the first split for a given arch
9443
# rather than every possible set of source files and inputs. Oddly, this only applies to the
9544
# swift source files and the swiftconstvalues files; the triples and other files do cover all
@@ -99,7 +48,6 @@ def _app_intents_metadata_bundle_partial_impl(
9948
metadata_bundle = generate_app_intents_metadata_bundle(
10049
actions = actions,
10150
apple_fragment = platform_prerequisites.apple_fragment,
102-
bundle_binary = fat_stub_binary,
10351
constvalues_files = [
10452
swiftconstvalues_file
10553
for dep in deps[first_cc_toolchain_key]
@@ -111,6 +59,7 @@ def _app_intents_metadata_bundle_partial_impl(
11159
for intent_module_name in dep[AppIntentsInfo].intent_module_names
11260
],
11361
label = label,
62+
platform_prerequisites = platform_prerequisites,
11463
source_files = [
11564
swift_source_file
11665
for dep in deps[first_cc_toolchain_key]
@@ -140,10 +89,7 @@ def app_intents_metadata_bundle_partial(
14089
*,
14190
actions,
14291
cc_toolchains,
143-
ctx,
14492
deps,
145-
disabled_features,
146-
features,
14793
label,
14894
platform_prerequisites,
14995
json_tool):
@@ -155,10 +101,7 @@ def app_intents_metadata_bundle_partial(
155101
actions: The actions provider from ctx.actions.
156102
cc_toolchains: Dictionary of CcToolchainInfo and ApplePlatformInfo providers under a split
157103
transition to relay target platform information.
158-
ctx: The Starlark context for a rule target being built.
159104
deps: Dictionary of targets under a split transition implementing the AppIntents protocol.
160-
disabled_features: List of features to be disabled for C++ link actions.
161-
features: List of features to be enabled for C++ link actions.
162105
label: Label of the target being built.
163106
platform_prerequisites: Struct containing information on the platform being targeted.
164107
json_tool: A `files_to_run` wrapping Python's `json.tool` module
@@ -171,10 +114,7 @@ def app_intents_metadata_bundle_partial(
171114
_app_intents_metadata_bundle_partial_impl,
172115
actions = actions,
173116
cc_toolchains = cc_toolchains,
174-
ctx = ctx,
175117
deps = deps,
176-
disabled_features = disabled_features,
177-
features = features,
178118
label = label,
179119
platform_prerequisites = platform_prerequisites,
180120
json_tool = json_tool,

0 commit comments

Comments
 (0)