@@ -105,14 +105,20 @@ public final class UserToolchain: Toolchain {
105
105
public typealias SwiftCompilers = ( compile: AbsolutePath , manifest: AbsolutePath )
106
106
107
107
/// Determines the Swift compiler paths for compilation and manifest parsing.
108
- public static func determineSwiftCompilers( binDir: AbsolutePath , envSearchPaths : [ AbsolutePath ] ) throws -> SwiftCompilers {
108
+ public static func determineSwiftCompilers( binDir: AbsolutePath ) throws -> SwiftCompilers {
109
109
func validateCompiler( at path: AbsolutePath ? ) throws {
110
110
guard let path = path else { return }
111
111
guard localFileSystem. isExecutableFile ( path) else {
112
112
throw InvalidToolchainDiagnostic ( " could not find the `swiftc \( hostExecutableSuffix) ` at expected path \( path) " )
113
113
}
114
114
}
115
115
116
+ // Get the search paths from PATH.
117
+ let envSearchPaths = getEnvSearchPaths (
118
+ pathString: ProcessEnv . path,
119
+ currentWorkingDirectory: localFileSystem. currentWorkingDirectory
120
+ )
121
+
116
122
let lookup = { UserToolchain . lookup ( variable: $0, searchPaths: envSearchPaths) }
117
123
// Get overrides.
118
124
let SWIFT_EXEC_MANIFEST = lookup ( " SWIFT_EXEC_MANIFEST " )
@@ -144,9 +150,6 @@ public final class UserToolchain: Toolchain {
144
150
return lookupExecutablePath ( filename: ProcessEnv . vars [ variable] , searchPaths: searchPaths)
145
151
}
146
152
147
- /// Environment to use when looking up tools.
148
- private let processEnvironment : [ String : String ]
149
-
150
153
/// Returns the path to clang compiler tool.
151
154
public func getClangCompiler( ) throws -> AbsolutePath {
152
155
// Check if we already computed.
@@ -267,25 +270,22 @@ public final class UserToolchain: Toolchain {
267
270
+ destination. extraSwiftCFlags
268
271
}
269
272
270
- public init ( destination: Destination , searchPaths : [ AbsolutePath ] , environment : [ String : String ] = ProcessEnv . vars ) throws {
273
+ public init ( destination: Destination ) throws {
271
274
self . destination = destination
272
- self . processEnvironment = environment
273
275
274
276
// Get the search paths from PATH.
275
- let searchPaths = getEnvSearchPaths (
276
- pathString: ProcessEnv . path,
277
+ self . envSearchPaths = getEnvSearchPaths (
278
+ pathString: ProcessEnv . path,
277
279
currentWorkingDirectory: localFileSystem. currentWorkingDirectory
278
- ) + searchPaths
279
-
280
- self . envSearchPaths = searchPaths
280
+ )
281
281
282
282
// Get the binDir from destination.
283
283
let binDir = destination. binDir
284
284
285
- let swiftCompilers = try UserToolchain . determineSwiftCompilers ( binDir: binDir, envSearchPaths : searchPaths )
285
+ let swiftCompilers = try UserToolchain . determineSwiftCompilers ( binDir: binDir)
286
286
self . swiftCompiler = swiftCompilers. compile
287
287
self . archs = destination. archs
288
-
288
+
289
289
// Use the triple from destination or compute the host triple using swiftc.
290
290
var triple = destination. target ?? Triple . getHostTriple ( usingSwiftCompiler: swiftCompilers. compile)
291
291
@@ -302,7 +302,7 @@ public final class UserToolchain: Toolchain {
302
302
if triple. isDarwin ( ) {
303
303
// FIXME: We should have some general utility to find tools.
304
304
let xctestFindArgs = [ " /usr/bin/xcrun " , " --sdk " , " macosx " , " --find " , " xctest " ]
305
- self . xctest = try AbsolutePath ( validating: Process . checkNonZeroExit ( arguments: xctestFindArgs, environment: environment ) . spm_chomp ( ) )
305
+ self . xctest = try AbsolutePath ( validating: Process . checkNonZeroExit ( arguments: xctestFindArgs, environment: ProcessEnv . vars ) . spm_chomp ( ) )
306
306
} else {
307
307
self . xctest = nil
308
308
}
0 commit comments