1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE OverloadedStrings #-}
5 module Distribution
.Types
.BuildType
10 import Distribution
.Compat
.Prelude
13 import Distribution
.CabalSpecVersion
(CabalSpecVersion
(..))
14 import Distribution
.Parsec
15 import Distribution
.Pretty
17 import qualified Distribution
.Compat
.CharParsing
as P
18 import qualified Text
.PrettyPrint
as Disp
20 -- | The type of build system used by this package.
22 = -- | calls @Distribution.Simple.defaultMain@
24 |
-- | calls @Distribution.Simple.defaultMainWithHooks defaultUserHooks@,
25 -- which invokes @configure@ to generate additional build
26 -- information used by later phases.
28 |
-- | calls @Distribution.Make.defaultMain@
30 |
-- | uses user-supplied @Setup.hs@ or @Setup.lhs@ (default)
33 deriving (Generic
, Show, Read, Eq
, Ord
, Typeable
, Data
)
35 instance Binary BuildType
36 instance Structured BuildType
37 instance NFData BuildType
where rnf
= genericRnf
39 knownBuildTypes
:: [BuildType
]
40 knownBuildTypes
= [Simple
, Configure
, Make
, Custom
, Hooks
]
42 instance Pretty BuildType
where
43 pretty
= Disp
.text
. show
45 instance Parsec BuildType
where
47 name
<- P
.munch1
isAlphaNum
49 "Simple" -> return Simple
50 "Configure" -> return Configure
51 "Custom" -> return Custom
54 v
<- askCabalSpecVersion
55 if v
>= CabalSpecV3_14
57 else fail "build-type: 'Hooks'. This feature requires cabal-version >= 3.14."
59 v
<- askCabalSpecVersion
60 if v
<= CabalSpecV1_18
-- oldest version needing this, based on hackage-tests
62 parsecWarning PWTBuildTypeDefault
"build-type: Default is parsed as Custom for legacy reasons. See https://github.com/haskell/cabal/issues/5020"
64 else fail ("unknown build-type: '" ++ name
++ "'")
65 _
-> fail ("unknown build-type: '" ++ name
++ "'")