Skip to content

Commit c9e0c15

Browse files
Adjust hdrs collection to exclusively use compilation_context (#601)
This fixes issues where generated files were used with rules like `apple_static_framework_import`. If a `apple_static_framework_import` doesn't have any headers, but the archive is generated, we will still run into an issue. To resolve that we need to adjust `linker_input_files` to add `static_framework_file`, `library`, and the like to inputs. That's for a later change (probably merging `input_files` and `linker_inputs` into one module).
1 parent ccadb6f commit c9e0c15

File tree

7 files changed

+35
-42
lines changed

7 files changed

+35
-42
lines changed

examples/ios_app/test/fixtures/bwb_spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,8 +1168,8 @@
11681168
"info_plist": null,
11691169
"inputs": {
11701170
"hdrs": [
1171-
"Utils/Foo.h",
1172-
"Utils/Utils.h"
1171+
"Utils/Utils.h",
1172+
"Utils/Foo.h"
11731173
],
11741174
"srcs": [
11751175
"Utils/Foo.m"

examples/ios_app/test/fixtures/bwx_spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,8 +1183,8 @@
11831183
"info_plist": null,
11841184
"inputs": {
11851185
"hdrs": [
1186-
"Utils/Foo.h",
1187-
"Utils/Utils.h"
1186+
"Utils/Utils.h",
1187+
"Utils/Foo.h"
11881188
],
11891189
"srcs": [
11901190
"Utils/Foo.m"

test/fixtures/command_line/bwb_spec.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"configuration": "darwin_x86_64-fastbuild-ST-d53d69b6b8c1",
1414
"extra_files": [
1515
"examples/command_line/lib/BUILD",
16+
{
17+
"_": "examples_command_line_external/ExternalFramework.framework",
18+
"t": "e"
19+
},
1620
{
1721
"_": "examples_command_line_external/ImportableLibrary/Library.h",
1822
"t": "e"
@@ -21,10 +25,6 @@
2125
"_": "macos-x86_64-min11.0-applebin_macos-darwin_x86_64-dbg-ST-0139d977e630/bin/examples/command_line/lib/lib_impl.swift.modulemap",
2226
"t": "g"
2327
},
24-
{
25-
"_": "examples_command_line_external/ExternalFramework.framework",
26-
"t": "e"
27-
},
2828
{
2929
"_": "macos-x86_64-min11.0-applebin_macos-darwin_x86_64-dbg-ST-0139d977e630/bin/external/examples_command_line_external/Library.swift.modulemap",
3030
"t": "g"
@@ -35,6 +35,7 @@
3535
},
3636
"examples/command_line/lib/dir with space/lib.h",
3737
"examples/command_line/third_party/BUILD",
38+
"examples/command_line/third_party/ExampleFramework.framework",
3839
"examples/command_line/tool/BUILD",
3940
"examples/command_line/tool/Info.plist",
4041
"examples/command_line/Tests/BUILD",

test/fixtures/command_line/bwx_spec.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"configuration": "darwin_x86_64-fastbuild-ST-d53d69b6b8c1",
1414
"extra_files": [
1515
"examples/command_line/lib/BUILD",
16+
{
17+
"_": "examples_command_line_external/ExternalFramework.framework",
18+
"t": "e"
19+
},
1620
{
1721
"_": "examples_command_line_external/ImportableLibrary/Library.h",
1822
"t": "e"
@@ -21,10 +25,6 @@
2125
"_": "macos-x86_64-min11.0-applebin_macos-darwin_x86_64-dbg-ST-59a3e2f8ef60/bin/examples/command_line/lib/lib_impl.swift.modulemap",
2226
"t": "g"
2327
},
24-
{
25-
"_": "examples_command_line_external/ExternalFramework.framework",
26-
"t": "e"
27-
},
2828
{
2929
"_": "macos-x86_64-min11.0-applebin_macos-darwin_x86_64-dbg-ST-59a3e2f8ef60/bin/external/examples_command_line_external/Library.swift.modulemap",
3030
"t": "g"
@@ -35,6 +35,7 @@
3535
},
3636
"examples/command_line/lib/dir with space/lib.h",
3737
"examples/command_line/third_party/BUILD",
38+
"examples/command_line/third_party/ExampleFramework.framework",
3839
"examples/command_line/tool/BUILD",
3940
"examples/command_line/tool/Info.plist",
4041
"examples/command_line/Tests/BUILD",

xcodeproj/internal/default_automatic_target_processing_aspect.bzl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def _default_automatic_target_processing_aspect_impl(target, ctx):
5252
srcs = ()
5353

5454
non_arc_srcs = ()
55-
hdrs = ()
5655
pch = None
5756
bundle_id = None
5857
provisioning_profile = None
@@ -66,14 +65,12 @@ def _default_automatic_target_processing_aspect_impl(target, ctx):
6665
"deps": [target_type.compile],
6766
"interface_deps": [target_type.compile],
6867
}
69-
hdrs = ("hdrs", "textual_hdrs")
7068
elif ctx.rule.kind == "objc_library":
7169
xcode_targets = {
7270
"deps": [target_type.compile],
7371
"runtime_deps": [target_type.compile],
7472
}
7573
non_arc_srcs = ("non_arc_srcs")
76-
hdrs = ("hdrs", "textual_hdrs")
7774
pch = "pch"
7875
elif ctx.rule.kind == "swift_library":
7976
xcode_targets = {
@@ -120,7 +117,6 @@ def _default_automatic_target_processing_aspect_impl(target, ctx):
120117
xcode_targets = xcode_targets,
121118
non_arc_srcs = non_arc_srcs,
122119
srcs = srcs,
123-
hdrs = hdrs,
124120
pch = pch,
125121
bundle_id = bundle_id,
126122
provisioning_profile = provisioning_profile,

xcodeproj/internal/input_files.bzl

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ def _is_categorized_attr(attr, *, automatic_target_info):
7474
return True
7575
elif attr in automatic_target_info.non_arc_srcs:
7676
return True
77-
elif attr in automatic_target_info.hdrs:
78-
return True
7977
elif attr == automatic_target_info.pch:
8078
return True
8179
elif attr in automatic_target_info.infoplists:
@@ -85,13 +83,16 @@ def _is_categorized_attr(attr, *, automatic_target_info):
8583
else:
8684
return False
8785

88-
def _process_cc_info_headers(headers, *, pch):
86+
def _process_cc_info_headers(headers, *, output_files, pch, generated):
87+
def _process_header(header):
88+
if not header.is_source:
89+
generated.append(header)
90+
return header
91+
8992
return [
90-
header
93+
_process_header(header)
9194
for header in headers
92-
if (header.is_source and
93-
".framework" not in header.path and
94-
header not in pch)
95+
if header not in pch and header not in output_files
9596
]
9697

9798
# API
@@ -176,8 +177,6 @@ def _collect(
176177
srcs.append(file)
177178
elif attr in automatic_target_info.non_arc_srcs:
178179
non_arc_srcs.append(file)
179-
elif attr in automatic_target_info.hdrs:
180-
hdrs.append(file)
181180
elif attr == automatic_target_info.pch:
182181
# We use `append` instead of setting a single value because
183182
# assigning to `pch` creates a new local variable instead of
@@ -275,19 +274,19 @@ def _collect(
275274
# headers from `objc_import` and the like.
276275
if CcInfo in target:
277276
compilation_context = target[CcInfo].compilation_context
278-
srcs.extend(
279-
_process_cc_info_headers(
280-
compilation_context.direct_private_headers,
281-
pch = pch,
282-
),
283-
)
284-
hdrs.extend(
285-
_process_cc_info_headers(
286-
(compilation_context.direct_public_headers +
287-
compilation_context.direct_textual_headers),
288-
pch = pch,
289-
),
290-
)
277+
srcs.extend(_process_cc_info_headers(
278+
compilation_context.direct_private_headers,
279+
output_files = output_files,
280+
pch = pch,
281+
generated = generated,
282+
))
283+
hdrs.extend(_process_cc_info_headers(
284+
(compilation_context.direct_public_headers +
285+
compilation_context.direct_textual_headers),
286+
output_files = output_files,
287+
pch = pch,
288+
generated = generated,
289+
))
291290

292291
return struct(
293292
srcs = depset(srcs),

xcodeproj/internal/providers.bzl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ An attribute name (or `None`) to collect `File`s from for the
2727
"infoplists": """\
2828
A sequence of attribute names to collect `File`s from for the `infoplists`-like
2929
attributes.
30-
""",
31-
"hdrs": """\
32-
A sequence of attribute names to collect `File`s from for the `hdrs`-like
33-
attributes.
3430
""",
3531
"non_arc_srcs": """\
3632
A sequence of attribute names to collect `File`s from for `non_arc_srcs`-like

0 commit comments

Comments
 (0)