Skip to content

Commit

Permalink
Do not consider dependencies of non-buildable components.
Browse files Browse the repository at this point in the history
When configuring a package, the condition trees in the package
descriptions are evaluated according to the known configuration
and flag assignment.

During this process, it becomes also known whether a component
has its "Buildable" flag set to True or False. We now disregard
all dependencies of non-buildable components.
  • Loading branch information
kosmikus authored and grayjay committed Jan 14, 2016
1 parent 928850d commit 53d85bb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Cabal/Distribution/PackageDescription/Configuration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ resolveWithFlags dom os arch impl constrs trees checkDeps =

-- simplify trees by (partially) evaluating all conditions and converting
-- dependencies to dependency maps.
simplifiedTrees :: [CondTree FlagName DependencyMap PDTagged]
simplifiedTrees = map ( mapTreeConstrs toDepMap -- convert to maps
. mapTreeConds (fst . simplifyWithSysParams os arch impl))
trees
Expand All @@ -228,6 +229,9 @@ resolveWithFlags dom os arch impl constrs trees checkDeps =
-- either succeeds or returns a binary tree with the missing dependencies
-- encountered in each run. Since the tree is constructed lazily, we
-- avoid some computation overhead in the successful case.
try :: [(FlagName, [Bool])]
-> [(FlagName, Bool)]
-> Either (BT [Dependency]) (TargetSet PDTagged, FlagAssignment)
try [] flags =
let targetSet = TargetSet $ flip map simplifiedTrees $
-- apply additional constraints to all dependencies
Expand Down Expand Up @@ -337,11 +341,11 @@ overallDependencies (TargetSet targets) = mconcat depss
where
(depss, _) = unzip $ filter (removeDisabledSections . snd) targets
removeDisabledSections :: PDTagged -> Bool
removeDisabledSections (Lib _) = True
removeDisabledSections (Exe _ _) = True
removeDisabledSections (Test _ t) = testEnabled t
removeDisabledSections (Bench _ b) = benchmarkEnabled b
removeDisabledSections PDNull = True
removeDisabledSections (Lib l) = buildable (libBuildInfo l)
removeDisabledSections (Exe _ e) = buildable (buildInfo e)
removeDisabledSections (Test _ t) = testEnabled t && buildable (testBuildInfo t)
removeDisabledSections (Bench _ b) = benchmarkEnabled b && buildable (benchmarkBuildInfo b)
removeDisabledSections PDNull = True

-- Apply extra constraints to a dependency map.
-- Combines dependencies where the result will only contain keys from the left
Expand Down Expand Up @@ -482,10 +486,6 @@ finalizePackageDescription userflags satisfyDep
, testSuites = tests'
, benchmarks = bms'
, buildDepends = fromDepMap (overallDependencies targetSet)
--TODO: we need to find a way to avoid pulling in deps
-- for non-buildable components. However cannot simply
-- filter at this stage, since if the package were not
-- available we would have failed already.
}
, flagVals )

Expand Down

0 comments on commit 53d85bb

Please sign in to comment.