@@ -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,34 +319,34 @@ 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 ) async {
323
323
self . delegate = delegate
324
324
325
325
for path in searchPaths {
326
- registerPlatformsInDirectory ( path)
326
+ await registerPlatformsInDirectory ( path, fs )
327
327
}
328
328
329
329
do {
330
330
if hostOperatingSystem. createFallbackSystemToolchain {
331
- try registerFallbackSystemPlatform ( operatingSystem: hostOperatingSystem)
331
+ try await registerFallbackSystemPlatform ( operatingSystem: hostOperatingSystem, fs : fs )
332
332
}
333
333
} catch {
334
334
delegate. error ( error)
335
335
}
336
336
337
- @preconcurrency @PluginExtensionSystemActor func platformInfoExtensions( ) -> [ any PlatformInfoExtensionPoint . ExtensionProtocol ] {
338
- delegate. pluginManager. extensions ( of: PlatformInfoExtensionPoint . self)
337
+ @preconcurrency @PluginExtensionSystemActor func platformInfoExtensions( ) async -> [ any PlatformInfoExtensionPoint . ExtensionProtocol ] {
338
+ return await delegate. pluginManager. extensions ( of: PlatformInfoExtensionPoint . self)
339
339
}
340
340
341
- for platformExtension in platformInfoExtensions ( ) {
341
+ for platformExtension in await platformInfoExtensions ( ) {
342
342
for (path, data) in platformExtension. additionalPlatforms ( ) {
343
- registerPlatform ( path, . plDict( data) )
343
+ await 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 ) async throws {
349
+ try await registerPlatform ( Path ( " / " ) , . plDict( fallbackSystemPlatformSettings ( operatingSystem: operatingSystem) ) , fs )
350
350
}
351
351
352
352
private func fallbackSystemPlatformSettings( operatingSystem: OperatingSystem ) throws -> [ String : PropertyListItem ] {
@@ -413,10 +413,10 @@ public final class PlatformRegistry {
413
413
}
414
414
415
415
/// Register all platforms in the given directory.
416
- private func registerPlatformsInDirectory( _ path: Path ) {
417
- for item in ( try ? localFS. listdir ( path) ) ? . sorted ( by: < ) ?? [ ] {
418
- let itemPath = path. join ( item)
419
416
417
+ private func registerPlatformsInDirectory( _ path: Path , _ fs: any FSProxy ) async {
418
+ for item in ( try ? fs. listdir ( path) ) ? . sorted ( by: < ) ?? [ ] {
419
+ let itemPath = path. join ( item)
420
420
// Check if this is a platform we should load
421
421
guard itemPath. fileSuffix == " .platform " else { continue }
422
422
@@ -432,14 +432,15 @@ public final class PlatformRegistry {
432
432
continue
433
433
}
434
434
435
- registerPlatform ( itemPath, infoPlist)
435
+ await registerPlatform ( itemPath, infoPlist, fs )
436
436
} catch let err {
437
437
delegate. error ( itemPath, " unable to load platform: 'Info.plist' was malformed: \( err) " )
438
438
}
439
439
}
440
440
}
441
441
442
- private func registerPlatform( _ path: Path , _ data: PropertyListItem ) {
442
+
443
+ private func registerPlatform( _ path: Path , _ data: PropertyListItem , _ fs: any FSProxy ) async {
443
444
// The data should always be a dictionary.
444
445
guard case . plDict( var items) = data else {
445
446
delegate. error ( path, " unexpected platform data " )
@@ -614,7 +615,7 @@ public final class PlatformRegistry {
614
615
delegate. pluginManager. extensions ( of: PlatformInfoExtensionPoint . self)
615
616
}
616
617
617
- for platformExtension in platformInfoExtensions ( ) {
618
+ for platformExtension in await platformInfoExtensions ( ) {
618
619
if let value = platformExtension. preferredArchValue ( for: name) {
619
620
preferredArchValue = value
620
621
}
@@ -624,8 +625,8 @@ public final class PlatformRegistry {
624
625
path. join ( " usr " ) . join ( " bin " ) ,
625
626
]
626
627
627
- for platformExtension in platformInfoExtensions ( ) {
628
- executableSearchPaths. append ( contentsOf: platformExtension. additionalPlatformExecutableSearchPaths ( platformName: name, platformPath: path) )
628
+ for platformExtension in await platformInfoExtensions ( ) {
629
+ await executableSearchPaths. append ( contentsOf: platformExtension. additionalPlatformExecutableSearchPaths ( platformName: name, platformPath: path, fs : localFS ) )
629
630
}
630
631
631
632
executableSearchPaths. append ( contentsOf: [
@@ -635,7 +636,7 @@ public final class PlatformRegistry {
635
636
] )
636
637
637
638
// 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)
639
+ let platform = Platform ( name, displayName, familyName, familyDisplayName, identifier, devicePlatformName, simulatorPlatformName, path, version, productBuildVersion, defaultSettings, additionalInfoPlistEntries, isDeploymentPlatform, delegate, preferredArchValue: preferredArchValue, executableSearchPaths: executableSearchPaths, fs : fs )
639
640
if let duplicatePlatform = platformsByIdentifier [ identifier] {
640
641
delegate. error ( path, " platform ' \( identifier) ' already registered from \( duplicatePlatform. path. str) " )
641
642
return
0 commit comments