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

Fix "Add emit extension block symbols option to dump-symbol-graph and SymbolGraphOptions" #5985

Conversation

theMomax
Copy link
Contributor

This PR reintroduces support for emitting extension block symbols for the dump-symbol-graph command originally introduced by #5892 and reverted by #5975.

Reversion

The original PR #5892 was reverted because it caused a CMake build failure on Windows that hadn't been reported in the GitHub CI overview for the PR. This was fixed with 1de306b. #5978, which contains the exact same changes as this PR, already landed on main. However, due to an unrelated build failure in the toolchain (see comments on #5978), merging #5978 was delayed until after the Swift 5.8 branch off.

The following sections are taken from #5892 and should provide a good overview over the scope of this change and its impact on the Swift 5.8 release.

Motivation:

Extension block symbols with the respective command line flags -emit-extension-block-symbols and -omit-extension-block-symbols were introduced in swiftlang/swift#59047 and swiftlang/swift#61637 as part of an ongoing effort to solve apple/swift-docc#210. These flags should be exposed in higher-level commands such as swift package dump-symbol-graph as well as the package plugin API, so that users and package manager plugins such as apple/swift-docc-plugin can access them more easily. This PR is the last step before we can provide extension support in the DocC Package Plugin.

Modifications:

This PR adds the flag-pair --emit-extension-block-symbols/--omit-extension-block-symbols to the DumpSymbolGraph command and exposes the emitExtensionBlocks option in PluginToHostMessage.SymbolGraphOptions. SymbolGraphExtract was also extended by an emitExtensionBlockSymbols option and its extractSymbolGraph function adds the respective compiler command line flag accordingly.

Result:

swift package dump-symbol-graph --emit-extension-block-symbols dumps symbol graph files that extension block symbol format. The default behavior does not change. The --omit-extension-block-symbols flag will be used to explicitly disable the feature once the default behavior has been changed to --emit-extension-block-symbols in the future.

Package Plugins can specify the emitExtensionBlocks property requesting symbol graphs, e.g.:

import PackagePlugin

// ...
try getSymbolGraph(for: target, options: PackageManager.SymbolGraphOptions(
            minimumAccessLevel: targetMinimumAccessLevel,
            includeSynthesized: true,
            includeSPI: false,
            emitExtensionBlocks: true
        ))

The default behavior for package plugins also does not change.

@tomerd tomerd merged commit 26f5077 into swiftlang:release/5.8 Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift 5.8 This PR targets the 5.8 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants