Commit 5495dafc authored by kristenk's avatar kristenk Committed by Edward Z. Yang
Browse files

Add a constraint scope to constrain a given package in any setup script.

I used the new constraint scope to enforce the minimum Cabal version in setup
scripts that lack a 'custom-setup' stanza.  It isn't exposed to users yet.
parent 3003d06d
......@@ -492,16 +492,14 @@ addDefaultSetupDependencies defaultSetupDeps params =
pkgdesc = PD.packageDescription gpkgdesc
-- | If a package has a custom setup then we need to add a setup-depends
-- on Cabal. For now it's easier to add this unconditionally. Once
-- qualified constraints land we can turn this into a custom setup
-- only constraint.
-- on Cabal.
--
addSetupCabalMinVersionConstraint :: Version
-> DepResolverParams -> DepResolverParams
addSetupCabalMinVersionConstraint minVersion =
addConstraints
[ LabeledPackageConstraint
(PackageConstraint (scopeToplevel cabalPkgname)
(PackageConstraint (ScopeAnySetupQualifier cabalPkgname)
(PackagePropertyVersion $ orLaterVersion minVersion))
ConstraintSetupCabalMinVersion
]
......
......@@ -38,6 +38,9 @@ import qualified Text.PrettyPrint as Disp
data ConstraintScope
-- | The package with the specified name and qualifier.
= ScopeQualified Qualifier PackageName
-- | The package with the specified name when it has a
-- setup qualifier.
| ScopeAnySetupQualifier PackageName
-- | The package with the specified name regardless of
-- qualifier.
| ScopeAnyQualifier PackageName
......@@ -52,11 +55,13 @@ scopeToplevel = ScopeQualified QualToplevel
-- | Returns the package name associated with a constraint scope.
scopeToPackageName :: ConstraintScope -> PackageName
scopeToPackageName (ScopeQualified _ pn) = pn
scopeToPackageName (ScopeAnySetupQualifier pn) = pn
scopeToPackageName (ScopeAnyQualifier pn) = pn
-- | Pretty-prints a constraint scope.
dispConstraintScope :: ConstraintScope -> Disp.Doc
dispConstraintScope (ScopeQualified q pn) = dispQualifier q <<>> disp pn
dispConstraintScope (ScopeAnySetupQualifier pn) = Disp.text "setup." <<>> disp pn
dispConstraintScope (ScopeAnyQualifier pn) = Disp.text "any." <<>> disp pn
-- | A package property is a logical predicate on packages.
......
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