Skip to content

Commit af6936e

Browse files
mergify[bot]gbaz
andauthored
defer build-tools-depends choices as well as setup choices (backport #7532) (#7538)
* defer build-tools-depends choices as well as setup choices (cherry picked from commit 3ac512e) * Update Preference.hs * Update Solver.hs Co-authored-by: Gershom Bazerman <[email protected]> Co-authored-by: gbaz <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 89d9257 commit af6936e

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

cabal-install/cabal-install-solver/src/Distribution/Solver/Modular/Preference.hs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- | Reordering or pruning the tree in order to prefer or make certain choices.
33
module Distribution.Solver.Modular.Preference
44
( avoidReinstalls
5-
, deferSetupChoices
5+
, deferSetupExeChoices
66
, deferWeakFlagChoices
77
, enforceManualFlags
88
, enforcePackageConstraints
@@ -400,17 +400,18 @@ preferBaseGoalChoice = trav go
400400
isBase (Goal (P (Q _pp pn)) _) = unPN pn == "base"
401401
isBase _ = False
402402

403-
-- | Deal with setup dependencies after regular dependencies, so that we can
404-
-- will link setup dependencies against package dependencies when possible
405-
deferSetupChoices :: Tree d c -> Tree d c
406-
deferSetupChoices = trav go
403+
-- | Deal with setup and build-tool-depends dependencies after regular dependencies,
404+
-- so we will link setup/exe dependencies against package dependencies when possible
405+
deferSetupExeChoices :: Tree d c -> Tree d c
406+
deferSetupExeChoices = trav go
407407
where
408-
go (GoalChoiceF rdm xs) = GoalChoiceF rdm (P.preferByKeys noSetup xs)
408+
go (GoalChoiceF rdm xs) = GoalChoiceF rdm (P.preferByKeys noSetupOrExe xs)
409409
go x = x
410410

411-
noSetup :: Goal QPN -> Bool
412-
noSetup (Goal (P (Q (PackagePath _ns (QualSetup _)) _)) _) = False
413-
noSetup _ = True
411+
noSetupOrExe :: Goal QPN -> Bool
412+
noSetupOrExe (Goal (P (Q (PackagePath _ns (QualSetup _)) _)) _) = False
413+
noSetupOrExe (Goal (P (Q (PackagePath _ns (QualExe _ _)) _)) _) = False
414+
noSetupOrExe _ = True
414415

415416
-- | Transformation that tries to avoid making weak flag choices early.
416417
-- Weak flags are trivial flags (not influencing dependencies) or such

cabal-install/cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
117117
sortGoals = case goalOrder sc of
118118
Nothing -> goalChoiceHeuristics .
119119
heuristicsTree .
120-
P.deferSetupChoices .
120+
P.deferSetupExeChoices .
121121
P.deferWeakFlagChoices .
122122
P.preferBaseGoalChoice
123123
Just order -> P.firstGoal .

0 commit comments

Comments
 (0)