1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
4 module Distribution
.Types
.LegacyExeDependency
5 ( LegacyExeDependency
(..)
8 import Distribution
.Compat
.Prelude
11 import Distribution
.Parsec
12 import Distribution
.Pretty
13 import Distribution
.Version
(VersionRange
, anyVersion
)
15 import qualified Distribution
.Compat
.CharParsing
as P
16 import qualified Text
.PrettyPrint
as Disp
18 -- | Describes a legacy `build-tools`-style dependency on an executable
20 -- It is "legacy" because we do not know what the build-tool referred to. It
21 -- could refer to a pkg-config executable (PkgconfigName), or an internal
22 -- executable (UnqualComponentName). Thus the name is stringly typed.
25 data LegacyExeDependency
29 deriving (Generic
, Read, Show, Eq
, Ord
, Typeable
, Data
)
31 instance Binary LegacyExeDependency
32 instance Structured LegacyExeDependency
33 instance NFData LegacyExeDependency
where rnf
= genericRnf
35 instance Pretty LegacyExeDependency
where
36 pretty
(LegacyExeDependency name ver
) =
37 Disp
.text name
<+> pretty ver
39 instance Parsec LegacyExeDependency
where
41 name
<- parsecMaybeQuoted nameP
43 verRange
<- parsecMaybeQuoted parsec
<|
> pure anyVersion
44 pure
$ LegacyExeDependency name verRange
46 nameP
= intercalate
"-" <$> toList
<$> P
.sepByNonEmpty component
(P
.char
'-')
48 cs
<- P
.munch1
(\c
-> isAlphaNum c || c
== '+' || c
== '_
')
49 if all isDigit cs
then fail "invalid component" else return cs