-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implement proposed adjustments to SE-0303 to use @main
for plugins
#3712
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
Implement proposed adjustments to SE-0303 to use @main
for plugins
#3712
Conversation
0fb7392
to
27104d7
Compare
@swift-ci please smoke test |
27104d7
to
2d75055
Compare
@swift-ci please smoke test |
@main
for plugins@main
for plugins
...scellaneous/Plugins/ContrivedTestPlugin/Plugins/MyAmbiguouslyNamedCommandPlugin/plugin.swift
Outdated
Show resolved
Hide resolved
|
||
struct Diagnostic: Encodable { | ||
enum Severity: String, Encodable { | ||
case error, warning, remark |
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.
remark -> info ?
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.
Maybe. Or note
. In the amendment proposal this is remark
, so we should also take it up there whether it should be something else.
2d12188
to
61abc08
Compare
@swift-ci please smoke test |
2dc5ea7
to
ec71d58
Compare
This is an implementation of the proposed adjustments to SE-0303 in swiftlang/swift-evolution#1434. This changes the entry point to use `@main` rather than top-level code, and introduces protocols for the entry points corresponding to the various plugin capabilities. It gets rid of the globals in favour of plugin parameters and return values (except for diagnostics, which are still collected using a process-wide list).
…ifications. Mark the Severity as public and add a method that takes it as a parameter.
ec71d58
to
aa295b0
Compare
@swift-ci please smoke test |
aa295b0
to
1ce1543
Compare
@swift-ci please smoke test |
@swift-ci please smoke test linux |
These Linux failures seem to be outside of the actual changes for this PR... they're also different each time; trying again. |
@swift-ci please smoke test linux |
lgtm 👍 |
This is an implementation of almost all of the approved adjustments to SE-0303 proposed in swiftlang/swift-evolution#1434.
Motivation:
This changes the entry point to use
@main
rather than top-level code, and introduces protocols for the entry points corresponding to the various plugin capabilities. Using@main
allows customized entry points for each kind of plugin, makes it clearer what the inputs and expected outputs of each plugin are by replacing the global variables with method parameters and return values, and will make it easier to add new kinds of plugins in the future.Modifications:
static func main()
that decodes input from SwiftPM and calls the pluginatexit()
code for dumping output with similar code at the end of the staticmain()
-parse-as-library
so that@main
can be usedResult:
Plugins will use the new entry point as described in the amended SE-0303.
The one change left to make is to mark the entry point as
async
. That cannot be done right now because it would make plugins unavailable on macOS 11 and earlier. Further work is needed to find a way to supportasync
when running on macOS 12 and later, while still supporting macOS 11 for plugins that don't needasync
APIs.