Skip to content

Commit b817df1

Browse files
committed
[PubGrub] Filter prebuilt library assigments before loading their packages
This avoid redundant work for packages that not yet cached or need a fetch.
1 parent ee6a58d commit b817df1

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

Sources/PackageGraph/Resolution/PubGrub/PubGrubDependencyResolver.swift

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,7 @@ public struct PubGrubDependencyResolver {
160160
}
161161

162162
do {
163-
// Strip packages that have prebuilt libraries only if they match library version.
164-
//
165-
// FIXME: This is built on assumption that libraries are part of the SDK and are
166-
// always available in include/library paths, but what happens if they are
167-
// part of a toolchain instead? Builder needs an indicator that certain path
168-
// has to be included when building packages that depend on prebuilt libraries.
169-
let bindings = try self.solve(root: root, constraints: constraints).bindings.filter {
170-
if case let .version(version) = $0.boundVersion {
171-
if let library = $0.package.matchingPrebuiltLibrary(in: self.availableLibraries) {
172-
return .init(stringLiteral: library.version) != version
173-
}
174-
}
175-
return true
176-
}
163+
let bindings = try self.solve(root: root, constraints: constraints).bindings
177164
return .success(bindings)
178165
} catch {
179166
// If version solving failing, build the user-facing diagnostic.
@@ -238,6 +225,8 @@ public struct PubGrubDependencyResolver {
238225
continue
239226
}
240227

228+
let package = assignment.term.node.package
229+
241230
let boundVersion: BoundVersion
242231
switch assignment.term.requirement {
243232
case .exact(let version):
@@ -246,10 +235,22 @@ public struct PubGrubDependencyResolver {
246235
throw InternalError("unexpected requirement value for assignment \(assignment.term)")
247236
}
248237

238+
// Strip packages that have prebuilt libraries only if they match library version.
239+
//
240+
// FIXME: This is built on assumption that libraries are part of the SDK and are
241+
// always available in include/library paths, but what happens if they are
242+
// part of a toolchain instead? Builder needs an indicator that certain path
243+
// has to be included when building packages that depend on prebuilt libraries.
244+
if let library = package.matchingPrebuiltLibrary(in: availableLibraries),
245+
boundVersion == .version(.init(stringLiteral: library.version))
246+
{
247+
continue
248+
}
249+
249250
let products = assignment.term.node.productFilter
250251

251252
// TODO: replace with async/await when available
252-
let container = try temp_await { provider.getContainer(for: assignment.term.node.package, completion: $0) }
253+
let container = try temp_await { provider.getContainer(for: package, completion: $0) }
253254
let updatePackage = try container.underlying.loadPackageReference(at: boundVersion)
254255

255256
if var existing = flattenedAssignments[updatePackage] {

0 commit comments

Comments
 (0)