Skip to content

Commit 9a9b037

Browse files
nglevinluispadron
authored andcommitted
Correct issues around "bundle_zips", add an analysis time check to ensure more do not slip through in rules processing.
Cherry-pick: b8e1152
1 parent 9c43767 commit 9a9b037

3 files changed

Lines changed: 36 additions & 11 deletions

File tree

apple/internal/partials/macos_additional_contents.bzl

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,26 @@ def _macos_additional_contents_partial_impl(*, additional_contents):
4646
bundle_zips = []
4747
for target, subdirectory in additional_contents.items():
4848
if AppleBundleInfo in target:
49-
bundle_zips.append(
50-
(
51-
processor.location.content,
52-
subdirectory,
53-
depset([target[AppleBundleInfo].archive]),
54-
),
55-
)
49+
target_archive = target[AppleBundleInfo].archive
50+
if (target_archive.short_path.endswith(".zip") or
51+
target_archive.short_path.endswith(".ipa")):
52+
# Zipped archive case.
53+
bundle_zips.append(
54+
(
55+
processor.location.content,
56+
subdirectory,
57+
depset([target_archive]),
58+
),
59+
)
60+
else:
61+
# Tree artifact archive case.
62+
bundle_files.append(
63+
(
64+
processor.location.content,
65+
subdirectory,
66+
depset([target_archive]),
67+
),
68+
)
5669
elif AppleBinaryInfo in target:
5770
bundle_files.append(
5871
(

apple/internal/processor.bzl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,19 @@ def _bundle_partial_outputs_files(
369369
input_files.extend(sources)
370370

371371
for source in sources:
372+
source_path = source.path
373+
if not source_path.endswith(".zip") and not source_path.endswith(".ipa"):
374+
fail("""
375+
Internal Error: Found a file declared by the Apple rules as a "bundle zip" that is not a zip file: \
376+
{source_path}
377+
378+
This indicates that there is a severe bug in how rules_apple handles the processing of these files.
379+
380+
Please file a bug against the Apple BUILD rules with repro steps.
381+
""".format(source_path = source_path))
382+
372383
target_path = paths.join(location_to_paths[location], parent_dir or "")
373-
control_zips.append(struct(src = source.path, dest = target_path))
384+
control_zips.append(struct(src = source_path, dest = target_path))
374385

375386
post_processor = ipa_post_processor
376387
post_processor_path = ""

apple/internal/resources.bzl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ def _bucketize_data(
243243

244244
# For each type of resource, place in the appropriate bucket.
245245
if AppleFrameworkBundleInfo in target:
246-
if "framework.dSYM/" in resource_short_path or resource.extension == "linkmap":
247-
# Ignore dSYM bundle and linkmap since the debug symbols partial is
248-
# responsible for propagating this up the dependency graph.
246+
if ".dSYM" in resource_short_path or resource.extension == "linkmap":
247+
# Never ever bundle dSYMs or linkmaps since they should never, ever belong in
248+
# resource processing. This goes for any "framework" outputs that do not belong
249+
# in the shipping framework bundle itself.
249250
continue
250251
bucket_name = "framework"
251252
elif resource_short_path.endswith(".strings") or resource_short_path.endswith(".stringsdict"):

0 commit comments

Comments
 (0)