@@ -68,6 +68,7 @@ extension ToolchainRegistry {
68
68
///
69
69
/// If called with the default values, creates a toolchain registry that searches:
70
70
/// * env SOURCEKIT_TOOLCHAIN_PATH <-- will override default toolchain
71
+ /// * installPath <-- will override default toolchain
71
72
/// * (Darwin) The currently selected Xcode
72
73
/// * (Darwin) [~]/Library/Developer/Toolchains
73
74
/// * env SOURCEKIT_PATH, PATH
@@ -77,9 +78,9 @@ extension ToolchainRegistry {
77
78
/// let tr = ToolchainRegistry()
78
79
/// tr.scanForToolchains()
79
80
/// ```
80
- public convenience init ( _ fileSystem: FileSystem ) {
81
+ public convenience init ( installPath : AbsolutePath ? = nil , _ fileSystem: FileSystem ) {
81
82
self . init ( )
82
- scanForToolchains ( fileSystem)
83
+ scanForToolchains ( installPath : installPath , fileSystem)
83
84
}
84
85
}
85
86
@@ -222,18 +223,12 @@ extension ToolchainRegistry {
222
223
///
223
224
/// If called with the default values, creates a toolchain registry that searches:
224
225
/// * env SOURCEKIT_TOOLCHAIN_PATH <-- will override default toolchain
226
+ /// * installPath <-- will override default toolchain
225
227
/// * (Darwin) The currently selected Xcode
226
228
/// * (Darwin) [~]/Library/Developer/Toolchains
227
229
/// * env SOURCEKIT_PATH, PATH
228
- ///
229
- /// This is equivalent to
230
- /// ```
231
- /// tr.scanForToolchains(environmentVariables: environmentVariables, setDefault: true)
232
- /// xcodes.forEach { tr.scanForToolchains(xcode: $0) }
233
- /// xctoolchainSearchPaths.forEach { tr.scanForToolchains(xctoolchainSearchPath: $0) }
234
- /// tr.scanForToolchains(pathVariables: pathVariables)
235
- /// ```
236
230
public func scanForToolchains(
231
+ installPath: AbsolutePath ? = nil ,
237
232
environmentVariables: [ String ] = [ " SOURCEKIT_TOOLCHAIN_PATH " ] ,
238
233
xcodes: [ AbsolutePath ] = [ currentXcodeDeveloperPath ] . compactMap ( { $0} ) ,
239
234
xctoolchainSearchPaths: [ AbsolutePath ] = [
@@ -245,6 +240,12 @@ extension ToolchainRegistry {
245
240
{
246
241
queue. sync {
247
242
_scanForToolchains ( environmentVariables: environmentVariables, setDefault: true , fileSystem)
243
+ if let installPath = installPath,
244
+ let toolchain = try ? _registerToolchain ( installPath, fileSystem) ,
245
+ _default == nil
246
+ {
247
+ _default = toolchain
248
+ }
248
249
xcodes. forEach { _scanForToolchains ( xcode: $0, fileSystem) }
249
250
xctoolchainSearchPaths. forEach { _scanForToolchains ( xctoolchainSearchPath: $0, fileSystem) }
250
251
_scanForToolchains ( pathVariables: pathVariables, fileSystem)
0 commit comments