Commit d692561f authored by John Ericson's avatar John Ericson
Browse files

Add notion of ExeDependency for tool-depends and custom setup

parent c6928316
......@@ -210,6 +210,7 @@ library
Distribution.Types.BuildType
Distribution.Types.ComponentInclude
Distribution.Types.Dependency
Distribution.Types.ExeDependency
Distribution.Types.LegacyExeDependency
Distribution.Types.PkgconfigDependency
Distribution.Types.Executable
......
......@@ -42,6 +42,7 @@ import Distribution.Types.BenchmarkType
(BenchmarkType (..))
import Distribution.Types.BuildType (BuildType (..))
import Distribution.Types.Dependency (Dependency (..))
import Distribution.Types.ExeDependency (ExeDependency (..))
import Distribution.Types.LegacyExeDependency (LegacyExeDependency (..))
import Distribution.Types.PkgconfigDependency (PkgconfigDependency (..))
import Distribution.Types.GenericPackageDescription (FlagName, mkFlagName)
......@@ -136,6 +137,14 @@ instance Parsec Dependency where
ver <- parsec <|> pure anyVersion
return (Dependency name ver)
instance Parsec ExeDependency where
parsec = do
name <- lexemeParsec
_ <- P.char ':'
exe <- lexemeParsec
ver <- parsec <|> pure anyVersion
return (ExeDependency name exe ver)
instance Parsec LegacyExeDependency where
parsec = do
name <- parsecMaybeQuoted nameP
......
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.ExeDependency
( ExeDependency(..)
, qualifiedExeName
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Package
import Distribution.Types.ComponentName
import Distribution.Types.UnqualComponentName
import Distribution.Version ( VersionRange, anyVersion )
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP
import Distribution.Text
import Text.PrettyPrint ((<+>), text)
-- | Describes a dependency on an executable from a package
--
data ExeDependency = ExeDependency
PackageName
UnqualComponentName -- name of executable component of package
VersionRange
deriving (Generic, Read, Show, Eq, Typeable, Data)
instance Binary ExeDependency
instance NFData ExeDependency where rnf = genericRnf
instance Text ExeDependency where
disp (ExeDependency name exe ver) =
(disp name <<>> text ":" <<>> disp exe) <+> disp ver
parse = do name <- parse
_ <- Parse.char ':'
exe <- parse
Parse.skipSpaces
ver <- parse <++ return anyVersion
Parse.skipSpaces
return (ExeDependency name exe ver)
qualifiedExeName :: ExeDependency -> ComponentName
qualifiedExeName (ExeDependency _ ucn _) = CExeName ucn
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