Skip to content

Commit aa22715

Browse files
committed
Allow a custom env for more xcrun invocations
Basically a continuation of #1766
1 parent 5f63b90 commit aa22715

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/Workspace/UserToolchain.swift

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

132+
private let environment: [String:String]
133+
132134
public func getClangCompiler() throws -> AbsolutePath {
133135

134136
if let clangCompiler = _clangCompiler {
@@ -142,7 +144,7 @@ public final class UserToolchain: Toolchain {
142144
clangCompiler = value
143145
} else {
144146
// No value in env, so search for `clang`.
145-
let foundPath = try Process.checkNonZeroExit(arguments: whichClangArgs).chomp()
147+
let foundPath = try Process.checkNonZeroExit(arguments: whichClangArgs, environment: environment).chomp()
146148
guard !foundPath.isEmpty else {
147149
throw InvalidToolchainDiagnostic("could not find `clang`")
148150
}
@@ -159,6 +161,7 @@ public final class UserToolchain: Toolchain {
159161

160162
public init(destination: Destination, environment: [String:String] = Process.env) throws {
161163
self.destination = destination
164+
self.environment = environment
162165

163166
// Get the search paths from PATH.
164167
let searchPaths = getEnvSearchPaths(

0 commit comments

Comments
 (0)