@@ -57,9 +57,6 @@ public final class UserToolchain: Toolchain {
57
57
/// The list of archs to build for.
58
58
public let archs : [ String ]
59
59
60
- /// Search paths from the PATH environment variable.
61
- let envSearchPaths : [ AbsolutePath ]
62
-
63
60
/// Returns the runtime library for the given sanitizer.
64
61
public func runtimeLibrary( for sanitizer: Sanitizer ) throws -> AbsolutePath {
65
62
// FIXME: This is only for SwiftPM development time support. It is OK
@@ -105,14 +102,20 @@ public final class UserToolchain: Toolchain {
105
102
public typealias SwiftCompilers = ( compile: AbsolutePath , manifest: AbsolutePath )
106
103
107
104
/// Determines the Swift compiler paths for compilation and manifest parsing.
108
- public static func determineSwiftCompilers( binDir: AbsolutePath , envSearchPaths : [ AbsolutePath ] ) throws -> SwiftCompilers {
105
+ public static func determineSwiftCompilers( binDir: AbsolutePath ) throws -> SwiftCompilers {
109
106
func validateCompiler( at path: AbsolutePath ? ) throws {
110
107
guard let path = path else { return }
111
108
guard localFileSystem. isExecutableFile ( path) else {
112
109
throw InvalidToolchainDiagnostic ( " could not find the `swiftc \( hostExecutableSuffix) ` at expected path \( path) " )
113
110
}
114
111
}
115
112
113
+ // Get the search paths from PATH.
114
+ let searchPaths = getEnvSearchPaths (
115
+ pathString: ProcessEnv . path,
116
+ currentWorkingDirectory: localFileSystem. currentWorkingDirectory
117
+ )
118
+
116
119
let lookup = { UserToolchain . lookup ( variable: $0, searchPaths: envSearchPaths) }
117
120
// Get overrides.
118
121
let SWIFT_EXEC_MANIFEST = lookup ( " SWIFT_EXEC_MANIFEST " )
@@ -144,9 +147,6 @@ public final class UserToolchain: Toolchain {
144
147
return lookupExecutablePath ( filename: ProcessEnv . vars [ variable] , searchPaths: searchPaths)
145
148
}
146
149
147
- /// Environment to use when looking up tools.
148
- private let processEnvironment : [ String : String ]
149
-
150
150
/// Returns the path to clang compiler tool.
151
151
public func getClangCompiler( ) throws -> AbsolutePath {
152
152
// Check if we already computed.
@@ -267,25 +267,16 @@ public final class UserToolchain: Toolchain {
267
267
+ destination. extraSwiftCFlags
268
268
}
269
269
270
- public init ( destination: Destination , searchPaths : [ AbsolutePath ] , environment : [ String : String ] = ProcessEnv . vars ) throws {
270
+ public init ( destination: Destination ) throws {
271
271
self . destination = destination
272
- self . processEnvironment = environment
273
-
274
- // Get the search paths from PATH.
275
- let searchPaths = getEnvSearchPaths (
276
- pathString: ProcessEnv . path,
277
- currentWorkingDirectory: localFileSystem. currentWorkingDirectory
278
- ) + searchPaths
279
-
280
- self . envSearchPaths = searchPaths
281
272
282
273
// Get the binDir from destination.
283
274
let binDir = destination. binDir
284
275
285
- let swiftCompilers = try UserToolchain . determineSwiftCompilers ( binDir: binDir, envSearchPaths : searchPaths )
276
+ let swiftCompilers = try UserToolchain . determineSwiftCompilers ( binDir: binDir)
286
277
self . swiftCompiler = swiftCompilers. compile
287
278
self . archs = destination. archs
288
-
279
+
289
280
// Use the triple from destination or compute the host triple using swiftc.
290
281
var triple = destination. target ?? Triple . getHostTriple ( usingSwiftCompiler: swiftCompilers. compile)
291
282
0 commit comments