@@ -1425,7 +1425,8 @@ extension Workspace {
1425
1425
// FIXME: this logic should be changed to use identity instead of location once identity is unique
1426
1426
public func loadDependencyManifests(
1427
1427
root: PackageGraphRoot ,
1428
- diagnostics: DiagnosticsEngine
1428
+ diagnostics: DiagnosticsEngine ,
1429
+ automaticallyAddManagedDependencies: Bool = false
1429
1430
) throws -> DependencyManifests {
1430
1431
// Utility Just because a raw tuple cannot be hashable.
1431
1432
struct Key : Hashable {
@@ -1476,6 +1477,13 @@ extension Workspace {
1476
1477
let allManifestsWithPossibleDuplicates = try topologicalSort ( inputPairs) { pair in
1477
1478
// optimization: preload manifest we know about in parallel
1478
1479
let dependenciesRequired = pair. item. dependenciesRequired ( for: pair. key. productFilter)
1480
+ // prepopulate managed dependencies if we are asked to do so
1481
+ if automaticallyAddManagedDependencies {
1482
+ dependenciesRequired. filter { $0. isLocal } . forEach { dependency in
1483
+ state. dependencies. add ( ManagedDependency . local ( packageRef: dependency. createPackageRef ( ) ) )
1484
+ }
1485
+ diagnostics. wrap { try state. saveState ( ) }
1486
+ }
1479
1487
let dependenciesRequiredURLs = dependenciesRequired. map { $0. location } . filter { !loadedManifests. keys. contains ( $0) }
1480
1488
// note: loadManifest emits diagnostics in case it fails
1481
1489
let dependenciesRequiredManifests = try temp_await { self . loadManifests ( forURLs: dependenciesRequiredURLs, diagnostics: diagnostics, completion: $0) }
@@ -2013,19 +2021,7 @@ extension Workspace {
2013
2021
}
2014
2022
}
2015
2023
2016
- // Save state for local packages, if any.
2017
- //
2018
- // FIXME: This will only work for top-level local packages right now.
2019
- for rootManifest in rootManifests. values {
2020
- let dependencies = rootManifest. dependencies. filter { $0. isLocal }
2021
- for localPackage in dependencies {
2022
- let package = localPackage. createPackageRef ( )
2023
- state. dependencies. add ( ManagedDependency . local ( packageRef: package ) )
2024
- }
2025
- }
2026
- diagnostics. wrap { try state. saveState ( ) }
2027
-
2028
- let currentManifests = try self . loadDependencyManifests ( root: graphRoot, diagnostics: diagnostics)
2024
+ let currentManifests = try self . loadDependencyManifests ( root: graphRoot, diagnostics: diagnostics, automaticallyAddManagedDependencies: true )
2029
2025
2030
2026
let precomputationResult = try precomputeResolution (
2031
2027
root: graphRoot,
0 commit comments