File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Sources/SwiftDriver/Toolchains Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 11
11
//===----------------------------------------------------------------------===//
12
12
import TSCBasic
13
13
14
- fileprivate func envVarName( forExecutable toolName: String ) -> String {
15
- return " SWIFT_DRIVER_ \( toolName. uppercased ( ) ) _EXEC "
16
- }
17
-
18
14
/// Toolchain for Darwin-based platforms, such as macOS and iOS.
19
15
///
20
16
/// FIXME: This class is not thread-safe.
@@ -124,7 +120,7 @@ public final class DarwinToolchain: Toolchain {
124
120
/// looks in the executable path; finally, fallback to xcrunFind.
125
121
/// - Parameter exec: executable to look for [i.e. `swift`].
126
122
func lookup( exec: String ) throws -> AbsolutePath {
127
- if let overrideString = env [ envVarName ( forExecutable: exec) ] {
123
+ if let overrideString = envVar ( forExecutable: exec) {
128
124
return try AbsolutePath ( validating: overrideString)
129
125
} else if let path = lookupExecutablePath ( filename: exec, searchPaths: [ executableDir] ) {
130
126
return path
Original file line number Diff line number Diff line change @@ -83,4 +83,15 @@ extension Toolchain {
83
83
}
84
84
return AbsolutePath ( path) . parentDirectory
85
85
}
86
+
87
+ /// Looks for `SWIFT_DRIVER_TOOLNAME_EXEC` in the `env` property.
88
+ /// - Returns: Environment variable value, if any.
89
+ func envVar( forExecutable toolName: String ) -> String ? {
90
+ return env [ envVarName ( for: toolName) ]
91
+ }
92
+
93
+ /// - Returns: String in the form of: `SWIFT_DRIVER_TOOLNAME_EXEC`
94
+ private func envVarName( for toolName: String ) -> String {
95
+ return " SWIFT_DRIVER_ \( toolName. uppercased ( ) ) _EXEC "
96
+ }
86
97
}
You can’t perform that action at this time.
0 commit comments