From 7c3a78104eee1e7353523efaf0f71ddb8e342ef3 Mon Sep 17 00:00:00 2001 From: Luis Padron Date: Wed, 19 Jun 2024 16:19:58 -0400 Subject: [PATCH] Remove emit symbol graph API 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: https://github.com/bazelbuild/rules_swift/pull/772 Rebase --- doc/api.md | 9 ++--- swift/internal/compiling.bzl | 57 ------------------------------ swift/internal/feature_names.bzl | 3 -- swift/internal/output_groups.bzl | 5 --- swift/internal/providers.bzl | 10 ++---- test/split_derived_files_tests.bzl | 48 ------------------------- 6 files changed, 4 insertions(+), 128 deletions(-) diff --git a/doc/api.md b/doc/api.md index b3196d36d..7a36b2bd0 100644 --- a/doc/api.md +++ b/doc/api.md @@ -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. @@ -471,7 +467,7 @@ A provider whose type/layout is an implementation detail and should not
 swift_common.create_swift_module(swiftdoc, swiftmodule, ast_files, defines, indexstore, plugins,
                                  swiftsourceinfo, swiftinterface, private_swiftinterface,
-                                 const_protocols_to_gather, symbol_graph)
+                                 const_protocols_to_gather)
 
Creates a value representing a Swift module use as a Swift dependency. @@ -491,12 +487,11 @@ Creates a value representing a Swift module use as a Swift dependency. | swiftinterface | The `.swiftinterface` file emitted by the compiler for this module. May be `None` if no module interface file was emitted. | `None` | | 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` | | 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`. | `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. diff --git a/swift/internal/compiling.bzl b/swift/internal/compiling.bzl index 3534b7cd5..32fbd8a88 100644 --- a/swift/internal/compiling.bzl +++ b/swift/internal/compiling.bzl @@ -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", @@ -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 @@ -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] @@ -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. @@ -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) @@ -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) @@ -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, ), ) @@ -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, ) @@ -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, @@ -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, diff --git a/swift/internal/feature_names.bzl b/swift/internal/feature_names.bzl index d9a6a9e27..6019d7c23 100644 --- a/swift/internal/feature_names.bzl +++ b/swift/internal/feature_names.bzl @@ -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" diff --git a/swift/internal/output_groups.bzl b/swift/internal/output_groups.bzl index 241197577..26ef79a15 100644 --- a/swift/internal/output_groups.bzl +++ b/swift/internal/output_groups.bzl @@ -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: @@ -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: @@ -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 diff --git a/swift/internal/providers.bzl b/swift/internal/providers.bzl index c9239ff46..b07c7e412 100644 --- a/swift/internal/providers.bzl +++ b/swift/internal/providers.bzl @@ -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: @@ -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( @@ -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( diff --git a/test/split_derived_files_tests.bzl b/test/split_derived_files_tests.bzl index 8808a6d4a..f95805403 100644 --- a/test/split_derived_files_tests.bzl +++ b/test/split_derived_files_tests.bzl @@ -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. @@ -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 = [