Skip to content

Commit 442deb8

Browse files
Depend on --experimental_remote_download_regex for Index Build input collection in incremental generation mode (#2859)
1 parent 8c6168f commit 442deb8

File tree

7 files changed

+105
-214
lines changed

7 files changed

+105
-214
lines changed

xcodeproj/internal/bazel_integration_files/generate_bazel_dependencies.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ else
2222
# Inputs for compiling, inputs for linking, and index store data
2323
readonly output_group_prefixes="xc,xl,xi"
2424
elif [[ "${ENABLE_PREVIEWS:-}" == "YES" ]]; then
25-
# Compiled outputs (i.e. swiftmodules) and generated inputs, products (i.e.
26-
# bundles), index store data, and link params
25+
# Compile params, products (i.e. bundles) and index store data, and link
26+
# params
27+
# TODO: Remove `bi` once we remove support for legacy generation mode
2728
readonly output_group_prefixes="bc,bp,bi,bl"
2829
else
29-
# Compiled outputs (i.e. swiftmodules) and generated
30-
# inputs, products (i.e. bundles), and index store data
30+
# Products (i.e. bundles) and index store data
31+
# TODO: Remove `bc` and `bi` once we remove support for legacy generation
32+
# mode
3133
readonly output_group_prefixes="bc,bp,bi"
3234
fi
3335

@@ -108,7 +110,18 @@ fi
108110
# Build
109111

110112
build_pre_config_flags=(
111-
"--experimental_remote_download_regex=.*\.indexstore/.*|.*\.a$|.*\.swiftdoc$|.*\.swiftmodule$|.*\.swiftsourceinfo$|.*\.swift$"
113+
# Include the following:
114+
#
115+
# - .indexstore directories to allow importing indexes
116+
# - .swift{doc,sourceinfo} files for indexing
117+
# - .a and .swiftmodule files for lldb
118+
# - primary compilation input files (.c, .C, .cc, .cl, .cpp, .cu, .cxx, .c++,
119+
# .m, .mm, .swift) for Xcode build input checking
120+
#
121+
# This is brittle. If different file extensions are used for compilation
122+
# inputs, they will need to be added to this list. Ideally we can stop doing
123+
# this once Bazel adds support for a Remote Output Service.
124+
"--experimental_remote_download_regex=.*\.indexstore/.*|.*\.(a|c|C|cc|cl|cpp|cu|cxx|c++|m|mm|swift|swiftdoc|swiftmodule|swiftsourceinfo)$"
112125
)
113126

114127
apply_sanitizers=1

xcodeproj/internal/bazel_integration_files/generate_index_build_bazel_dependencies.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ readonly config="${BAZEL_CONFIG}_indexbuild"
2323
# Compiled outputs (i.e. swiftmodules) and generated inputs
2424
readonly output_groups=(
2525
"index_import"
26+
# Compile params
2627
"bc $BAZEL_TARGET_ID"
28+
# Products (i.e. bundles) and index store data. The products themselves aren't
29+
# used, they cause transitive files to be created. We use
30+
# `--experimental_remote_download_regex` below to collect the files we care
31+
# about.
32+
"bp $BAZEL_TARGET_ID"
33+
# TODO: Remove `bi` once we remove support for legacy generation mode
2734
"bi $BAZEL_TARGET_ID"
2835
)
2936

@@ -43,7 +50,18 @@ if [[ "$BAZEL_TARGET_ID" =~ $targetid_regex ]]; then
4350
fi
4451

4552
readonly build_pre_config_flags=(
46-
"--experimental_remote_download_regex=.*\.indexstore/.*|.*\.a$|.*\.swiftdoc$|.*\.swiftmodule$|.*\.swiftsourceinfo$|.*\.swift$"
53+
# Include the following:
54+
#
55+
# - .indexstore directories to allow importing indexes
56+
# - .swift{doc,module,sourceinfo} files for indexing
57+
# - compilation input files (.cfg, .c, .C .cc, .cl, .cpp, .cu, .cxx, .c++,
58+
# .def, .h, .H, .hh, .hpp, .hxx, .h++, .hmap, .ilc, .inc, .ipp, .tcc, .tlh,
59+
# .tpp, .m, .modulemap, .mm, .pch, .swift, .yaml) for index compilation
60+
#
61+
# This is brittle. If different file extensions are used for compilation
62+
# inputs, they will need to be added to this list. Ideally we can stop doing
63+
# this once Bazel adds support for a Remote Output Service.
64+
"--experimental_remote_download_regex=.*\.indexstore/.*|.*\.(cfg|c|C|cc|cl|cpp|cu|cxx|c++|def|h|H|hh|hpp|hxx|h++|hmap|ilc|inc|ipp|tcc|tlh|tpp|m|modulemap|mm|pch|swift|swiftdoc|swiftmodule|swiftsourceinfo|yaml)$"
4765
)
4866

4967
source "$BAZEL_INTEGRATION_DIR/bazel_build.sh"

xcodeproj/internal/files/incremental_input_files.bzl

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def _collect_transitive_uncategorized(info):
4040

4141
def _inner_merge_input_files(
4242
*,
43-
generated,
4443
resource_bundles,
4544
transitive_infos,
4645
xccurrentversions):
@@ -63,13 +62,6 @@ def _inner_merge_input_files(
6362
for info in transitive_infos
6463
],
6564
),
66-
generated = memory_efficient_depset(
67-
generated,
68-
transitive = [
69-
info.inputs.generated
70-
for info in transitive_infos
71-
],
72-
),
7365
resource_bundles = memory_efficient_depset(
7466
resource_bundles,
7567
transitive = [
@@ -112,11 +104,9 @@ def _should_ignore_input_attr(attr):
112104
attr in _IGNORE_ATTR
113105
)
114106

115-
def _process_cc_info_headers(headers, *, exclude_headers, generated):
107+
def _process_cc_info_headers(headers, *, exclude_headers):
116108
def _process_header(header_file):
117109
exclude_headers[header_file] = None
118-
if not header_file.is_source:
119-
generated.append(header_file)
120110
return header_file
121111

122112
files = []
@@ -136,7 +126,6 @@ def _process_files_and_deps(
136126
collect_uncategorized,
137127
extra_files,
138128
file_handlers,
139-
generated,
140129
rule_attr,
141130
rule_file,
142131
rule_files):
@@ -167,8 +156,6 @@ def _process_files_and_deps(
167156
xccurrentversions.append(file)
168157
else:
169158
uncategorized.append(file)
170-
elif categorized:
171-
generated.append(file)
172159

173160
transitive_extra_files = []
174161

@@ -233,21 +220,18 @@ def _process_files_and_deps(
233220
_process_cc_info_headers(
234221
compilation_context.direct_private_headers,
235222
exclude_headers = categorized_files,
236-
generated = generated,
237223
),
238224
)
239225
extra_files.extend(
240226
_process_cc_info_headers(
241227
compilation_context.direct_public_headers,
242228
exclude_headers = categorized_files,
243-
generated = generated,
244229
),
245230
)
246231
extra_files.extend(
247232
_process_cc_info_headers(
248233
compilation_context.direct_textual_headers,
249234
exclude_headers = categorized_files,
250-
generated = generated,
251235
),
252236
)
253237

@@ -356,8 +340,6 @@ def _collect_incremental_input_files(
356340
* A `struct`, which will end up in `XcodeProjInfo.inputs`, with the
357341
following fields:
358342
359-
* `generated`: A `depset` of generated `File`s that are inputs to
360-
`target` or its transitive dependencies.
361343
* `important_generated`: A `depset` of important generated `File`s
362344
that are inputs to `target` or its transitive dependencies.
363345
These differ from `generated` in that they will be generated as
@@ -375,7 +357,6 @@ def _collect_incremental_input_files(
375357
entitlements = []
376358
c_sources = {}
377359
cxx_sources = {}
378-
generated = []
379360
non_arc_srcs = []
380361
srcs = []
381362

@@ -474,7 +455,6 @@ def _collect_incremental_input_files(
474455
),
475456
extra_files = extra_files,
476457
file_handlers = file_handlers,
477-
generated = generated,
478458
rule_attr = rule_attr,
479459
rule_file = ctx.rule.file,
480460
rule_files = ctx.rule.files,
@@ -497,11 +477,6 @@ def _collect_incremental_input_files(
497477
for file in linker_input_additional_files
498478
if file not in framework_files
499479
]
500-
generated.extend([
501-
file
502-
for file in linker_input_additional_files
503-
if not file.is_source
504-
])
505480
extra_files.extend(linker_input_additional_files)
506481

507482
if resource_info:
@@ -521,7 +496,6 @@ def _collect_incremental_input_files(
521496
resources = memory_efficient_depset(resources_result.resources)
522497
resource_bundles = resources_result.bundles
523498

524-
generated.extend(resources_result.generated)
525499
xccurrentversions.extend(resources_result.xccurrentversions)
526500

527501
resource_bundle_labels = memory_efficient_depset(
@@ -573,14 +547,6 @@ def _collect_incremental_input_files(
573547
if not file.is_source
574548
]
575549

576-
generated_depset = memory_efficient_depset(
577-
generated,
578-
transitive = [
579-
info.inputs.generated
580-
for info in transitive_infos
581-
],
582-
)
583-
584550
label_str = str(label)
585551

586552
return (
@@ -626,7 +592,6 @@ def _collect_incremental_input_files(
626592
for info in transitive_infos
627593
],
628594
),
629-
generated = generated_depset,
630595
important_generated = memory_efficient_depset(
631596
important_generated,
632597
transitive = [
@@ -678,7 +643,6 @@ def _collect_unsupported_input_files(
678643
679644
A value similar to the second `struct` returned by `input_files.collect`.
680645
"""
681-
generated = []
682646
extra_file_paths = []
683647
extra_files = []
684648

@@ -718,7 +682,6 @@ def _collect_unsupported_input_files(
718682
),
719683
extra_files = extra_files,
720684
file_handlers = file_handlers,
721-
generated = generated,
722685
rule_attr = rule_attr,
723686
rule_file = ctx.rule.file,
724687
rule_files = ctx.rule.files,
@@ -765,13 +728,6 @@ def _collect_unsupported_input_files(
765728
for info in transitive_infos
766729
],
767730
),
768-
generated = memory_efficient_depset(
769-
generated,
770-
transitive = [
771-
info.inputs.generated
772-
for info in transitive_infos
773-
],
774-
),
775731
important_generated = memory_efficient_depset(
776732
transitive = [
777733
info.inputs.important_generated
@@ -800,21 +756,19 @@ def _collect_unsupported_input_files(
800756
),
801757
)
802758

803-
def _merge_input_files(*, extra_generated = None, transitive_infos):
759+
def _merge_input_files(*, transitive_infos):
804760
"""Creates merged inputs.
805761
806762
Args:
807-
extra_generated: An optional `list` of `File`s to added to `generated`.
808763
transitive_infos: A `list` of `XcodeProjInfo`s for the transitive
809764
dependencies of the current target.
810765
811766
Returns:
812767
A value similar to the one returned from `input_files.collect`. The
813768
values potentially include the inputs of the transitive dependencies,
814-
via `transitive_infos` (e.g. `generated` and `extra_files`).
769+
via `transitive_infos` (e.g. `extra_files`).
815770
"""
816771
return _inner_merge_input_files(
817-
generated = extra_generated,
818772
resource_bundles = None,
819773
transitive_infos = transitive_infos,
820774
xccurrentversions = None,
@@ -840,7 +794,7 @@ def _merge_top_level_input_files(
840794
Returns:
841795
A value similar to the one returned from `input_files.collect`. The
842796
values potentially include the inputs of the transitive dependencies,
843-
via `transitive_infos` (e.g. `generated` and `extra_files`).
797+
via `transitive_infos` (e.g. `extra_files`).
844798
"""
845799
if resource_info:
846800
resources_result = resources_module.collect(
@@ -853,17 +807,14 @@ def _merge_top_level_input_files(
853807
],
854808
)
855809

856-
generated = resources_result.generated
857810
resource_bundles = resources_result.bundles
858811

859812
xccurrentversions = resources_result.xccurrentversions
860813
else:
861-
generated = None
862814
resource_bundles = None
863815
xccurrentversions = None
864816

865817
return _inner_merge_input_files(
866-
generated = generated,
867818
resource_bundles = resource_bundles,
868819
transitive_infos = transitive_infos,
869820
xccurrentversions = xccurrentversions,

0 commit comments

Comments
 (0)