Skip to content

Commit 773aff0

Browse files
authored
Collect additional mixed_language_library output files (#3261)
Fixes #3258. In `xcodeproj/internal/files/output_files.bzl` using `_collect_output_files` as a reference starts collecting more outputs in `_collect_mixed_language_output_files` to address the issue. I'll use #3259 to verify this fix is good (I will either rebase or cherry pick it here) --------- Signed-off-by: Thiago Cruz <thiago@squareup.com>
1 parent ad6709a commit 773aff0

2 files changed

Lines changed: 55 additions & 3 deletions

File tree

xcodeproj/internal/files/output_files.bzl

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,28 +292,52 @@ def _collect_mixed_language_output_files(
292292
*,
293293
actions,
294294
compile_params_files,
295+
debug_outputs,
295296
id,
296297
indexstore_overrides,
297298
mixed_target_infos,
298-
name):
299+
name,
300+
output_group_info,
301+
product = None,
302+
swift_info,
303+
transitive_infos):
299304
"""Collects the outputs of a target.
300305
301306
Args:
302307
actions: `ctx.actions`.
303308
compile_params_files: A `list` of compiler params `File`s that should be
304309
generated for Index Build and Xcode Previews.
310+
debug_outputs: The `AppleDebugOutputsInfo` provider for the target, or
311+
`None`.
305312
id: A unique identifier for the target.
306313
indexstore_overrides: A `list` of `(indexstore, target_name)` `tuple`s
307314
that override the indexstore for the target. This is used for merged
308315
targets.
309316
mixed_target_infos: A `list` of `XcodeProjInfo`s for the underlying
310317
Clang and Swift targets.
311318
name: Name (potentially replaced) of the target.
319+
output_group_info: The `OutputGroupInfo` provider for the target, or
320+
`None`.
321+
product: A value from `process_product`.
322+
swift_info: The `SwiftInfo` provider for the target, or `None`.
323+
transitive_infos: A `list` of `XcodeProjInfo`s for the transitive
324+
dependencies of the target.
312325
313326
Returns:
314327
An opaque `struct` that should be used with `output_files.to_dto` or
315328
`output_files.to_output_groups_fields`.
316329
"""
330+
direct_outputs = _get_outputs(
331+
debug_outputs = debug_outputs,
332+
output_group_info = output_group_info,
333+
product = product,
334+
swift_info = swift_info,
335+
)
336+
337+
direct_products = []
338+
if direct_outputs.product:
339+
direct_products.append(direct_outputs.product)
340+
317341
transitive_indexstore_overrides = memory_efficient_depset(
318342
indexstore_overrides,
319343
transitive = [
@@ -328,6 +352,17 @@ def _collect_mixed_language_output_files(
328352
],
329353
)
330354

355+
# TODO: Once BwB mode no longer has target dependencies, remove
356+
# transitive products. Until then we need them, to allow `Copy Bazel
357+
# Outputs` to be able to copy the products of transitive dependencies.
358+
transitive_products = memory_efficient_depset(
359+
direct_products,
360+
transitive = [
361+
info.outputs._transitive_products
362+
for info in transitive_infos
363+
],
364+
)
365+
331366
transitive_compile_params = memory_efficient_depset(
332367
compile_params_files,
333368
transitive = [
@@ -357,8 +392,9 @@ def _collect_mixed_language_output_files(
357392
# expand to individual files and blow up the BEP. Instead they are
358393
# declared as inputs to `indexstores_filelist`, ensuring they are
359394
# downloaded as needed.
360-
[indexstores_filelist]
395+
[indexstores_filelist] + direct_products
361396
),
397+
transitive = [transitive_products],
362398
)
363399

364400
direct_group_list = [

xcodeproj/internal/processed_targets/mixed_language_library_targets.bzl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Functions for processing mixed-language library targets."""
22

33
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
4+
load("@build_bazel_rules_apple//apple:providers.bzl", "AppleDebugOutputsInfo")
5+
load("@build_bazel_rules_swift//swift:swift.bzl", "SwiftInfo")
46
load("//xcodeproj:xcodeprojinfo.bzl", "XcodeProjInfo")
57
load("//xcodeproj/internal:build_settings.bzl", "get_product_module_name")
68
load("//xcodeproj/internal:compilation_providers.bzl", "compilation_providers")
@@ -65,6 +67,8 @@ def _process_mixed_language_library_target(
6567
)
6668

6769
objc = target[apple_common.Objc] if apple_common.Objc in target else None
70+
swift_info = target[SwiftInfo] if SwiftInfo in target else None
71+
6872
(
6973
target_compilation_providers,
7074
provider_compilation_providers,
@@ -163,17 +167,29 @@ def _process_mixed_language_library_target(
163167
tool = ctx.executable._target_build_settings_generator,
164168
)
165169

170+
if AppleDebugOutputsInfo in target:
171+
debug_outputs = target[AppleDebugOutputsInfo]
172+
else:
173+
debug_outputs = None
174+
166175
(
167176
target_outputs,
168177
provider_outputs,
169178
target_output_groups_metadata,
170179
) = output_files.collect_mixed_language(
171180
actions = actions,
172181
compile_params_files = params_files,
182+
debug_outputs = debug_outputs,
173183
id = id,
174184
indexstore_overrides = indexstore_overrides,
175-
name = label.name,
176185
mixed_target_infos = mixed_target_infos,
186+
name = label.name,
187+
output_group_info = (
188+
target[OutputGroupInfo] if OutputGroupInfo in target else None
189+
),
190+
product = product,
191+
swift_info = swift_info,
192+
transitive_infos = transitive_infos,
177193
)
178194
target_output_groups = output_groups.collect(
179195
metadata = target_output_groups_metadata,

0 commit comments

Comments
 (0)