I’m very interested in the project idea of adding SwiftPM support in Swift scripts. I’ve kept tracking on the SwiftPM support for Swift scripts thread since nearly a year ago (and also left a comment lol), and I’m really excited that it’s going to be picked up. Here’s my plan for making it an official evolution proposal:
Draft a proposal based on the original one, and discuss with community members on the API design and working structure;
Integrate SwiftPM support for scripts in SwiftDriver;
Linux and macOS are the first target platforms for this proposal;
Before the proposal is accepted, this feature will be available behind a flag;
If possible, it should also be integrated into Swift REPL and SourceKit.
Currently, I plan to add the package parsing ability to Swift’s parser. SwiftDriver retrieves the package information from the frontend, and then hands it over to SwiftPM. SwiftPM will gain the ability of caching the build (and probably the script itself) and managing the cache. What do you think about this idea? @abertelrud@tomerd
thank you @stevapple for reaching out, getting a proposal out to discuss the design would be a great step forward, looking forward to see what you come up with -- this would be a great addition to the Swift ecosystem
A good approach is to write a more light-weight version of the proposal and pitch that, then develop it to a full proposal with sample implementation once the pitch converges
I’d like to make it clear here that I’m not going to implement the whole proposal during GSoC.
I plan to work out a suitable working logic and implement the key function (swift script run, I suppose) as for the GSoC proposal. The current SE proposal is only a draft that provides more details than the original one, and hopefully it will be improved and finalized though community discussions (and the GSoC practice) over time.
Having a fully fledged proposal that can be implemented in multiple steps make total sense. The design should allow for such steps, making sure that we can build something useful, even if small, as part of the GSoC project
I think the basic swift-script run <file> demo will meet the GSoC requirements. For the current proposal, this involves parsing the attributes, dumping the results into a JSON file (frontend), searching the cache, resolving the dependencies, building and running the code (SwiftPM).
Based on a successful demonstration, we can then implement the swift-script toolset (breaking into multiple parts), and finally other integrations.
The goal for GSoC is some kind of proof-of-concept and is expected to be the foundation of a full implementation of this feature. The outcome is expected to be a prototype of the new swift-script tool, which has a limited set of basic operations implemented like run and reset. There will also be a new flag for Swift Driver which enables a shortcut to the feature through swift command.