Setting toolchain

How to set Toolchain in the scripts?

I can write directly that

export TOOLCHAIN=/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-11-20-a.xctoolchain

but instead, I want my docc to ask for setting toolchain to the above specific path.

So, I thought the following will work but I am not sure...

if [[ ! -d "$docc_source_path" ]]; then
cd /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2021-11-20-a.xctoolchain
else
echo "TOOLCHAIN var exists."

Hi Shilpee,

I'm a little lost as to what you're trying to accomplish with this ask.

When you install and run code from a toolchain on macOS, it wouldn't be uncommon to have another "default" toolchain location already operating: whatever you have with Xcode. If you have multiple Xcode versions installed, each one also has it's own toolchain (say, Xcode vs. and Xcode beta).

The Xcode install toolchains all do some kind of interesting magic with the tool xcrun, which is a fancy shell script that sets up environment variables and forwards commands so that they run within whatever default toolchain you have. The default between various Xcodes is something that you choose in Xcode preferences.

All that's an aside from "when you install a toolchain yourself" - and the path you listed above is where you'd install a downloadable toolchain on macOS. In those cases, the common pattern I've seen is to set a TOOLCHAIN environment variable, and then build off that to run any tools or commands that work from that toolchain - either by building it into your PATH variable, or calling the commands with paths that are built up using ${TOOLCHAIN}/... kinds of constructs in shell scripts.

As I've been running docc, I've generally been using the xcrun before it so that it has the relevant pathing all set up. In the cases where I wanted to run it from an explicit toolchain that I downloaded and installed, then I constructed the various paths that docc needed to work by building them up manually.

They way its set up, I think docc is meant to be agnostic of a toolchain location - entirely so that you can have multiple versions of it (along with multiple versions of swift and all the rest) installed.

Does this help point any other paths to solving the underlying problem you're trying to resolve?

Hello Sir, Thanks for helping me out.

I am sorry for not providing enough references.

These are some changes.

This is the pull request that I am trying to create so I wanted to change the toolchain accordingly in the generate_docc.sh file.

It is the same file which you had used while building documentation run when you were running the server for swift-distributed-actors.

I have downloaded and installed the Swift-development snapshot 2021-11-20 in my local machine along with other versions.

So, you changed the path by your own from the docc file and then run it. But this would be same as writing

Ah, the pull request made a lot more sense, once i read through it. I went ahead and commented on the PR to provide more concrete detail more related to what you were looking to achieve.

At the core, when using docc from a specific tool chain, you’d prefix the commands with the path of the toolchain. Hopefully my notes in the PR will make it clear.

1 Like

Thank you so much sir

Terms of Service

Privacy Policy

Cookie Policy