Skip to content

Commit 6a719f4

Browse files
committed
[Workspace] Augment resolution based on Package.resolved to support provided libraries
If a package with a provided library is mentioned in the Package.resolved let's check whether the version of the library matches pinned version of the package and is so, switch to the library.
1 parent a76b970 commit 6a719f4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Sources/Workspace/Workspace+Dependencies.swift

+17-1
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,20 @@ extension Workspace {
371371
// automatically manage the parallelism.
372372
let group = DispatchGroup()
373373
for pin in pinsStore.pins.values {
374+
// Provided library doesn't have a container, we need to inject a special depedency.
375+
if let library = pin.packageRef.matchingPrebuiltLibrary(in: self.providedLibraries),
376+
case .version(library.version, _) = pin.state
377+
{
378+
try self.state.dependencies.add(
379+
.providedLibrary(
380+
packageRef: pin.packageRef,
381+
library: library
382+
)
383+
)
384+
try self.state.save()
385+
continue
386+
}
387+
374388
group.enter()
375389
let observabilityScope = observabilityScope.makeChildScope(
376390
description: "requesting package containers",
@@ -418,7 +432,9 @@ extension Workspace {
418432
return !pin.state.equals(checkoutState)
419433
case .registryDownload(let version):
420434
return !pin.state.equals(version)
421-
case .edited, .fileSystem, .providedLibrary, .custom:
435+
case .providedLibrary:
436+
return false
437+
case .edited, .fileSystem, .custom:
422438
return true
423439
}
424440
}

0 commit comments

Comments
 (0)