Skip to content

Commit

Permalink
Only add "index-unit-output-path" in the output map for modular indexing
Browse files Browse the repository at this point in the history
Pre Xcode 14 you'll get a warning if this is specified without having indexing enabled:

```
<unknown>:0: warning: -index-unit-output-path is ignored without -index-store-path
```

We can reconsider this in the future (e.g. to automatically set this for Xcode 14+),
but for now limit the scope based on the modular indexing feature.

PiperOrigin-RevId: 480943677
  • Loading branch information
DavidGoldman authored and swiple-rules-gardener committed Oct 13, 2022
1 parent a5d5c2b commit c9b5002
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions swift/internal/compiling.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,21 @@ def _declare_compile_outputs(
user_compile_flags = user_compile_flags,
)

if is_feature_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE_INDEX_WHILE_BUILDING,
):
indexstore_directory = actions.declare_directory(
"{}.indexstore".format(target_name),
)
include_index_unit_paths = is_feature_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE_MODULAR_INDEXING,
)
else:
indexstore_directory = None
include_index_unit_paths = False

if not output_nature.emits_multiple_objects:
# If we're emitting a single object, we don't use an object map; we just
# declare the output file that the compiler will generate and there are
Expand All @@ -940,20 +955,11 @@ def _declare_compile_outputs(
actions = actions,
srcs = srcs,
target_name = target_name,
include_index_unit_paths = include_index_unit_paths,
)
object_files = output_info.object_files
output_file_map = output_info.output_file_map

if is_feature_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE_INDEX_WHILE_BUILDING,
):
indexstore_directory = actions.declare_directory(
"{}.indexstore".format(target_name),
)
else:
indexstore_directory = None

return struct(
generated_header_file = generated_header,
generated_module_map_file = generated_module_map,
Expand Down Expand Up @@ -1002,14 +1008,17 @@ def _index_unit_output_path(output_file):
def _declare_multiple_outputs_and_write_output_file_map(
actions,
srcs,
target_name):
target_name,
include_index_unit_paths):
"""Declares low-level outputs and writes the output map for a compilation.
Args:
actions: The object used to register actions.
srcs: The list of source files that will be compiled.
target_name: The name (excluding package path) of the target being
built.
include_index_unit_paths: Whether to include "index-unit-output-path" paths in the output
file map.
Returns:
A `struct` with the following fields:
Expand Down Expand Up @@ -1040,10 +1049,12 @@ def _declare_multiple_outputs_and_write_output_file_map(
src = src,
)
output_objs.append(obj)
output_map[src.path] = {
file_outputs = {
"object": obj.path,
"index-unit-output-path": _index_unit_output_path(obj),
}
if include_index_unit_paths:
file_outputs["index-unit-output-path"] = _index_unit_output_path(obj)
output_map[src.path] = file_outputs

actions.write(
content = json.encode(output_map),
Expand Down

1 comment on commit c9b5002

@brentleyjones
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.