Open kateinoigakukun opened 6 months ago
Project-local swift version specification was only left out for simplicity's sake because we weren't sure if it was that important to users--I think it's a totally valid feature. If it's critical to your adoption of swiftly, then I imagine there's others in the same situation, so I would be in favor of introducing it. And design/implementation is more than welcome if you'd like to contribute that, thanks in advance!
A few design notes/questions:
swift
? or is it common to invoke swiftc
or any of the other swift-xxx
executables directly? what about lldb?).self-update
command. Maybe we have a new field in config.json
that indicates whether the transition has completed or not which we can check during install / use? (this could be something like a version number to be useful going forward)
.swift-version
for ease of transition? Or should we only support a swiftly-specific file? I somewhat like the idea of supporting the former as a backup if the swiftly-specific one isn't found.What do you think @adam-fowler?
Thanks for your consideration @patrickfreed!
I'm also wondering which executables we need to write shims for (is it just swift? or is it common to invoke swiftc or any of the other swift-xxx executables directly? what about lldb?).
I think we can follow the way macOS does for /usr/bin binaries. Some of /usr/bin binaries including swift
and clang
are actually shims that corporates with xcode-select
status. You can find which executables are shimed by the following script:
$ for bin in /usr/bin/*; do if otool -L $bin | grep libxcselect.dylib &> /dev/null; then echo $bin; fi; done
We can choose those executables that is included in both Swift toolchain package and /usr/bin shims.
We'll need to provide a transition path, which I think will need to be implemented in swiftly itself due to the self-update command. Maybe we have a new field in config.json that indicates whether the transition has completed or not which we can check during install / use? (this could be something like a version number to be useful going forward)
Yeah, will have detailed design later.
Should we support .swift-version for ease of transition? Or should we only support a swiftly-specific file? I somewhat like the idea of supporting the former as a backup if the swiftly-specific one isn't found.
I think we should support .swift-version for migration path from swiftenv. And also for future possibility of custom toolchain support and Swift SDK installation support, it would be nice to have more structural configuration format like rust-toolchain.toml.
That is a large number of shims, and I think maintaining that list would be pretty difficult (e.g. if Swift removes or adds a new executable to their toolchains, we'll be out of date and users will need to update swiftly itself). To work around that, it might be best to just shim swift
-specific executables plus. That would be something like:
swift-api-digester
swift-api-extract
swift-autolink-extract
swift-build
swift-build-sdk-interfaces
swift-build-tool
swiftc
swift-demangle
swift-driver
swift-frontend
swift-help
swift-package
swift-package-collection
swift-package-registry
swift-run
swift-symbolgraph-extract
swift-test
sourcekit-lsp
If we wanted to be even more minimal, we could probably just do swift
, swiftc
, and sourcekit-lsp
, since swift
gets us all the swift-xxx
executables via its commands. That might be a good starting point at least.
If we wanted to be even more minimal, we could probably just do
swift
,swiftc
, andsourcekit-lsp
, sinceswift
gets us all theswift-xxx
executables via its commands. That might be a good starting point at least.
That's pretty much how it works on macOS. swift, lldb and sourcekit-lsp are in /usr/bin and everything else is in the toolchain normally inside the Xcode.app folder. Although I'm not sure where it gets the version of clang or ld from as there are versions of this in /usr/bin.
One of the current missing pieces compared with swiftenv is "project-local" Swift version.
@patrickfreed said https://github.com/swift-server/swiftly/issues/52#issuecomment-1537531322:
In our case, this feature is the main blocker to migrating from swiftenv to swiftly, so it's critical at least for us. I'm happy to design and implement it but I'd like to hear if this feature could be accepted before starting detailed design.
This feature would depend on an architectural change: https://github.com/swift-server/swiftly/issues/52