Skip to content

Commit ba9d373

Browse files
neonichuaciidgh
authored andcommitted
Allow a custom env for more xcrun invocations
Basically a continuation of #1766
1 parent e6166b0 commit ba9d373

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/Workspace/UserToolchain.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ public final class UserToolchain: Toolchain {
129129
return lookupExecutablePath(filename: getenv(variable), searchPaths: searchPaths)
130130
}
131131

132+
/// Environment to use when looking up tools.
133+
private let processEnvironment: [String: String]
134+
132135
public func getClangCompiler() throws -> AbsolutePath {
133136

134137
if let clangCompiler = _clangCompiler {
@@ -142,7 +145,7 @@ public final class UserToolchain: Toolchain {
142145
clangCompiler = value
143146
} else {
144147
// No value in env, so search for `clang`.
145-
let foundPath = try Process.checkNonZeroExit(arguments: whichClangArgs).chomp()
148+
let foundPath = try Process.checkNonZeroExit(arguments: whichClangArgs, environment: processEnvironment).chomp()
146149
guard !foundPath.isEmpty else {
147150
throw InvalidToolchainDiagnostic("could not find `clang`")
148151
}
@@ -157,8 +160,9 @@ public final class UserToolchain: Toolchain {
157160
return clangCompiler
158161
}
159162

160-
public init(destination: Destination, environment: [String:String] = Process.env) throws {
163+
public init(destination: Destination, environment: [String: String] = Process.env) throws {
161164
self.destination = destination
165+
self.processEnvironment = environment
162166

163167
// Get the search paths from PATH.
164168
let searchPaths = getEnvSearchPaths(

0 commit comments

Comments
 (0)