Commit 9aa4b9f0 authored by kristenk's avatar kristenk Committed by Edward Z. Yang

Expose constraints that apply to any setup dependency.

For example, "setup.Cabal installed" forces cabal to use the installed Cabal
library for all setup scripts.
parent f9139d7b
......@@ -1321,9 +1321,14 @@ Miscellaneous options
::
# Example use of the 'setup' qualifier. This constraint
# applies to package bar when it is a dependency of the
# Setup.hs script of package foo.
# Example uses of 'setup' qualifiers.
# This constraint applies to package bar when it is a
# dependency of any Setup.hs script.
$ cabal install --constraint="setup.bar == 1.0"
# This constraint applies to package bar when it is a
# dependency of the Setup.hs script of package foo.
$ cabal install --constraint="foo:setup.bar == 1.0"
.. TODO: Uncomment this example once we decide on a syntax for 'exe'.
......
......@@ -719,6 +719,9 @@ data UserConstraintScope =
-- | Scope that applies to the package when it has the specified qualifier.
UserQualified UserQualifier PackageName
-- | Scope that applies to the package when it has a setup qualifier.
| UserAnySetupQualifier PackageName
-- | Scope that applies to the package when it has any qualifier.
| UserAnyQualifier PackageName
deriving (Eq, Show, Generic)
......@@ -733,6 +736,7 @@ fromUserQualifier (UserQualExe name1 name2) = QualExe name1 name2
fromUserConstraintScope :: UserConstraintScope -> ConstraintScope
fromUserConstraintScope (UserQualified q pn) =
ScopeQualified (fromUserQualifier q) pn
fromUserConstraintScope (UserAnySetupQualifier pn) = ScopeAnySetupQualifier pn
fromUserConstraintScope (UserAnyQualifier pn) = ScopeAnyQualifier pn
-- | Version of 'PackageConstraint' that the user can specify on
......@@ -748,6 +752,7 @@ userConstraintPackageName (UserConstraint scope _) = scopePN scope
where
scopePN (UserQualified _ pn) = pn
scopePN (UserAnyQualifier pn) = pn
scopePN (UserAnySetupQualifier pn) = pn
userToPackageConstraint :: UserConstraint -> PackageConstraint
userToPackageConstraint (UserConstraint scope prop) =
......@@ -776,6 +781,11 @@ instance Text UserConstraint where
pn <- parse
return (UserAnyQualifier pn)
+++
do
_ <- Parse.string "setup."
pn <- parse
return (UserAnySetupQualifier pn)
+++
do
-- Qualified name
pn <- parse
......
......@@ -37,8 +37,9 @@
* New 'cabal-install' command: 'outdated', for listing outdated
version bounds in a .cabal file or a freeze file (#4207).
* Added qualified constraints for setup dependencies. For example,
--constraint="foo:setup.bar == 1.0" constrains foo's setup dependency
on bar (part of #3502).
--constraint="setup.bar == 1.0" constrains all setup dependencies on
bar, and --constraint="foo:setup.bar == 1.0" constrains foo's setup
dependency on bar (part of #3502).
* Non-qualified constraints, such as --constraint="bar == 1.0", now
only apply to top-level dependencies. They don't constrain setup or
build-tool dependencies. The new syntax --constraint="any.bar == 1.0"
......
......@@ -567,6 +567,7 @@ instance Arbitrary RemoteRepo where
instance Arbitrary UserConstraintScope where
arbitrary = oneof [ UserQualified <$> arbitrary <*> arbitrary
, UserAnySetupQualifier <$> arbitrary
, UserAnyQualifier <$> arbitrary
]
......
......@@ -58,6 +58,10 @@ exampleConstraints =
UserConstraint (UserAnyQualifier (pn "directory"))
(PackagePropertyStanzas [TestStanzas]))
, ("setup.Cabal installed",
UserConstraint (UserAnySetupQualifier (pn "Cabal"))
PackagePropertyInstalled)
, ("process:setup.bytestring ==5.2",
UserConstraint (UserQualified (UserQualSetup (pn "process")) (pn "bytestring"))
(PackagePropertyVersion (thisVersion (mkVersion [5, 2]))))
......
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