@@ -84,7 +84,8 @@ public struct Destination {
84
84
/// The destination describing the host OS.
85
85
public static func hostDestination(
86
86
_ binDir: AbsolutePath ? = nil ,
87
- originalWorkingDirectory: AbsolutePath ? = localFileSystem. currentWorkingDirectory
87
+ originalWorkingDirectory: AbsolutePath ? = localFileSystem. currentWorkingDirectory,
88
+ environment: [ String : String ] = Process . env
88
89
) throws -> Destination {
89
90
// Select the correct binDir.
90
91
let binDir = binDir ?? Destination . hostBinDir (
@@ -98,7 +99,7 @@ public struct Destination {
98
99
} else {
99
100
// No value in env, so search for it.
100
101
let sdkPathStr = try Process . checkNonZeroExit (
101
- args : " xcrun " , " --sdk " , " macosx " , " --show-sdk-path " ) . chomp ( )
102
+ arguments : [ " xcrun " , " --sdk " , " macosx " , " --show-sdk-path " ] , environment : environment ) . chomp ( )
102
103
guard !sdkPathStr. isEmpty else {
103
104
throw DestinationError . invalidInstallation ( " default SDK not found " )
104
105
}
@@ -107,7 +108,7 @@ public struct Destination {
107
108
108
109
// Compute common arguments for clang and swift.
109
110
// This is currently just frameworks path.
110
- let commonArgs = Destination . sdkPlatformFrameworkPath ( ) . map ( { [ " -F " , $0. asString] } ) ?? [ ]
111
+ let commonArgs = Destination . sdkPlatformFrameworkPath ( environment : environment ) . map ( { [ " -F " , $0. asString] } ) ?? [ ]
111
112
112
113
return Destination (
113
114
target: hostTargetTriple,
@@ -132,12 +133,12 @@ public struct Destination {
132
133
}
133
134
134
135
/// Returns macosx sdk platform framework path.
135
- public static func sdkPlatformFrameworkPath( ) -> AbsolutePath ? {
136
+ public static func sdkPlatformFrameworkPath( environment : [ String : String ] = Process . env ) -> AbsolutePath ? {
136
137
if let path = _sdkPlatformFrameworkPath {
137
138
return path
138
139
}
139
140
let platformPath = try ? Process . checkNonZeroExit (
140
- args : " xcrun " , " --sdk " , " macosx " , " --show-sdk-platform-path " ) . chomp ( )
141
+ arguments : [ " xcrun " , " --sdk " , " macosx " , " --show-sdk-platform-path " ] , environment : environment ) . chomp ( )
141
142
142
143
if let platformPath = platformPath, !platformPath. isEmpty {
143
144
_sdkPlatformFrameworkPath = AbsolutePath ( platformPath) . appending (
0 commit comments