[swift-build-dev] Feature request: Scripting support for Swift
Jason Dusek
jason.dusek at gmail.com
Sun Feb 19 13:43:15 CST 2017
One issue with compiling the dependencies is that script startup would be
slow. Maybe there should be a per-user or system level cache? System level
is better from a disk usage perspective but some thought must be given to
security.
With Ruby and Python, it is not expected that a script's dependencies are
installed when it is run but rather they have already been installed via
the package manager, although it does seem useful for single files to
contain all the relevant information.
Here is another idea: a Swift script can be run from a project directory
with Sources/, Packages/, &c. In that environment, build products are
already cached. If the script is symlinked into /usr/local/bin/ it will be
on the path but xcrun will still be able to find the project. It is kind of
like a source-level .app bundle.
Maxim Veksler via swift-build-dev <swift-build-dev at swift.org> schrieb am
Sa. 18. Feb. 2017 um 11:28:
> Hi,
>
> Ayaka Nonaka gave a talk[1] about basic scripting[2] support in Swift.
>
> The gist of the idea is to use #!/usr/bin/env xcrun swift
>
> Therefor it seems the basic building blocks for allowing a swift file to
> "execute itself" are always laid out and proved to be applicable.
>
> What's missing IMHO is a better support for dependencies, the suggested
> solutions in the talk are using the -F for including frameworks that were
> built using Carthage or CocoaPods. That's not idle because a script I think
> should be self contained, meaning that you can "just run it" and it works.
>
> So, I'm wondering what if it was possible to include the dependencies
> inside the swift file itself? Probably using the same format as the
> Package.swift syntax. The the swift binary would "detect" that it's a self
> contained file, it could make this distinction because import
> PackageDescription is defined by the user.
>
> Then it would follow a 3 step process:
> 1. It should download and build the dependencies
> 2. then compile the code inside the file
> 3. and then run it.
>
> Having everything happening behind the scenes, so the "script user" simply
> calls ./MyScript.swift or swift MyScript.swift and it "just works".
>
> Wondering what the community thinks.
>
> [1] https://realm.io/news/swift-scripting/
> [2] https://github.com/ayanonagon/talks/tree/master/2015-swiftsummit/2
> _______________________________________________
> swift-build-dev mailing list
> swift-build-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-build-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-build-dev/attachments/20170219/8fe223ae/attachment.html>
More information about the swift-build-dev
mailing list