@@ -607,10 +607,15 @@ extension Workspace {
607
607
let constraint = PackageContainerConstraint ( package : dependency. packageRef, requirement: requirement, products: . nothing)
608
608
609
609
// Run the resolution.
610
- try self . _resolve ( root: root, forceResolution: false , extraConstraints: [ constraint] , diagnostics: diagnostics)
610
+ try self . resolve (
611
+ root: root,
612
+ forceResolution: false ,
613
+ constraints: [ constraint] ,
614
+ diagnostics: diagnostics
615
+ )
611
616
}
612
617
613
- /// Cleans the build artefacts from workspace data.
618
+ /// Cleans the build artifacts from workspace data.
614
619
///
615
620
/// - Parameters:
616
621
/// - diagnostics: The diagnostics engine that reports errors, warnings
@@ -809,16 +814,17 @@ extension Workspace {
809
814
// Perform dependency resolution, if required.
810
815
let manifests : DependencyManifests
811
816
if forceResolvedVersions {
812
- manifests = try self . _resolveToResolvedVersion (
817
+ manifests = try self . resolveBasedOnResolvedVersionsFile (
813
818
root: root,
814
819
explicitProduct: explicitProduct,
815
820
diagnostics: diagnostics
816
821
)
817
822
} else {
818
- manifests = try self . _resolve (
823
+ manifests = try self . resolve (
819
824
root: root,
820
825
explicitProduct: explicitProduct,
821
826
forceResolution: false ,
827
+ constraints: [ ] ,
822
828
diagnostics: diagnostics
823
829
)
824
830
}
@@ -868,7 +874,12 @@ extension Workspace {
868
874
forceResolution: Bool = false ,
869
875
diagnostics: DiagnosticsEngine
870
876
) throws {
871
- try self . _resolve ( root: root, forceResolution: forceResolution, diagnostics: diagnostics)
877
+ try self . resolve (
878
+ root: root,
879
+ forceResolution: forceResolution,
880
+ constraints: [ ] ,
881
+ diagnostics: diagnostics
882
+ )
872
883
}
873
884
874
885
/// Loads and returns manifests at the given paths.
@@ -1966,29 +1977,31 @@ extension Workspace {
1966
1977
1967
1978
extension Workspace {
1968
1979
1980
+ @available ( * , deprecated, message: " renamed to resolveBasedOnResolvedVersionsFile " )
1981
+ public func resolveToResolvedVersion( root: PackageGraphRootInput , diagnostics: DiagnosticsEngine ) throws {
1982
+ try self . resolveBasedOnResolvedVersionsFile ( root: root, diagnostics: diagnostics)
1983
+ }
1984
+
1969
1985
/// Resolves the dependencies according to the entries present in the Package.resolved file.
1970
1986
///
1971
1987
/// This method bypasses the dependency resolution and resolves dependencies
1972
1988
/// according to the information in the resolved file.
1973
- public func resolveToResolvedVersion(
1974
- root: PackageGraphRootInput ,
1975
- diagnostics: DiagnosticsEngine
1976
- ) throws {
1977
- try self . _resolveToResolvedVersion ( root: root, diagnostics: diagnostics)
1989
+ public func resolveBasedOnResolvedVersionsFile( root: PackageGraphRootInput , diagnostics: DiagnosticsEngine ) throws {
1990
+ try self . resolveBasedOnResolvedVersionsFile ( root: root, explicitProduct: . none, diagnostics: diagnostics)
1978
1991
}
1979
1992
1980
1993
/// Resolves the dependencies according to the entries present in the Package.resolved file.
1981
1994
///
1982
1995
/// This method bypasses the dependency resolution and resolves dependencies
1983
1996
/// according to the information in the resolved file.
1984
1997
@discardableResult
1985
- fileprivate func _resolveToResolvedVersion (
1998
+ fileprivate func resolveBasedOnResolvedVersionsFile (
1986
1999
root: PackageGraphRootInput ,
1987
- explicitProduct: String ? = nil ,
2000
+ explicitProduct: String ? ,
1988
2001
diagnostics: DiagnosticsEngine
1989
2002
) throws -> DependencyManifests {
1990
2003
// Ensure the cache path exists.
1991
- createCacheDirectories ( with: diagnostics)
2004
+ self . createCacheDirectories ( with: diagnostics)
1992
2005
1993
2006
// FIXME: this should not block
1994
2007
let rootManifests = try temp_await { self . loadRootManifests ( packages: root. packages, diagnostics: diagnostics, completion: $0) }
@@ -2032,10 +2045,11 @@ extension Workspace {
2032
2045
2033
2046
let currentManifests = try self . loadDependencyManifests ( root: graphRoot, diagnostics: diagnostics, automaticallyAddManagedDependencies: true )
2034
2047
2035
- let precomputationResult = try precomputeResolution (
2048
+ let precomputationResult = try self . precomputeResolution (
2036
2049
root: graphRoot,
2037
2050
dependencyManifests: currentManifests,
2038
- pinsStore: pinsStore
2051
+ pinsStore: pinsStore,
2052
+ constraints: [ ]
2039
2053
)
2040
2054
2041
2055
if case let . required( reason) = precomputationResult {
@@ -2060,18 +2074,18 @@ extension Workspace {
2060
2074
/// imposed outside of manifest and pins file. E.g., when using a command
2061
2075
/// like `$ swift package resolve foo --version 1.0.0`.
2062
2076
@discardableResult
2063
- fileprivate func _resolve (
2077
+ fileprivate func resolve (
2064
2078
root: PackageGraphRootInput ,
2065
2079
explicitProduct: String ? = nil ,
2066
2080
forceResolution: Bool ,
2067
- extraConstraints : [ PackageContainerConstraint ] = [ ] ,
2081
+ constraints : [ PackageContainerConstraint ] ,
2068
2082
diagnostics: DiagnosticsEngine ,
2069
2083
retryOnPackagePathMismatch: Bool = true ,
2070
2084
resetPinsStoreOnFailure: Bool = true
2071
2085
) throws -> DependencyManifests {
2072
2086
2073
2087
// Ensure the cache path exists and validate that edited dependencies.
2074
- createCacheDirectories ( with: diagnostics)
2088
+ self . createCacheDirectories ( with: diagnostics)
2075
2089
2076
2090
// FIXME: this should not block
2077
2091
// Load the root manifests and currently checked out manifests.
@@ -2098,14 +2112,14 @@ extension Workspace {
2098
2112
// there are extra constraints.
2099
2113
if !missingPackageURLs. isEmpty {
2100
2114
delegate? . willResolveDependencies ( reason: . newPackages( packages: Array ( missingPackageURLs) ) )
2101
- } else if !extraConstraints . isEmpty || forceResolution {
2115
+ } else if !constraints . isEmpty || forceResolution {
2102
2116
delegate? . willResolveDependencies ( reason: . forced)
2103
2117
} else {
2104
- let result = try precomputeResolution (
2118
+ let result = try self . precomputeResolution (
2105
2119
root: graphRoot,
2106
2120
dependencyManifests: currentManifests,
2107
2121
pinsStore: pinsStore,
2108
- extraConstraints : extraConstraints
2122
+ constraints : constraints
2109
2123
)
2110
2124
2111
2125
switch result {
@@ -2122,17 +2136,17 @@ extension Workspace {
2122
2136
}
2123
2137
2124
2138
// Create the constraints.
2125
- var constraints = [ PackageContainerConstraint] ( )
2126
- constraints += currentManifests. editedPackagesConstraints ( )
2127
- constraints += try graphRoot. constraints ( ) + extraConstraints
2139
+ var computedConstraints = [ PackageContainerConstraint] ( )
2140
+ computedConstraints += currentManifests. editedPackagesConstraints ( )
2141
+ computedConstraints += try graphRoot. constraints ( ) + constraints
2128
2142
2129
2143
// Perform dependency resolution.
2130
2144
let resolver = try createResolver ( pinsMap: pinsStore. pinsMap)
2131
2145
self . activeResolver = resolver
2132
2146
2133
- let result = resolveDependencies (
2147
+ let result = self . resolveDependencies (
2134
2148
resolver: resolver,
2135
- constraints: constraints ,
2149
+ constraints: computedConstraints ,
2136
2150
diagnostics: diagnostics)
2137
2151
2138
2152
// Reset the active resolver.
@@ -2163,11 +2177,11 @@ extension Workspace {
2163
2177
if retryOnPackagePathMismatch {
2164
2178
// Retry resolution which will most likely resolve correctly now since
2165
2179
// we have the manifest files of all the dependencies.
2166
- return try self . _resolve (
2180
+ return try self . resolve (
2167
2181
root: root,
2168
2182
explicitProduct: explicitProduct,
2169
2183
forceResolution: forceResolution,
2170
- extraConstraints : extraConstraints ,
2184
+ constraints : constraints ,
2171
2185
diagnostics: diagnostics,
2172
2186
retryOnPackagePathMismatch: false ,
2173
2187
resetPinsStoreOnFailure: resetPinsStoreOnFailure
@@ -2180,11 +2194,11 @@ extension Workspace {
2180
2194
pinsStore. unpinAll ( )
2181
2195
try pinsStore. saveState ( )
2182
2196
// try again with pins reset
2183
- return try self . _resolve (
2197
+ return try self . resolve (
2184
2198
root: root,
2185
2199
explicitProduct: explicitProduct,
2186
2200
forceResolution: forceResolution,
2187
- extraConstraints : extraConstraints ,
2201
+ constraints : constraints ,
2188
2202
diagnostics: diagnostics,
2189
2203
retryOnPackagePathMismatch: false ,
2190
2204
resetPinsStoreOnFailure: false
@@ -2228,18 +2242,18 @@ extension Workspace {
2228
2242
root: PackageGraphRoot ,
2229
2243
dependencyManifests: DependencyManifests ,
2230
2244
pinsStore: PinsStore ,
2231
- extraConstraints : [ PackageContainerConstraint ] = [ ]
2245
+ constraints : [ PackageContainerConstraint ]
2232
2246
) throws -> ResolutionPrecomputationResult {
2233
- let constraints =
2247
+ let computedConstraints =
2234
2248
try root. constraints ( ) +
2235
2249
// Include constraints from the manifests in the graph root.
2236
2250
root. manifests. values. flatMap { try $0. dependencyConstraints ( productFilter: . everything) } +
2237
2251
dependencyManifests. dependencyConstraints ( ) +
2238
- extraConstraints
2252
+ constraints
2239
2253
2240
2254
let precomputationProvider = ResolverPrecomputationProvider ( root: root, dependencyManifests: dependencyManifests)
2241
2255
let resolver = PubgrubDependencyResolver ( provider: precomputationProvider, pinsMap: pinsStore. pinsMap)
2242
- let result = resolver. solve ( constraints: constraints )
2256
+ let result = resolver. solve ( constraints: computedConstraints )
2243
2257
2244
2258
switch result {
2245
2259
case . success:
0 commit comments