Skip to content

Commit

Permalink
Factor out -index-ignore-system-modules into a separate feature.
Browse files Browse the repository at this point in the history
The feature has opposite polarity to the compiler flag, as we want it to be off by default and only enabled on certain targets.

PiperOrigin-RevId: 467693984
  • Loading branch information
allevato authored and swiple-rules-gardener committed Aug 15, 2022
1 parent 2a1a387 commit 14e066f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions swift/internal/feature_names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ SWIFT_FEATURE_DEBUG_PREFIX_MAP = "swift.debug_prefix_map"
# graph.
SWIFT_FEATURE_EMIT_C_MODULE = "swift.emit_c_module"

# If enabled alongside `swift.index_while_building`, the indexstore will also
# contain records for symbols in system modules imported by the code being
# indexed.
SWIFT_FEATURE_INDEX_SYSTEM_MODULES = "swift.index_system_modules"

# If enabled, the compilation action for a target will also produce an index
# store among its outputs.
SWIFT_FEATURE_INDEX_WHILE_BUILDING = "swift.index_while_building"
Expand Down
8 changes: 7 additions & 1 deletion swift/toolchains/config/compile_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ load(
"SWIFT_FEATURE_ENABLE_TESTING",
"SWIFT_FEATURE_FASTBUILD",
"SWIFT_FEATURE_FULL_DEBUG_INFO",
"SWIFT_FEATURE_INDEX_SYSTEM_MODULES",
"SWIFT_FEATURE_INDEX_WHILE_BUILDING",
"SWIFT_FEATURE_LAYERING_CHECK",
"SWIFT_FEATURE_MODULE_MAP_HOME_IS_CWD",
Expand Down Expand Up @@ -683,6 +684,12 @@ def compile_action_configs(
configurators = [_index_while_building_configurator],
features = [SWIFT_FEATURE_INDEX_WHILE_BUILDING],
),
ActionConfigInfo(
actions = [SWIFT_ACTION_COMPILE],
configurators = [add_arg("-index-ignore-system-modules")],
features = [SWIFT_FEATURE_INDEX_WHILE_BUILDING],
not_features = [SWIFT_FEATURE_INDEX_SYSTEM_MODULES],
),

# User-defined conditional compilation flags (defined for Swift; those
# passed directly to ClangImporter are handled above).
Expand Down Expand Up @@ -1184,7 +1191,6 @@ def _module_name_configurator(prerequisites, args):

def _index_while_building_configurator(prerequisites, args):
"""Adds flags for indexstore generation to the command line."""
args.add("-index-ignore-system-modules")
args.add("-index-store-path", prerequisites.indexstore_directory.path)

def _source_files_configurator(prerequisites, args):
Expand Down

1 comment on commit 14e066f

@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.