swiftly icon indicating copy to clipboard operation
swiftly copied to clipboard

Implement `exec` command

Open patrickfreed opened this issue 3 years ago • 1 comments

swiftly should have an exec command which allows a user to run a specific swift command without having to switch the active toolchain.

e.g.

swiftly exec 5.5 build

Would run swift build using the latest 5.5 toolchain.

patrickfreed avatar Nov 11 '22 19:11 patrickfreed

Here are some additional thoughts on this enhancement. First, the version selector can be optional, and then the toolchain that is in use would be chosen, where the used toolchain logic can be flexible, possibly consulting the .swift-version file (see #155) as well as the global default in the config.json.

At the expense of requiring the full toolchain command there are some additional features we can unlock. Here's what the build example above could look like:

swiftly exec 5.5 swift build

But now you aren't restricted to just the swift command from the toolchain. You can also invoke any of the other tools, such as lldb, and clang too using the in-use toolchain:

swiftly exec clang -o foo.o foo.c

Or, you can invoke a command or even a shell script that makes use of any tool in the toolchain because it sets the toolchain at the beginning of the PATH:

swiftly exec ./my-special-script.sh

And, if your project uses autoconf/cmake you can build it with the swift toolchain (clang, clang++) like this because exec sets the CC, CXX environment variables to the in-use toolchain:

swiftly exec ./configure
swiftly exec make

cmcgee1024 avatar Aug 21 '24 11:08 cmcgee1024