Skip to content

Commit 94c1a7f

Browse files
nglevinswiple-rules-gardener
authored andcommitted
Remove "conflict detection" for the hdrs attribute and the generated umbrella header to consistently allow users to override the umbrella header via public_hdrs or hdrs, where available.
PiperOrigin-RevId: 553817824
1 parent 686d202 commit 94c1a7f

File tree

7 files changed

+12
-105
lines changed

7 files changed

+12
-105
lines changed

apple/internal/partials/framework_header_modulemap.bzl

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,20 @@ def _create_umbrella_header(actions, output, headers):
119119
content = "\n".join(import_lines) + "\n"
120120
actions.write(output = output, content = content)
121121

122-
def _verify_headers(
122+
def _exported_headers(
123123
*,
124124
public_hdrs,
125-
umbrella_header_name):
126-
"""Raises an error if a public header conflicts with the umbrella header.
125+
generated_umbrella_header_file):
126+
"""Determines if the generated umbrella header needs to be an output of public headers.
127127
128128
Args:
129129
public_hdrs: The list of headers to bundle.
130-
umbrella_header_name: The basename of the umbrella header file, or None if
131-
there is no umbrella header.
130+
generated_umbrella_header_file: The generated umbrella header file.
132131
"""
133-
conflicting_headers = []
134132
for public_hdr in public_hdrs:
135-
if public_hdr.basename == umbrella_header_name:
136-
conflicting_headers.append(public_hdr.path)
137-
if conflicting_headers:
138-
fail(("Found imported header file(s) which conflict(s) with the name \"%s\" of the " +
139-
"generated umbrella header for this target. Check input files:\n%s\n\nPlease " +
140-
"remove the references to these files from your rule's list of headers to import " +
141-
"or rename the headers if necessary.\n") %
142-
(umbrella_header_name, ", ".join(conflicting_headers)))
133+
if public_hdr.basename == generated_umbrella_header_file.basename:
134+
return public_hdrs
135+
return public_hdrs + [generated_umbrella_header_file]
143136

144137
def _framework_header_modulemap_partial_impl(
145138
*,
@@ -182,13 +175,13 @@ def _framework_header_modulemap_partial_impl(
182175
(processor.location.bundle, "Headers", depset(hdrs)),
183176
)
184177
else:
185-
_verify_headers(
178+
exported_hdrs = _exported_headers(
186179
public_hdrs = hdrs,
187-
umbrella_header_name = umbrella_header_name,
180+
generated_umbrella_header_file = umbrella_header_file,
188181
)
189182

190183
bundle_files.append(
191-
(processor.location.bundle, "Headers", depset(hdrs + [umbrella_header_file])),
184+
(processor.location.bundle, "Headers", depset(exported_hdrs)),
192185
)
193186
else:
194187
umbrella_header_name = None
@@ -227,7 +220,7 @@ def framework_header_modulemap_partial(
227220
output_discriminator = None,
228221
sdk_dylibs = [],
229222
sdk_frameworks = [],
230-
umbrella_header):
223+
umbrella_header = None):
231224
"""Constructor for the framework headers and modulemaps partial.
232225
233226
This partial bundles the headers and modulemaps for sdk frameworks.
@@ -243,7 +236,7 @@ def framework_header_modulemap_partial(
243236
or `None`.
244237
sdk_dylibs: A list of dynamic libraries referenced by this framework.
245238
sdk_frameworks: A list of frameworks referenced by this framework.
246-
umbrella_header: An umbrella header to use instead of generating one
239+
umbrella_header: An umbrella header to use instead of generating one. Optional.
247240
248241
Returns:
249242
A partial that returns the bundle location of the sdk framework header and modulemap

apple/internal/xcframework_rules.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ def _apple_xcframework_impl(ctx):
668668
hdrs = ctx.files.public_hdrs,
669669
label_name = label.name,
670670
output_discriminator = library_identifier,
671-
umbrella_header = None,
672671
),
673672
)
674673

@@ -941,7 +940,6 @@ def _apple_static_xcframework_impl(ctx):
941940
hdrs = ctx.files.public_hdrs,
942941
label_name = label.name,
943942
output_discriminator = library_identifier,
944-
umbrella_header = None,
945943
sdk_frameworks = sdk_frameworks,
946944
sdk_dylibs = sdk_dylibs,
947945
))

test/starlark_tests/apple_xcframework_tests.bzl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ load(
2020
)
2121
load(
2222
"//test/starlark_tests/rules:analysis_failure_message_test.bzl",
23-
"analysis_failure_message_test",
2423
"analysis_failure_message_with_tree_artifact_outputs_test",
2524
)
2625
load(
@@ -525,15 +524,6 @@ def apple_xcframework_test_suite(name):
525524
tags = [name],
526525
)
527526

