Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update extract symbol graphs rule to include swiftdoc #1286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions swift/internal/symbol_graph_extracting.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,20 @@ def extract_symbol_graph(
# conditionally.
transitive_modules = merged_swift_info.transitive_modules.to_list()

direct_swiftdocs = []
transitive_swiftmodules = []
for module in transitive_modules:
swift_module = module.swift
if swift_module:
transitive_swiftmodules.append(swift_module.swiftmodule)
if module.name == module_name and swift_module.swiftdoc:
direct_swiftdocs.append(swift_module.swiftdoc)

prerequisites = struct(
bin_dir = feature_configuration._bin_dir,
cc_compilation_context = merged_compilation_context,
developer_dirs = swift_toolchain.developer_dirs,
direct_swiftdocs = direct_swiftdocs,
emit_extension_block_symbols = emit_extension_block_symbols,
genfiles_dir = feature_configuration._genfiles_dir,
include_dev_srch_paths = include_dev_srch_paths,
Expand Down
21 changes: 21 additions & 0 deletions swift/toolchains/config/compile_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ load(
"SWIFT_FEATURE_DISABLE_SYSTEM_INDEX",
"SWIFT_FEATURE_EMIT_BC",
"SWIFT_FEATURE_EMIT_PRIVATE_SWIFTINTERFACE",
"SWIFT_FEATURE_EMIT_SWIFTDOC",
"SWIFT_FEATURE_EMIT_SWIFTINTERFACE",
"SWIFT_FEATURE_ENABLE_BATCH_MODE",
"SWIFT_FEATURE_ENABLE_LIBRARY_EVOLUTION",
Expand Down Expand Up @@ -815,9 +816,15 @@ def compile_action_configs(

# swift-symbolgraph-extract doesn't yet support explicit Swift module
# maps.
ActionConfigInfo(
actions = [SWIFT_ACTION_SYMBOL_GRAPH_EXTRACT],
configurators = [_dependencies_swiftmodules_and_swiftdocs_configurator],
features = [SWIFT_FEATURE_EMIT_SWIFTDOC],
brentleyjones marked this conversation as resolved.
Show resolved Hide resolved
),
ActionConfigInfo(
actions = [SWIFT_ACTION_SYMBOL_GRAPH_EXTRACT],
configurators = [_dependencies_swiftmodules_configurator],
not_features = [SWIFT_FEATURE_EMIT_SWIFTDOC],
),
])

Expand Down Expand Up @@ -1671,6 +1678,20 @@ def _swift_module_search_path_map_fn(module):
else:
return None

def _dependencies_swiftmodules_and_swiftdocs_configurator(prerequisites, args):
"""Adds `.swiftmodule` and `.swiftdoc` files from the transitive modules to search paths and action inputs."""
args.add_all(
prerequisites.transitive_modules,
format_each = "-I%s",
map_each = _swift_module_search_path_map_fn,
uniquify = True,
)

return ConfigResultInfo(
inputs = prerequisites.transitive_swiftmodules +
prerequisites.direct_swiftdocs,
)

def _dependencies_swiftmodules_configurator(prerequisites, args):
"""Adds `.swiftmodule` files from deps to search paths and action inputs."""
args.add_all(
Expand Down