@@ -180,9 +180,9 @@ public final class Platform: Sendable {
180
180
@_spi ( Testing) public var sdks : [ SDK ] = [ ]
181
181
182
182
/// The list of executable search paths in the platform.
183
- @_spi ( Testing) public var executableSearchPaths : [ Path ]
183
+ @_spi ( Testing) public var executableSearchPaths : StackedSearchPath
184
184
185
- init ( _ name: String , _ displayName: String , _ familyName: String , _ familyDisplayName: String ? , _ identifier: String , _ devicePlatformName: String ? , _ simulatorPlatformName: String ? , _ path: Path , _ version: String ? , _ productBuildVersion: String ? , _ defaultSettings: [ String : PropertyListItem ] , _ additionalInfoPlistEntries: [ String : PropertyListItem ] , _ isDeploymentPlatform: Bool , _ specRegistryProvider: any SpecRegistryProvider , preferredArchValue: String ? , executableSearchPaths: [ Path ] ) {
185
+ init ( _ name: String , _ displayName: String , _ familyName: String , _ familyDisplayName: String ? , _ identifier: String , _ devicePlatformName: String ? , _ simulatorPlatformName: String ? , _ path: Path , _ version: String ? , _ productBuildVersion: String ? , _ defaultSettings: [ String : PropertyListItem ] , _ additionalInfoPlistEntries: [ String : PropertyListItem ] , _ isDeploymentPlatform: Bool , _ specRegistryProvider: any SpecRegistryProvider , preferredArchValue: String ? , executableSearchPaths: [ Path ] , fs : any FSProxy ) {
186
186
self . name = name
187
187
self . displayName = displayName
188
188
self . familyName = familyName
@@ -198,7 +198,7 @@ public final class Platform: Sendable {
198
198
self . isDeploymentPlatform = isDeploymentPlatform
199
199
self . specRegistryProvider = specRegistryProvider
200
200
self . preferredArch = preferredArchValue
201
- self . executableSearchPaths = executableSearchPaths
201
+ self . executableSearchPaths = StackedSearchPath ( paths : executableSearchPaths, fs : fs )
202
202
self . sdkCanonicalName = name
203
203
}
204
204
@@ -319,16 +319,16 @@ public final class PlatformRegistry {
319
319
} )
320
320
}
321
321
322
- @_spi ( Testing) public init ( delegate: any PlatformRegistryDelegate , searchPaths: [ Path ] , hostOperatingSystem: OperatingSystem ) {
322
+ @_spi ( Testing) public init ( delegate: any PlatformRegistryDelegate , searchPaths: [ Path ] , hostOperatingSystem: OperatingSystem , fs : any FSProxy ) {
323
323
self . delegate = delegate
324
324
325
325
for path in searchPaths {
326
- registerPlatformsInDirectory ( path)
326
+ registerPlatformsInDirectory ( path, fs )
327
327
}
328
328
329
329
do {
330
330
if hostOperatingSystem. createFallbackSystemToolchain {
331
- try registerFallbackSystemPlatform ( operatingSystem: hostOperatingSystem)
331
+ try registerFallbackSystemPlatform ( operatingSystem: hostOperatingSystem, fs : fs )
332
332
}
333
333
} catch {
334
334
delegate. error ( error)
@@ -340,13 +340,13 @@ public final class PlatformRegistry {
340
340
341
341
for platformExtension in platformInfoExtensions ( ) {
342
342
for (path, data) in platformExtension. additionalPlatforms ( ) {
343
- registerPlatform ( path, . plDict( data) )
343
+ registerPlatform ( path, . plDict( data) , fs )
344
344
}
345
345
}
346
346
}
347
347
348
- private func registerFallbackSystemPlatform( operatingSystem: OperatingSystem ) throws {
349
- try registerPlatform ( Path ( " / " ) , . plDict( fallbackSystemPlatformSettings ( operatingSystem: operatingSystem) ) )
348
+ private func registerFallbackSystemPlatform( operatingSystem: OperatingSystem , fs : any FSProxy ) throws {
349
+ try registerPlatform ( Path ( " / " ) , . plDict( fallbackSystemPlatformSettings ( operatingSystem: operatingSystem) ) , fs )
350
350
}
351
351
352
352
private func fallbackSystemPlatformSettings( operatingSystem: OperatingSystem ) throws -> [ String : PropertyListItem ] {
@@ -413,7 +413,7 @@ public final class PlatformRegistry {
413
413
}
414
414
415
415
/// Register all platforms in the given directory.
416
- private func registerPlatformsInDirectory( _ path: Path ) {
416
+ private func registerPlatformsInDirectory( _ path: Path , _ fs : any FSProxy ) {
417
417
for item in ( try ? localFS. listdir ( path) ) ? . sorted ( by: < ) ?? [ ] {
418
418
let itemPath = path. join ( item)
419
419
@@ -431,15 +431,14 @@ public final class PlatformRegistry {
431
431
// Silently skip loading the platform if it does not have an Info.plist at all. (We will still error below if it has an Info.plist which is malformed.)
432
432
continue
433
433
}
434
-
435
- registerPlatform ( itemPath, infoPlist)
434
+ registerPlatform ( itemPath, infoPlist, fs)
436
435
} catch let err {
437
436
delegate. error ( itemPath, " unable to load platform: 'Info.plist' was malformed: \( err) " )
438
437
}
439
438
}
440
439
}
441
440
442
- private func registerPlatform( _ path: Path , _ data: PropertyListItem ) {
441
+ private func registerPlatform( _ path: Path , _ data: PropertyListItem , _ fs : any FSProxy ) {
443
442
// The data should always be a dictionary.
444
443
guard case . plDict( var items) = data else {
445
444
delegate. error ( path, " unexpected platform data " )
@@ -635,7 +634,7 @@ public final class PlatformRegistry {
635
634
] )
636
635
637
636
// FIXME: Need to parse other fields. It would also be nice to diagnose unused keys like we do for Spec data (and we might want to just use the spec parser here).
638
- let platform = Platform ( name, displayName, familyName, familyDisplayName, identifier, devicePlatformName, simulatorPlatformName, path, version, productBuildVersion, defaultSettings, additionalInfoPlistEntries, isDeploymentPlatform, delegate, preferredArchValue: preferredArchValue, executableSearchPaths: executableSearchPaths)
637
+ let platform = Platform ( name, displayName, familyName, familyDisplayName, identifier, devicePlatformName, simulatorPlatformName, path, version, productBuildVersion, defaultSettings, additionalInfoPlistEntries, isDeploymentPlatform, delegate, preferredArchValue: preferredArchValue, executableSearchPaths: executableSearchPaths, fs : fs )
639
638
if let duplicatePlatform = platformsByIdentifier [ identifier] {
640
639
delegate. error ( path, " platform ' \( identifier) ' already registered from \( duplicatePlatform. path. str) " )
641
640
return
0 commit comments