Skip to content

Commit

Permalink
Remove emit symbol graph API
Browse files Browse the repository at this point in the history
Removes the now old `emit_symbol_grah` feature in favor of the new `swift_symbol_graph_extract` rule which can be used to collec the symbol graph of Swift targets.

Depends on: #772
Rebase
  • Loading branch information
luispadron committed Jun 19, 2024
1 parent 6e48feb commit 7c3a781
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 128 deletions.
9 changes: 2 additions & 7 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ A tuple containing three elements:
the index store data generated by the compiler if the
`"swift.index_while_building"` feature is enabled, otherwise
this will be `None`.
* `symbol_graph`: A `File` representing the directory that
contains the symbol graph data generated by the compiler if the
`"swift.emit_symbol_graph"` feature is enabled, otherwise this
will be `None`.
* `const_values_files`: A list of `File`s that contains JSON
representations of constant values extracted from the source
files, if requested via a direct dependency.
Expand Down Expand Up @@ -471,7 +467,7 @@ A provider whose type/layout is an implementation detail and should not
<pre>
swift_common.create_swift_module(<a href="#swift_common.create_swift_module-swiftdoc">swiftdoc</a>, <a href="#swift_common.create_swift_module-swiftmodule">swiftmodule</a>, <a href="#swift_common.create_swift_module-ast_files">ast_files</a>, <a href="#swift_common.create_swift_module-defines">defines</a>, <a href="#swift_common.create_swift_module-indexstore">indexstore</a>, <a href="#swift_common.create_swift_module-plugins">plugins</a>,
<a href="#swift_common.create_swift_module-swiftsourceinfo">swiftsourceinfo</a>, <a href="#swift_common.create_swift_module-swiftinterface">swiftinterface</a>, <a href="#swift_common.create_swift_module-private_swiftinterface">private_swiftinterface</a>,
<a href="#swift_common.create_swift_module-const_protocols_to_gather">const_protocols_to_gather</a>, <a href="#swift_common.create_swift_module-symbol_graph">symbol_graph</a>)
<a href="#swift_common.create_swift_module-const_protocols_to_gather">const_protocols_to_gather</a>)
</pre>

Creates a value representing a Swift module use as a Swift dependency.
Expand All @@ -491,12 +487,11 @@ Creates a value representing a Swift module use as a Swift dependency.
| <a id="swift_common.create_swift_module-swiftinterface"></a>swiftinterface | The `.swiftinterface` file emitted by the compiler for this module. May be `None` if no module interface file was emitted. | `None` |
| <a id="swift_common.create_swift_module-private_swiftinterface"></a>private_swiftinterface | The `.private.swiftinterface` file emitted by the compiler for this module. May be `None` if no private module interface file was emitted. | `None` |
| <a id="swift_common.create_swift_module-const_protocols_to_gather"></a>const_protocols_to_gather | A list of protocol names from which constant values should be extracted from source code that takes this module as a *direct* dependency. | `[]` |
| <a id="swift_common.create_swift_module-symbol_graph"></a>symbol_graph | A `File` representing the directory that contains the symbol graph data generated by the compiler if the `"swift.emit_symbol_graph"` feature is enabled, otherwise this will be `None`. | `None` |

**RETURNS**