528-
# Test that an actionable error is produced for the user when a header to
529-
# bundle conflicts with the generated umbrella header.
530-
analysis_failure_message_test(
531-
name = "{}_umbrella_header_conflict_test".format(name),
532-
target_under_test = "//test/starlark_tests/targets_under_test/apple:ios_dynamic_xcframework_with_umbrella_header_conflict",
533-
expected_error = "Found imported header file(s) which conflict(s) with the name \"UmbrellaHeaderConflict.h\" of the generated umbrella header for this target. Check input files:\nthird_party/bazel_rules/rules_apple/test/starlark_tests/resources/UmbrellaHeaderConflict.h\n\nPlease remove the references to these files from your rule's list of headers to import or rename the headers if necessary.",
534-
tags = [name],
535-
)
536-
537527
# Test tvOS XCFramework binaries contain Mach-O load commands for device or simulator.
538528
archive_contents_test(
539529
name = "{}_tvos_simulator_binary_contains_macho_load_cmd_test".format(name),

test/starlark_tests/ios_static_framework_tests.bzl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ load(
1818
":common.bzl",
1919
"common",
2020
)
21-
load(
22-
"//test/starlark_tests/rules:analysis_failure_message_test.bzl",
23-
"analysis_failure_message_test",
24-
)
2521
load(
2622
"//test/starlark_tests/rules:common_verification_tests.bzl",
2723
"archive_contents_test",
@@ -149,15 +145,6 @@ def ios_static_framework_test_suite(name):
149145
tags = [name],
150146
)
151147

152-
# Test that an actionable error is produced for the user when a header to
153-
# bundle conflicts with the generated umbrella header.
154-
analysis_failure_message_test(
155-
name = "{}_umbrella_header_conflict_test".format(name),
156-
target_under_test = "//test/starlark_tests/targets_under_test/ios:static_framework_with_umbrella_header_conflict",
157-
expected_error = "Found imported header file(s) which conflict(s) with the name \"UmbrellaHeaderConflict.h\" of the generated umbrella header for this target. Check input files:\nthird_party/bazel_rules/rules_apple/test/starlark_tests/resources/UmbrellaHeaderConflict.h\n\nPlease remove the references to these files from your rule's list of headers to import or rename the headers if necessary.",
158-
tags = [name],
159-
)
160-
161148
# Tests that attempting to generate dSYMs does not cause the build to fail
162149
# (apple_static_library does not generate dSYMs, and the bundler should not
163150
# unconditionally assume that the provider will be present).

test/starlark_tests/resources/UmbrellaHeaderConflict.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/starlark_tests/targets_under_test/apple/BUILD

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -665,31 +665,6 @@ apple_xcframework(
665665
deps = [":Swift3PFmwkWithGenHeader"],
666666
)
667667

668-
apple_xcframework(
669-
name = "ios_dynamic_xcframework_with_umbrella_header_conflict",
670-
bundle_id = "com.google.example",
671-
bundle_name = "UmbrellaHeaderConflict",
672-
# TODO(b/239957001): Remove this when the rule no longer forces library
673-
# evolution.
674-
features = ["apple.no_legacy_swiftinterface"],
675-
infoplists = [
676-
"//test/starlark_tests/resources:Info.plist",
677-
],
678-
ios = {
679-
"simulator": ["x86_64"],
680-
"device": ["arm64"],
681-
},
682-
minimum_os_versions = {
683-
"ios": common.min_os_ios.baseline,
684-
},
685-
public_hdrs = [
686-
"//test/starlark_tests/resources:shared.h",
687-
"//test/starlark_tests/resources:UmbrellaHeaderConflict.h",
688-
],
689-
tags = common.fixture_tags,
690-
deps = [":fmwk_lib"],
691-
)
692-
693668
apple_static_xcframework(
694669
name = "ios_static_xcframework_oldest_supported",
695670
# TODO(b/239957001): Remove this when the rule no longer forces library

test/starlark_tests/targets_under_test/ios/BUILD

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,21 +2895,6 @@ ios_static_framework(
28952895
deps = [":SwiftStaticFmwkWithGenHeader"],
28962896
)
28972897

2898-
ios_static_framework(
2899-
name = "static_framework_with_umbrella_header_conflict",
2900-
hdrs = [
2901-
"//test/starlark_tests/resources:UmbrellaHeaderConflict.h",
2902-
"//test/starlark_tests/resources:shared.h",
2903-
],
2904-
bundle_name = "UmbrellaHeaderConflict",
2905-
# TODO(b/239957001): Remove this when the rule no longer forces library
2906-
# evolution.
2907-
features = ["apple.no_legacy_swiftinterface"],
2908-
minimum_os_version = common.min_os_ios.baseline,
2909-
tags = common.fixture_tags,
2910-
deps = [":shared_lib"],
2911-
)
2912-
29132898
ios_static_framework(
29142899
name = "static_framework_from_objc_library",
29152900
# TODO(b/239957001): Remove this when the rule no longer forces library

0 commit comments

Comments
 (0)