Commit b01171ba authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Fix freeze constraints to include flags of local packages

We deliberately exclude version constraints of packages that are local
to the project (since their versions are fixed to be what they are
anyway, and it'd just make it harder to bump versions etc). However the
flag constraints of local packages were also being ignored, which leads
to "slushy" frozen files.

We saw this in practice with leksah where the flag gtk-3.18 was varying
between different users and causing great confusion.
parent dd012e4a
......@@ -133,14 +133,15 @@ projectFreezeConstraints plan =
--
-- For the moment we deal with multiple versions in the solution by using
-- constraints that allow either version. Also, we do not include any
-- constraints for packages that are local to the project (e.g. if the
-- solution has two instances of Cabal, one from the local project and one
-- pulled in as a setup deps then we exclude all constraints on Cabal, not
-- just the constraint for the local instance since any constraint would
-- apply to both instances).
-- /version/ constraints for packages that are local to the project (e.g.
-- if the solution has two instances of Cabal, one from the local project
-- and one pulled in as a setup deps then we exclude all constraints on
-- Cabal, not just the constraint for the local instance since any
-- constraint would apply to both instances). We do however keep flag
-- constraints of local packages.
--
Map.unionWith (++) versionConstraints flagConstraints
`Map.difference` localPackages
deleteLocalPackagesVersionConstraints
(Map.unionWith (++) versionConstraints flagConstraints)
where
versionConstraints :: Map PackageName [(UserConstraint, ConstraintSource)]
versionConstraints =
......@@ -173,6 +174,23 @@ projectFreezeConstraints plan =
pkgname = packageName elab
, not (null flags) ]
-- As described above, remove the version constraints on local packages,
-- but leave any flag constraints.
deleteLocalPackagesVersionConstraints
:: Map PackageName [(UserConstraint, ConstraintSource)]
-> Map PackageName [(UserConstraint, ConstraintSource)]
deleteLocalPackagesVersionConstraints =
Map.mergeWithKey
(\_pkgname () constraints ->
case filter (not . isVersionConstraint . fst) constraints of
[] -> Nothing
constraints' -> Just constraints')
(const Map.empty) id
localPackages
isVersionConstraint UserConstraintVersion{} = True
isVersionConstraint _ = False
localPackages :: Map PackageName ()
localPackages =
Map.fromList
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment