Overall I think the proposal looks like a decent first step, I have some specific remarks though:
I think Target.plugin(...)
should include a sources
parameter at least, if not more of the parameters the other target types have. With the sources list, packages with a single, simple plugin could just use a single file at the package root, which I personally would quite like.
If we can run basically arbitrary shell commands as prebuild actions, can we use swift run
on some package in a subdirectory (or even generated from scratch using the new package editing commands)? This could serve as a workaround to avoid the (I think rather unfortunate) reliance on downloading a binary from somewhere if it could be avoided, if maybe in a hackish way, until prebuild plugins depending on other targets can be supported natively.
The security section states "In addition, SwiftPM and IDEs that use libSwiftPM should run each command generated by an plugin in a sandbox". How does this work when tools from the system search path are used, which could require pretty much arbitrary files on the system to be accessible in order to function properly?
Wrt. future directions, does 'the ability for package plugin scripts to use libraries provided by other targets' imply implementing build steps using these libraries directly in the plugin, probably in form of a closure? Or are the libraries only meant to help creating commands? (I hope it's the former, as I'd rather get rid of the indirection through a command line invocation as soon as may be)
For the type-safe configuration idea, I think it would be unfortunate if every line in a plugin list ended up as .plugin(name: "X", options: XOptions(...))
, instead of something like X(...)
or .x(...)
, avoiding the repetition and string name, but I guess we'll get to that when we get to that :D
Lastly, should DiagnosticsEmitter integrate with SwiftLog in some way? This could then dovetail nicely once build steps can be defined in Swift, and depend on libraries that might be using SwiftLog already.