A `struct` containing the `ast_files`, `defines`, `indexstore,
`swiftdoc`, `swiftmodule`, `swiftinterface`, and `symbol_graph` fields
`swiftdoc`, `swiftmodule`, and `swiftinterface` fields
provided as arguments.


Expand Down
57 changes: 0 additions & 57 deletions swift/internal/compiling.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ load(
"SWIFT_FEATURE_EMIT_SWIFTDOC",
"SWIFT_FEATURE_EMIT_SWIFTINTERFACE",
"SWIFT_FEATURE_EMIT_SWIFTSOURCEINFO",
"SWIFT_FEATURE_EMIT_SYMBOL_GRAPH",
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
"SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION",
"SWIFT_FEATURE_ENABLE_SKIP_FUNCTION_BODIES",
Expand Down Expand Up @@ -849,26 +848,6 @@ def compile_action_configs(
SWIFT_FEATURE_USE_PCH_OUTPUT_DIR,
],
),
swift_toolchain_config.action_config(
actions = [
swift_action_names.COMPILE,
],
configurators = [_emit_symbol_graph_configurator],
features = [
SWIFT_FEATURE_EMIT_SYMBOL_GRAPH,
],
not_features = [SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION],
),
swift_toolchain_config.action_config(
actions = [
swift_action_names.DERIVE_FILES,
],
configurators = [_emit_symbol_graph_configurator],
features = [
SWIFT_FEATURE_EMIT_SYMBOL_GRAPH,
SWIFT_FEATURE_SPLIT_DERIVED_FILES_GENERATION,
],
),

# When using C modules, disable the implicit search for module map files
# because all of them, including system dependencies, will be provided
Expand Down Expand Up @@ -1999,21 +1978,6 @@ def _pch_output_dir_configurator(prerequisites, args):
paths.join(prerequisites.bin_dir.path, "_pch_output_dir"),
)

def _emit_symbol_graph_configurator(prerequisites, args):
"""Adds flags for `-emit-symbol-graph` configuration to the command line.
This is a directory to persist symbol graph files that can be used by
tools such as DocC or jazzy to generate documentation.
"""
args.add(
"-Xfrontend",
"-emit-symbol-graph",
)
args.add(
"-emit-symbol-graph-dir",
prerequisites.symbol_graph_directory.path,
)

def _global_index_store_configurator(prerequisites, args):
"""Adds flags for index-store generation to the command line."""
out_dir = prerequisites.indexstore_directory.dirname.split("/")[0]
Expand Down Expand Up @@ -2438,10 +2402,6 @@ def compile(
the index store data generated by the compiler if the
`"swift.index_while_building"` feature is enabled, otherwise
this will be `None`.
* `symbol_graph`: A `File` representing the directory that
contains the symbol graph data generated by the compiler if the
`"swift.emit_symbol_graph"` feature is enabled, otherwise this
will be `None`.
* `const_values_files`: A list of `File`s that contains JSON
representations of constant values extracted from the source
files, if requested via a direct dependency.
Expand Down Expand Up @@ -2510,7 +2470,6 @@ def compile(
# for that action). This guarantees some predictability.
compile_outputs.swiftmodule_file,
compile_outputs.generated_header_file,
compile_outputs.symbol_graph_directory,
]) + other_outputs
if include_swiftdoc:
all_derived_outputs.append(compile_outputs.swiftdoc_file)
Expand All @@ -2528,7 +2487,6 @@ def compile(
compile_outputs.generated_header_file,
compile_outputs.indexstore_directory,
compile_outputs.macro_expansion_directory,
compile_outputs.symbol_graph_directory,
]) + compile_outputs.object_files + compile_outputs.const_values_files + other_outputs
if include_swiftdoc:
all_compile_outputs.append(compile_outputs.swiftdoc_file)
Expand Down Expand Up @@ -2795,7 +2753,6 @@ to use swift_common.compile(include_dev_srch_paths = ...) instead.\
swiftmodule = compile_outputs.swiftmodule_file,
swiftsourceinfo = compile_outputs.swiftsourceinfo_file,
const_protocols_to_gather = compile_outputs.const_values_files,
symbol_graph = compile_outputs.symbol_graph_directory,
),
)

Expand All @@ -2808,7 +2765,6 @@ to use swift_common.compile(include_dev_srch_paths = ...) instead.\
ast_files = compile_outputs.ast_files,
indexstore = compile_outputs.indexstore_directory,
macro_expansion_directory = compile_outputs.macro_expansion_directory,
symbol_graph = compile_outputs.symbol_graph_directory,
const_values_files = compile_outputs.const_values_files,
)

Expand Down Expand Up @@ -3299,18 +3255,6 @@ def _declare_compile_outputs(
else:
indexstore_directory = None

emit_symbol_graph = is_feature_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE_EMIT_SYMBOL_GRAPH,
)
if (emit_symbol_graph):
symbol_graph_directory = derived_files.symbol_graph_directory(
actions = actions,
target_name = target_name,
)
else:
symbol_graph_directory = None

if is_feature_enabled(
feature_configuration = feature_configuration,
feature_name = SWIFT_FEATURE__SUPPORTS_MACROS,
Expand All @@ -3332,7 +3276,6 @@ def _declare_compile_outputs(
indexstore_directory = indexstore_directory,
macro_expansion_directory = macro_expansion_directory,
private_swiftinterface_file = private_swiftinterface_file,
symbol_graph_directory = symbol_graph_directory,
object_files = object_files,
output_file_map = output_file_map,
derived_files_output_file_map = derived_files_output_file_map,
Expand Down
3 changes: 0 additions & 3 deletions swift/internal/feature_names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ SWIFT_FEATURE_CODEVIEW_DEBUG_INFO = "swift.codeview_debug_info"
# https://docs.google.com/document/d/1cH2sTpgSnJZCkZtJl1aY-rzy4uGPcrI-6RrUpdATO2Q/
SWIFT_FEATURE_INDEX_WHILE_BUILDING = "swift.index_while_building"

# If enabled, the compilation action for a target will produce a symbol graph.
SWIFT_FEATURE_EMIT_SYMBOL_GRAPH = "swift.emit_symbol_graph"

# If enabled the compilation action will not produce indexes for system modules.
SWIFT_FEATURE_DISABLE_SYSTEM_INDEX = "swift.disable_system_index"

Expand Down
5 changes: 0 additions & 5 deletions swift/internal/output_groups.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def supplemental_compilation_output_groups(*supplemental_outputs):
const_values_files = []
indexstore_files = []
macro_expansions_files = []
symbol_graph_files = []

for outputs in supplemental_outputs:
if outputs.ast_files:
Expand All @@ -46,8 +45,6 @@ def supplemental_compilation_output_groups(*supplemental_outputs):
indexstore_files.append(outputs.indexstore)
if outputs.macro_expansion_directory:
macro_expansions_files.append(outputs.macro_expansion_directory)
if outputs.symbol_graph:
symbol_graph_files.append(outputs.symbol_graph)

output_groups = {}
if ast_files:
Expand All @@ -58,6 +55,4 @@ def supplemental_compilation_output_groups(*supplemental_outputs):
output_groups["swift_index_store"] = depset(indexstore_files)
if macro_expansions_files:
output_groups["macro_expansions"] = depset(macro_expansions_files)
if symbol_graph_files:
output_groups["swift_symbol_graph"] = depset(symbol_graph_files)
return output_groups
10 changes: 2 additions & 8 deletions swift/internal/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ def create_swift_module(
swiftsourceinfo = None,
swiftinterface = None,
private_swiftinterface = None,
const_protocols_to_gather = [],
symbol_graph = None):
const_protocols_to_gather = []):
"""Creates a value representing a Swift module use as a Swift dependency.
Args:
Expand All @@ -490,14 +489,10 @@ def create_swift_module(
const_protocols_to_gather: A list of protocol names from which constant
values should be extracted from source code that takes this module
as a *direct* dependency.
symbol_graph: A `File` representing the directory that contains the
symbol graph data generated by the compiler if the
`"swift.emit_symbol_graph"` feature is enabled, otherwise this will
be `None`.
Returns:
A `struct` containing the `ast_files`, `defines`, `indexstore,
`swiftdoc`, `swiftmodule`, `swiftinterface`, and `symbol_graph` fields
`swiftdoc`, `swiftmodule`, and `swiftinterface` fields
provided as arguments.
"""
return struct(
Expand All @@ -511,7 +506,6 @@ def create_swift_module(
swiftmodule = swiftmodule,
swiftsourceinfo = swiftsourceinfo,
const_protocols_to_gather = tuple(const_protocols_to_gather),
symbol_graph = symbol_graph,
)

def create_swift_info(
Expand Down
48 changes: 0 additions & 48 deletions test/split_derived_files_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,6 @@ split_swiftmodule_copts_test = make_action_command_line_test_rule(
],
},
)
split_swiftmodule_symbol_graph_test = make_action_command_line_test_rule(
config_settings = {
"//command_line_option:features": [
"swift.emit_symbol_graph",
"swift.split_derived_files_generation",
],
},
)
default_no_split_swiftmodule_symbol_graph_test = make_action_command_line_test_rule(
config_settings = {
"//command_line_option:features": [
"swift.emit_symbol_graph",
],
},
)

def split_derived_files_test_suite(name):
"""Test suite for split derived files options.
Expand Down Expand Up @@ -292,39 +277,6 @@ def split_derived_files_test_suite(name):
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

split_swiftmodule_symbol_graph_test(
name = "{}_symbol_graph_in_derive_action".format(name),
expected_argv = [
"-emit-symbol-graph",
"-emit-symbol-graph-dir",
],
mnemonic = "SwiftDeriveFiles",
tags = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

split_swiftmodule_symbol_graph_test(
name = "{}_no_symbol_graph_in_compile_action".format(name),
not_expected_argv = [
"-emit-symbol-graph",
"-emit-symbol-graph-dir",
],
mnemonic = "SwiftCompile",
tags = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

default_no_split_swiftmodule_symbol_graph_test(
name = "{}_default_no_split_symbol_graph_in_compile_action".format(name),
expected_argv = [
"-emit-symbol-graph",
"-emit-symbol-graph-dir",
],
mnemonic = "SwiftCompile",
tags = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

split_swiftmodule_test(
name = "{}_swiftmodule_only".format(name),
expected_argv = [
Expand Down

0 comments on commit 7c3a781

Please sign in to comment.