@@ -23,52 +23,6 @@ public enum ManifestParseError: Swift.Error, Equatable {
23
23
case runtimeManifestErrors( [ String ] )
24
24
}
25
25
26
- /// Resources required for manifest loading.
27
- ///
28
- /// These requirements are abstracted out to make it easier to add support for
29
- /// using the package manager with alternate toolchains in the future.
30
- public protocol ManifestResourceProvider {
31
- /// The path of the swift compiler.
32
- var swiftCompiler : AbsolutePath { get }
33
-
34
- /// The path of the library resources.
35
- var libDir : AbsolutePath { get }
36
-
37
- /// The path to SDK root.
38
- ///
39
- /// If provided, it will be passed to the swift interpreter.
40
- var sdkRoot : AbsolutePath ? { get }
41
-
42
- /// The bin directory.
43
- var binDir : AbsolutePath ? { get }
44
-
45
- /// Extra flags to pass the Swift compiler.
46
- var swiftCompilerFlags : [ String ] { get }
47
-
48
- /// XCTest Location
49
- var xctestLocation : AbsolutePath ? { get }
50
- }
51
-
52
- /// Default implemention for the resource provider.
53
- public extension ManifestResourceProvider {
54
-
55
- var sdkRoot : AbsolutePath ? {
56
- return nil
57
- }
58
-
59
- var binDir : AbsolutePath ? {
60
- return nil
61
- }
62
-
63
- var swiftCompilerFlags : [ String ] {
64
- return [ ]
65
- }
66
-
67
- var xctestLocation : AbsolutePath ? {
68
- return nil
69
- }
70
- }
71
-
72
26
/// Protocol for the manifest loader interface.
73
27
public protocol ManifestLoaderProtocol {
74
28
/// Load the manifest for the package at `path`.
@@ -124,7 +78,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
124
78
private static var _hostTriple = ThreadSafeBox < Triple > ( )
125
79
private static var _packageDescriptionMinimumDeploymentTarget = ThreadSafeBox < String > ( )
126
80
127
- private let resources : ManifestResourceProvider
81
+ private let toolchain : ToolchainConfiguration
128
82
private let serializedDiagnostics : Bool
129
83
private let isManifestSandboxEnabled : Bool
130
84
private let delegate : ManifestLoaderDelegate ?
@@ -137,14 +91,14 @@ public final class ManifestLoader: ManifestLoaderProtocol {
137
91
private let operationQueue : OperationQueue
138
92
139
93
public init (
140
- manifestResources : ManifestResourceProvider ,
94
+ toolchain : ToolchainConfiguration ,
141
95
serializedDiagnostics: Bool = false ,
142
96
isManifestSandboxEnabled: Bool = true ,
143
97
cacheDir: AbsolutePath ? = nil ,
144
98
delegate: ManifestLoaderDelegate ? = nil ,
145
99
extraManifestFlags: [ String ] = [ ]
146
100
) {
147
- self . resources = manifestResources
101
+ self . toolchain = toolchain
148
102
self . serializedDiagnostics = serializedDiagnostics
149
103
self . isManifestSandboxEnabled = isManifestSandboxEnabled
150
104
self . delegate = delegate
@@ -157,6 +111,26 @@ public final class ManifestLoader: ManifestLoaderProtocol {
157
111
self . operationQueue. maxConcurrentOperationCount = Concurrency . maxOperations
158
112
}
159
113
114
+ // deprecated 8/2021
115
+ @available ( * , deprecated, message: " use non-deprecated constructor instead " )
116
+ public convenience init (
117
+ manifestResources: ToolchainConfiguration ,
118
+ serializedDiagnostics: Bool = false ,
119
+ isManifestSandboxEnabled: Bool = true ,
120
+ cacheDir: AbsolutePath ? = nil ,
121
+ delegate: ManifestLoaderDelegate ? = nil ,
122
+ extraManifestFlags: [ String ] = [ ]
123
+ ) {
124
+ self . init (
125
+ toolchain: manifestResources,
126
+ serializedDiagnostics: serializedDiagnostics,
127
+ isManifestSandboxEnabled: isManifestSandboxEnabled,
128
+ cacheDir: cacheDir,
129
+ delegate: delegate,
130
+ extraManifestFlags: extraManifestFlags
131
+ )
132
+ }
133
+
160
134
/// Loads a root manifest from a path using the resources associated with a particular `swiftc` executable.
161
135
///
162
136
/// - Parameters:
@@ -177,8 +151,8 @@ public final class ManifestLoader: ManifestLoaderProtocol {
177
151
completion: @escaping ( Result < Manifest , Error > ) -> Void
178
152
) {
179
153
do {
180
- let resources = try UserManifestResources ( swiftCompiler: swiftCompiler, swiftCompilerFlags: swiftCompilerFlags)
181
- let loader = ManifestLoader ( manifestResources : resources )
154
+ let toolchain = try ToolchainConfiguration ( swiftCompiler: swiftCompiler, swiftCompilerFlags: swiftCompilerFlags)
155
+ let loader = ManifestLoader ( toolchain : toolchain )
182
156
let toolsVersion = try ToolsVersionLoader ( ) . load ( at: path, fileSystem: fileSystem)
183
157
let packageLocation = fileSystem. isFile ( path) ? path. parentDirectory : path
184
158
let packageIdentity = identityResolver. resolveIdentity ( for: packageLocation)
@@ -713,14 +687,14 @@ public final class ManifestLoader: ManifestLoaderProtocol {
713
687
let moduleCachePath = ( ProcessEnv . vars [ " SWIFTPM_MODULECACHE_OVERRIDE " ] ?? ProcessEnv . vars [ " SWIFTPM_TESTS_MODULECACHE " ] ) . flatMap { AbsolutePath . init ( $0) }
714
688
715
689
var cmd : [ String ] = [ ]
716
- cmd += [ resources . swiftCompiler. pathString]
690
+ cmd += [ self . toolchain . swiftCompiler. pathString]
717
691
cmd += verbosity. ccArgs
718
692
719
693
let macOSPackageDescriptionPath : AbsolutePath
720
694
// If we got the binDir that means we could be developing SwiftPM in Xcode
721
695
// which produces a framework for dynamic package products.
722
696
let packageFrameworkPath = runtimePath. appending ( component: " PackageFrameworks " )
723
- if resources . binDir != nil , localFileSystem. exists ( packageFrameworkPath) {
697
+ if self . toolchain . binDir != nil , localFileSystem. exists ( packageFrameworkPath) {
724
698
cmd += [
725
699
" -F " , packageFrameworkPath. pathString,
726
700
" -framework " , " PackageDescription " ,
@@ -746,7 +720,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
746
720
// Use the same minimum deployment target as the PackageDescription library (with a fallback of 10.15).
747
721
#if os(macOS)
748
722
let triple = Self . _hostTriple. memoize {
749
- Triple . getHostTriple ( usingSwiftCompiler: resources . swiftCompiler)
723
+ Triple . getHostTriple ( usingSwiftCompiler: self . toolchain . swiftCompiler)
750
724
}
751
725
752
726
let version = try Self . _packageDescriptionMinimumDeploymentTarget. memoize {
@@ -756,7 +730,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
756
730
#endif
757
731
758
732
// Add any extra flags required as indicated by the ManifestLoader.
759
- cmd += resources . swiftCompilerFlags
733
+ cmd += self . toolchain . swiftCompilerFlags
760
734
761
735
cmd += self . interpreterFlags ( for: toolsVersion)
762
736
if let moduleCachePath = moduleCachePath {
@@ -879,7 +853,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
879
853
cmd += [ " -swift-version " , toolsVersion. swiftLanguageVersion. rawValue]
880
854
cmd += [ " -I " , runtimePath. pathString]
881
855
#if os(macOS)
882
- if let sdkRoot = resources . sdkRoot ?? self . sdkRoot ( ) {
856
+ if let sdkRoot = self . toolchain . sdkRoot ?? self . sdkRoot ( ) {
883
857
cmd += [ " -sdk " , sdkRoot. pathString]
884
858
}
885
859
#endif
@@ -890,18 +864,18 @@ public final class ManifestLoader: ManifestLoaderProtocol {
890
864
/// Returns the runtime path given the manifest version and path to libDir.
891
865
private func runtimePath( for version: ToolsVersion ) -> AbsolutePath {
892
866
// Bin dir will be set when developing swiftpm without building all of the runtimes.
893
- if let binDir = resources . binDir {
867
+ if let binDir = self . toolchain . binDir {
894
868
return binDir
895
869
}
896
870
897
871
// Otherwise we use the standard location of the manifest API in the toolchain, if it exists.
898
- let manifestAPIDir = resources . libDir. appending ( component: " ManifestAPI " )
872
+ let manifestAPIDir = self . toolchain . libDir. appending ( component: " ManifestAPI " )
899
873
if localFileSystem. exists ( manifestAPIDir) {
900
874
return manifestAPIDir
901
875
}
902
876
903
877
// Otherwise, fall back on the old location (this would indicate that we're using an old toolchain).
904
- return resources . libDir. appending ( version. runtimeSubpath)
878
+ return self . toolchain . libDir. appending ( version. runtimeSubpath)
905
879
}
906
880
907
881
/// Returns path to the manifest database inside the given cache directory.
0 commit comments