Skip to content

Commit 04dff51

Browse files
committed
Revert the change to filter out deps of non-buildable components
It does not work as intended and gives inconsistent results between cabal install and cabal configure. The problem with the approach was that we were filtering out the dependencies of non-buildable components at the end. But that does not help much since if one of the deps of the non-buildable component were not available then we would have failed earlier with a constraint failure. A proper solution would have to tackle it from the beginning, not just as a filter at the end. The meaning of build-depends and buildable: False needs more thought.
1 parent 485b212 commit 04dff51

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

Distribution/PackageDescription/Configuration.hs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ import Distribution.PackageDescription
6565
, Flag(..), FlagName(..), FlagAssignment
6666
, CondTree(..), ConfVar(..), Condition(..) )
6767
import Distribution.Version
68-
( VersionRange, anyVersion, intersectVersionRanges, withinRange
69-
, toVersionIntervals, intersectVersionIntervals
70-
, fromVersionIntervals )
68+
( VersionRange, anyVersion, intersectVersionRanges, withinRange )
7169
import Distribution.Compiler
7270
( CompilerId(CompilerId) )
7371
import Distribution.System
@@ -81,7 +79,6 @@ import Distribution.Compat.ReadP as ReadP hiding ( char )
8179
import Control.Arrow (first)
8280
import qualified Distribution.Compat.ReadP as ReadP ( char )
8381

84-
import Control.Exception (assert)
8582
import Data.Char ( isAlphaNum )
8683
import Data.Maybe ( catMaybes, maybeToList )
8784
import Data.Map ( Map, fromListWith, toList )
@@ -489,29 +486,13 @@ finalizePackageDescription userflags satisfyDep (Platform arch os) impl constrai
489486
Right ((mlib, exes'), targetSet, flagVals) ->
490487
Right ( pkg { library = mlib
491488
, executables = exes'
492-
, buildDepends = assert sanity overallDeps
489+
, buildDepends = fromDepMap (overallDependencies targetSet)
490+
--TODO: we need to find a way to avoid pulling in deps
491+
-- for non-buildable components. However cannot simply
492+
-- filter at this stage, since if the package were not
493+
-- available we would have failed already.
493494
}
494495
, flagVals )
495-
where
496-
-- Note that we exclude non-buildable components. This means your tools and
497-
-- test progs to not contribute to the overall package dependencies.
498-
--
499-
overallDeps = canonicalise
500-
. concatMap targetBuildDepends
501-
. filter buildable
502-
$ buildInfos
503-
buildInfos = map libBuildInfo (maybeToList mlib) ++ map buildInfo exes'
504-
505-
-- as a sanity check, check that the overall deps from the target set
506-
-- matches those from the (unfiltered for being buildable) components
507-
sanity = canonicalise overallDeps' == canonicalise overallDeps''
508-
overallDeps' = concatMap targetBuildDepends buildInfos
509-
overallDeps'' = fromDepMap (overallDependencies targetSet)
510-
canonicalise =
511-
map (\(name, vi) -> Dependency name (fromVersionIntervals vi))
512-
. Map.toList
513-
. Map.fromListWith intersectVersionIntervals
514-
. map (\(Dependency name vr) -> (name, toVersionIntervals vr))
515496

516497
Left missing -> Left missing
517498
where

0 commit comments

Comments
 (0)