Skip to content

Commit 0f9ad9a

Browse files
committed
Add an Environment Variable to Specify the Toolchain Path
This is particularly useful for Windows which doesn't currently have a standardized place to install the toolchain to.
1 parent 9c5a13a commit 0f9ad9a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/Workspace/Destination.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import TSCBasic
22
import Build
33
import TSCUtility
4+
import Foundation
45

56
public enum DestinationError: Swift.Error {
67
/// Couldn't find the Xcode installation.
@@ -57,16 +58,16 @@ public struct Destination: Encodable {
5758
private static func hostBinDir(
5859
originalWorkingDirectory: AbsolutePath? = localFileSystem.currentWorkingDirectory
5960
) -> AbsolutePath {
61+
if let toolchainDir = ProcessInfo.processInfo.environment["SWIFT_TOOLCHAIN_PATH"] {
62+
return AbsolutePath(toolchainDir)
63+
}
6064
#if Xcode
6165
// For Xcode, set bin directory to the build directory containing the fake
6266
// toolchain created during bootstraping. This is obviously not production ready
6367
// and only exists as a development utility right now.
6468
//
6569
// This also means that we should have bootstrapped with the same Swift toolchain
6670
// we're using inside Xcode otherwise we will not be able to load the runtime libraries.
67-
//
68-
// FIXME: We may want to allow overriding this using an env variable but that
69-
// doesn't seem urgent or extremely useful as of now.
7071
return AbsolutePath(#file).parentDirectory
7172
.parentDirectory.parentDirectory.appending(components: ".build", hostTargetTriple.tripleString, "debug")
7273
#else

0 commit comments

Comments
 (0)