Skip to content

Commit f3ca387

Browse files
committed
Add support for emit-extension-block-symbols flag
This flag can be used when emitting a symbol graph to additionally include the symbols from the extension blocks. This is useful when generating documentation with DocC so that the symbols from the extension blocks are included in the documentation.
1 parent 7c78ebc commit f3ca387

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

swift/internal/compiling.bzl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ load(
5353
"SWIFT_FEATURE_EMIT_SWIFTINTERFACE",
5454
"SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO",
5555
"SWIFT_FEATURE_EMIT_SYMBOL_GRAPH",
56+
"SWIFT_FEATURE_EMIT_SYMBOL_GRAPH_EXTENSION_BLOCKS",
5657
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
5758
"SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION",
5859
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES",
@@ -818,6 +819,16 @@ def compile_action_configs(
818819
],
819820
not_features = [SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION],
820821
),
822+
swift_toolchain_config.action_config(
823+
actions = [
824+
swift_action_names.COMPILE,
825+
],
826+
configurators = [_emit_symbol_graph_extension_blocks_configurator],
827+
features = [
828+
SWIFT_FEATURE_EMIT_SYMBOL_GRAPH,
829+
SWIFT_FEATURE_EMIT_SYMBOL_GRAPH_EXTENSION_BLOCKS,
830+
],
831+
),
821832
swift_toolchain_config.action_config(
822833
actions = [
823834
swift_action_names.DERIVE_FILES,
@@ -1960,6 +1971,12 @@ def _emit_symbol_graph_configurator(prerequisites, args):
19601971
prerequisites.symbol_graph_directory.path,
19611972
)
19621973

1974+
def _emit_symbol_graph_extension_blocks_configurator(_prerequisites, args):
1975+
args.add(
1976+
"-Xfrontend",
1977+
"-emit-extension-block-symbols",
1978+
)
1979+
19631980
def _global_index_store_configurator(prerequisites, args):
19641981
"""Adds flags for index-store generation to the command line."""
19651982
out_dir = prerequisites.indexstore_directory.dirname.split("/")[0]

swift/internal/feature_names.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ SWIFT_FEATURE_INDEX_WHILE_BUILDING = "swift.index_while_building"
110110
# If enabled, the compilation action for a target will produce a symbol graph.
111111
SWIFT_FEATURE_EMIT_SYMBOL_GRAPH = "swift.emit_symbol_graph"
112112

113+
# If enabled when `SWIFT_FEATURE_EMIT_SYMBOL_GRAPH` is enabled, emits symbols for extension code blocks.
114+
SWIFT_FEATURE_EMIT_SYMBOL_GRAPH_EXTENSION_BLOCKS = "swift.emit_symbol_graph_extension_blocks"
115+
113116
# If enabled the compilation action will not produce indexes for system modules.
114117
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX = "swift.disable_system_index"
115118

test/split_derived_files_tests.bzl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ default_no_split_swiftmodule_symbol_graph_test = make_action_command_line_test_r
130130
],
131131
},
132132
)
133+
default_no_split_swiftmodule_symbol_graph_extension_blocks_test = make_action_command_line_test_rule(
134+
config_settings = {
135+
"//command_line_option:features": [
136+
"swift.emit_symbol_graph",
137+
"swift.emit_symbol_graph_extension_blocks",
138+
],
139+
},
140+
)
133141

134142
def split_derived_files_test_suite(name):
135143
"""Test suite for split derived files options.
@@ -320,6 +328,21 @@ def split_derived_files_test_suite(name):
320328
"-emit-symbol-graph",
321329
"-emit-symbol-graph-dir",
322330
],
331+
not_expected_argv = [
332+
"-emit-extension-block-symbols",
333+
],
334+
mnemonic = "SwiftCompile",
335+
tags = [name],
336+
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
337+
)
338+
339+
default_no_split_swiftmodule_symbol_graph_extension_blocks_test(
340+
name = "{}_default_no_split_symbol_graph_extension_blocks_in_compile_action".format(name),
341+
expected_argv = [
342+
"-emit-symbol-graph",
343+
"-emit-symbol-graph-dir",
344+
"-emit-extension-block-symbols",
345+
],
323346
mnemonic = "SwiftCompile",
324347
tags = [name],
325348
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",

0 commit comments

Comments
 (0)