Skip to content

Commit

Permalink
Introduce InstallPlan.depends = nodeNeighbors and use it.
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Aug 21, 2016
1 parent c41ead7 commit f63273d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions cabal-install/Distribution/Client/InstallPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module Distribution.Client.InstallPlan (
new,
toList,
planIndepGoals,
depends,

fromSolverInstallPlan,
configureInstallPlan,
Expand Down Expand Up @@ -161,6 +162,9 @@ data GenericPlanPackage ipkg srcpkg

type IsUnit a = (IsNode a, Key a ~ UnitId)

depends :: IsUnit a => a -> [UnitId]
depends = nodeNeighbors

-- NB: Expanded constraint synonym here to avoid undecidable
-- instance errors in GHC 7.8 and earlier.
instance (IsNode ipkg, IsNode srcpkg, Key ipkg ~ UnitId, Key srcpkg ~ UnitId)
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/Distribution/Client/ProjectBuilding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ foldMInstallPlanDepOrder plan0 visit =
depresults =
map (\ipkgid -> let Just result = Map.lookup ipkgid results
in result)
(nodeNeighbors pkg)
(InstallPlan.depends pkg)
result <- visit pkg depresults
let results' = Map.insert (nodeKey pkg) result results
go results' pkgs
Expand Down
11 changes: 6 additions & 5 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1744,9 +1744,10 @@ pruneInstallPlanPass1 perPkgTargetsMap pkgs =
-- stanzas in the next pass.
--
pruneOptionalDependencies :: ElaboratedConfiguredPackage -> [UnitId]
pruneOptionalDependencies elab@ElaboratedConfiguredPackage{ elabPkgOrComp = ElabComponent _ } = nodeNeighbors elab -- no pruning
pruneOptionalDependencies ElaboratedConfiguredPackage{ elabPkgOrComp = ElabPackage pkg } =
(CD.flatDeps . CD.filterDeps keepNeeded) (pkgOrderDependencies pkg)
pruneOptionalDependencies elab@ElaboratedConfiguredPackage{ elabPkgOrComp = ElabComponent _ }
= InstallPlan.depends elab -- no pruning
pruneOptionalDependencies ElaboratedConfiguredPackage{ elabPkgOrComp = ElabPackage pkg }
= (CD.flatDeps . CD.filterDeps keepNeeded) (pkgOrderDependencies pkg)
where
keepNeeded (CD.ComponentTest _) _ = TestStanzas `Set.member` stanzas
keepNeeded (CD.ComponentBench _) _ = BenchStanzas `Set.member` stanzas
Expand Down Expand Up @@ -1865,7 +1866,7 @@ pruneInstallPlanPass2 pkgs =
hasReverseLibDeps :: Set UnitId
hasReverseLibDeps =
Set.fromList [ depid | pkg <- pkgs
, depid <- nodeNeighbors pkg ]
, depid <- InstallPlan.depends pkg ]

mapConfiguredPackage :: (srcpkg -> srcpkg')
-> InstallPlan.GenericPlanPackage ipkg srcpkg
Expand Down Expand Up @@ -2211,7 +2212,7 @@ setupHsConfigureFlags (ReadyPackage elab@ElaboratedConfiguredPackage{..})

-- we only use configDependencies, unless we're talking to an old Cabal
-- in which case we use configConstraints
-- NB: This does NOT use nodeNeighbors, which includes executable
-- NB: This does NOT use InstallPlan.depends, which includes executable
-- dependencies which should NOT be fed in here (also you don't have
-- enough info anyway)
configDependencies = [ (packageName srcid, cid)
Expand Down

0 comments on commit f63273d

Please sign in to comment.