-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Make the symbol graph extraction requested by plugins more robust #3993
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
Conversation
@swift-ci smoke test |
54cafa6
to
ad13f0a
Compare
@swift-ci smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few suggestions
|
||
print("-- Emitting symbol graph for", target.name) | ||
try runTool(args) | ||
try localFileSystem.createDirectory(outputDirectory, recursive: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this support abstract file system instead of assuming local?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the tool only works locally there didn't seem to be much point, and could be misleading since only the local file system will work.
// Create a sample package with a library, and executable, and a plugin. | ||
let packageDir = tmpPath.appending(components: "MyPackage") | ||
try localFileSystem.writeFileContents(packageDir.appending(components: "Package.swift")) { | ||
$0 <<< """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can now pass string directly, o need to go through the byte stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I didn't realize. All the other tests use the stream, but I can change this one over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a subtle difference, where for the block-and-stream version, the parent directory of the output file is automatically created, but for the others (string, bytes, etc) it's not. I'm inclined to leave this as is just in the interesting of getting more bugs fixed and then deal with all the tests in a separate PR, possibly also modifying the other calls to at least optionally create the parent directories of the output file.
…in the context of plugins. This includes parameterizing the output that's printed and the output path, and applying the extractor to a target at a time and not always to all the targets in a package. The original behavior for the `dump-symbol-graph` command is unmodified, but some of the specifics are hoisted into the DumpSymbolGraph command implementation rather than in the reusable SymbolGraphExtract type.
…SymbolGraphExtract: - only generate symbol graph information for the specified target - use a unique symbol graph output directory for each package/target combination Also add a unit test to check these things. rdar://87234110&86785765
- change output format to an enumeration - change verbosity to log level to avoid using the global
ad13f0a
to
9dd86bb
Compare
@swift-ci smoke test |
Error is:
I'm going to have to think about the best way of fixing this one — it's only an issue during testing, but it would be better to have the tests always running rather than conditionalize on availability of this tool. It looks like It doesn't seem that we had any previous unit tests for the |
…iler that hasn't built the `swift-symbolgraph-extract` tool. There is a `SWIFT_SYMBOLGRAPH_EXTRACT` env var that could be used to point it another binary, but on platforms other than macOS we don't have an existing Xcode or anything that would be guaranteed to contain this tool. This test should still run on full builds and on self tests, where the tool is available.
@swift-ci smoke test |
I ended up making the test conditional on the presence of the |
…iftlang#3993) * Rework the SymbolGraphExtract so it's more suitable for being called in the context of plugins. This includes parameterizing the output format and the output path, as well as the diagnostics that are printed, and applying the extractor to a target at a time and not always to all the targets in a package. The original behavior for the `dump-symbol-graph` command is unmodified, but some of the specifics are hoisted into the DumpSymbolGraph command implementation rather than in the reusable SymbolGraphExtract type. * Make the symbol graph generation more robust by using the refactored SymbolGraphExtract: - only generate symbol graph information for the specified target - use a unique symbol graph output directory for each package/target combination - added a unit test to check these things. * Skip the test in a bootstrap situation where we're using a Swift compiler that hasn't built the `swift-symbolgraph-extract` tool. There is a `SWIFT_SYMBOLGRAPH_EXTRACT` env var that could be used to point it another binary, but on platforms other than macOS we don't have an existing Xcode or anything that would be guaranteed to contain this tool. This test should still run on full builds and on self tests, where the tool is available. rdar://87234110&86785765 (cherry picked from commit 850c772)
) (#3998) * Rework the SymbolGraphExtract so it's more suitable for being called in the context of plugins. This includes parameterizing the output format and the output path, as well as the diagnostics that are printed, and applying the extractor to a target at a time and not always to all the targets in a package. The original behavior for the `dump-symbol-graph` command is unmodified, but some of the specifics are hoisted into the DumpSymbolGraph command implementation rather than in the reusable SymbolGraphExtract type. * Make the symbol graph generation more robust by using the refactored SymbolGraphExtract: - only generate symbol graph information for the specified target - use a unique symbol graph output directory for each package/target combination - added a unit test to check these things. * Skip the test in a bootstrap situation where we're using a Swift compiler that hasn't built the `swift-symbolgraph-extract` tool. There is a `SWIFT_SYMBOLGRAPH_EXTRACT` env var that could be used to point it another binary, but on platforms other than macOS we don't have an existing Xcode or anything that would be guaranteed to contain this tool. This test should still run on full builds and on self tests, where the tool is available. rdar://87234110&86785765 (cherry picked from commit 850c772)
This includes reworking the SymbolGraphExtract type that so it's more suitable for being called in the context of plugins.
Motivation:
The symbol graph extraction support for plugins called into the existing SymbolGraphExtract type, but this type was more suited to use from the command line action, and this caused some bugs for its use from plugins.
This PR refactors SymbolGraphExtract to hoist the assumptions about things like destination path out into the caller, and adjusts the call sites.
Modifications
dump-symbol-graph
command as well as its use from plugins-v
todump-symbol-graph
so it prints additional information tooResults
Same behavior for
dump-symbol-graph
except that verbose mode is now also passed on to that tool, which is in the spirit of enabling verbose more. For package plugin use, there are now separate output paths per combination of package and target, and only those symbol graphs that are asked for are emitted.rdar://87234110&86785765
This will be nominated for inclusion in SwiftPM 5.6.