@@ -221,6 +221,9 @@ public class Workspace {
221
221
/// The file system on which the workspace will operate.
222
222
fileprivate let fileSystem : FileSystem
223
223
224
+ /// The host toolchain to use.
225
+ fileprivate let hostToolchain : UserToolchain
226
+
224
227
/// The manifest loader to use.
225
228
fileprivate let manifestLoader : ManifestLoaderProtocol
226
229
@@ -290,6 +293,7 @@ public class Workspace {
290
293
/// - authorizationProvider: Provider of authentication information for outbound network requests.
291
294
/// - configuration: Configuration to fine tune the dependency resolution behavior.
292
295
/// - initializationWarningHandler: Initialization warnings handler
296
+ /// - customHostToolchain: Custom host toolchain. Used to create a customized ManifestLoader, customizing how manifest are loaded.
293
297
/// - customManifestLoader: Custom manifest loader. Used to customize how manifest are loaded.
294
298
/// - customPackageContainerProvider: Custom package container provider. Used to provide specialized package providers.
295
299
/// - customRepositoryProvider: Custom repository provider. Used to customize source control access.
@@ -301,6 +305,7 @@ public class Workspace {
301
305
configuration: WorkspaceConfiguration ? = . none,
302
306
initializationWarningHandler: ( ( String ) -> Void ) ? = . none,
303
307
// optional customization used for advanced integration situations
308
+ customHostToolchain: UserToolchain ? = . none,
304
309
customManifestLoader: ManifestLoaderProtocol ? = . none,
305
310
customPackageContainerProvider: PackageContainerProvider ? = . none,
306
311
customRepositoryProvider: RepositoryProvider ? = . none,
@@ -317,6 +322,7 @@ public class Workspace {
317
322
customFingerprints: . none,
318
323
customMirrors: . none,
319
324
customToolsVersion: . none,
325
+ customHostToolchain: customHostToolchain,
320
326
customManifestLoader: customManifestLoader,
321
327
customPackageContainerProvider: customPackageContainerProvider,
322
328
customRepositoryManager: . none,
@@ -384,7 +390,7 @@ public class Workspace {
384
390
/// - authorizationProvider: Provider of authentication information for outbound network requests.
385
391
/// - configuration: Configuration to fine tune the dependency resolution behavior.
386
392
/// - initializationWarningHandler: Initialization warnings handler
387
- /// - customToolchain : Custom toolchain. Used to create a customized ManifestLoader, customizing how manifest are loaded.
393
+ /// - customHostToolchain : Custom host toolchain. Used to create a customized ManifestLoader, customizing how manifest are loaded.
388
394
/// - customPackageContainerProvider: Custom package container provider. Used to provide specialized package providers.
389
395
/// - customRepositoryProvider: Custom repository provider. Used to customize source control access.
390
396
/// - delegate: Delegate for workspace events
@@ -395,7 +401,7 @@ public class Workspace {
395
401
configuration: WorkspaceConfiguration ? = . none,
396
402
initializationWarningHandler: ( ( String ) -> Void ) ? = . none,
397
403
// optional customization used for advanced integration situations
398
- customToolchain : UserToolchain ,
404
+ customHostToolchain : UserToolchain ,
399
405
customPackageContainerProvider: PackageContainerProvider ? = . none,
400
406
customRepositoryProvider: RepositoryProvider ? = . none,
401
407
// delegate
@@ -404,15 +410,16 @@ public class Workspace {
404
410
let fileSystem = fileSystem ?? localFileSystem
405
411
let location = Location ( forRootPackage: packagePath, fileSystem: fileSystem)
406
412
let manifestLoader = ManifestLoader (
407
- toolchain: customToolchain . configuration,
413
+ toolchain: customHostToolchain . configuration,
408
414
cacheDir: location. sharedManifestsCacheDirectory
409
415
)
410
416
try self . init (
411
417
fileSystem: fileSystem,
412
- forRootPackage : packagePath ,
418
+ location : location ,
413
419
authorizationProvider: authorizationProvider,
414
420
configuration: configuration,
415
421
initializationWarningHandler: initializationWarningHandler,
422
+ customHostToolchain: customHostToolchain,
416
423
customManifestLoader: manifestLoader,
417
424
customPackageContainerProvider: customPackageContainerProvider,
418
425
customRepositoryProvider: customRepositoryProvider,
@@ -464,6 +471,7 @@ public class Workspace {
464
471
customFingerprints: customFingerprintStorage,
465
472
customMirrors: mirrors,
466
473
customToolsVersion: customToolsVersion,
474
+ customHostToolchain: . none,
467
475
customManifestLoader: customManifestLoader,
468
476
customPackageContainerProvider: customPackageContainerProvider,
469
477
customRepositoryManager: customRepositoryManager,
@@ -581,6 +589,7 @@ public class Workspace {
581
589
customFingerprints: PackageFingerprintStorage ? = . none,
582
590
customMirrors: DependencyMirrors ? = . none,
583
591
customToolsVersion: ToolsVersion ? = . none,
592
+ customHostToolchain: UserToolchain ? = . none,
584
593
customManifestLoader: ManifestLoaderProtocol ? = . none,
585
594
customPackageContainerProvider: PackageContainerProvider ? = . none,
586
595
customRepositoryManager: RepositoryManager ? = . none,
@@ -603,6 +612,7 @@ public class Workspace {
603
612
customFingerprints: customFingerprints,
604
613
customMirrors: customMirrors,
605
614
customToolsVersion: customToolsVersion,
615
+ customHostToolchain: customHostToolchain,
606
616
customManifestLoader: customManifestLoader,
607
617
customPackageContainerProvider: customPackageContainerProvider,
608
618
customRepositoryManager: customRepositoryManager,
@@ -628,6 +638,7 @@ public class Workspace {
628
638
customFingerprints: PackageFingerprintStorage ? ,
629
639
customMirrors: DependencyMirrors ? ,
630
640
customToolsVersion: ToolsVersion ? ,
641
+ customHostToolchain: UserToolchain ? ,
631
642
customManifestLoader: ManifestLoaderProtocol ? ,
632
643
customPackageContainerProvider: PackageContainerProvider ? ,
633
644
customRepositoryManager: RepositoryManager ? ,
@@ -648,8 +659,9 @@ public class Workspace {
648
659
649
660
let currentToolsVersion = customToolsVersion ?? ToolsVersion . currentToolsVersion
650
661
let toolsVersionLoader = ToolsVersionLoader ( currentToolsVersion: currentToolsVersion)
651
- let manifestLoader = try customManifestLoader ?? ManifestLoader (
652
- toolchain: UserToolchain ( destination: . hostDestination( ) ) . configuration,
662
+ let hostToolchain = try customHostToolchain ?? UserToolchain ( destination: . hostDestination( ) )
663
+ let manifestLoader = customManifestLoader ?? ManifestLoader (
664
+ toolchain: hostToolchain. configuration,
653
665
cacheDir: location. sharedManifestsCacheDirectory
654
666
)
655
667
@@ -711,6 +723,7 @@ public class Workspace {
711
723
self . delegate = delegate
712
724
self . mirrors = mirrors
713
725
self . authorizationProvider = authorizationProvider
726
+ self . hostToolchain = hostToolchain
714
727
self . manifestLoader = manifestLoader
715
728
self . currentToolsVersion = currentToolsVersion
716
729
self . toolsVersionLoader = toolsVersionLoader
@@ -2443,7 +2456,6 @@ extension Workspace {
2443
2456
let indexFiles = artifacts. filter { $0. url. pathExtension. lowercased ( ) == " artifactbundleindex " }
2444
2457
if !indexFiles. isEmpty {
2445
2458
let errors = ThreadSafeArrayStore < Error > ( )
2446
- let hostToolchain = try UserToolchain ( destination: . hostDestination( ) )
2447
2459
let jsonDecoder = JSONDecoder . makeWithDefaults ( )
2448
2460
for indexFile in indexFiles {
2449
2461
group. enter ( )
@@ -2468,8 +2480,8 @@ extension Workspace {
2468
2480
}
2469
2481
let metadata = try jsonDecoder. decode ( ArchiveIndexFile . self, from: body)
2470
2482
// FIXME: this filter needs to become more sophisticated
2471
- guard let supportedArchive = metadata. archives. first ( where: { $0. fileName. lowercased ( ) . hasSuffix ( " .zip " ) && $0. supportedTriples. contains ( hostToolchain. triple) } ) else {
2472
- throw StringError ( " No supported archive was found for ' \( hostToolchain. triple. tripleString) ' " )
2483
+ guard let supportedArchive = metadata. archives. first ( where: { $0. fileName. lowercased ( ) . hasSuffix ( " .zip " ) && $0. supportedTriples. contains ( self . hostToolchain. triple) } ) else {
2484
+ throw StringError ( " No supported archive was found for ' \( self . hostToolchain. triple. tripleString) ' " )
2473
2485
}
2474
2486
// add relevant archive
2475
2487
zipArtifacts. append (
0 commit comments