1 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
2 {-# LANGUAGE NamedFieldPuns #-}
3 {-# LANGUAGE PatternSynonyms #-}
5 module Distribution
.Simple
.Build
.Inputs
6 ( -- * Inputs of actions for building components
7 PreBuildComponentInputs
(..)
9 -- * Queries over the component being built
21 , buildingWhatVerbosity
22 , buildingWhatDistPref
26 import Distribution
.Simple
.Compiler
27 import Distribution
.Simple
.Setup
(BuildingWhat
(..), buildingWhatDistPref
, buildingWhatVerbosity
)
28 import Distribution
.Types
.BuildInfo
29 import Distribution
.Types
.Component
30 import Distribution
.Types
.ComponentLocalBuildInfo
31 import Distribution
.Types
.LocalBuildInfo
32 import Distribution
.Types
.TargetInfo
33 import Distribution
.Verbosity
35 -- | The information required for a build computation which is available right
36 -- before building each component, i.e. the pre-build component inputs.
37 data PreBuildComponentInputs
= PreBuildComponentInputs
38 { buildingWhat
:: BuildingWhat
39 -- ^ What kind of build are we doing?
40 , localBuildInfo
:: LocalBuildInfo
41 -- ^ Information about the package
42 , targetInfo
:: TargetInfo
43 -- ^ Information about an individual component
46 -- | Get the @'Verbosity'@ from the context the component being built is in.
47 buildVerbosity
:: PreBuildComponentInputs
-> Verbosity
48 buildVerbosity
= buildingWhatVerbosity
. buildingWhat
50 -- | Get the @'Component'@ being built.
51 buildComponent
:: PreBuildComponentInputs
-> Component
52 buildComponent
= targetComponent
. targetInfo
54 -- | Is the @'Component'@ being built a @'Library'@?
55 buildIsLib
:: PreBuildComponentInputs
-> Bool
57 component
<- buildComponent
59 | CLib
{} <- component
= True
62 {-# INLINE buildIsLib #-}
64 -- | Get the @'ComponentLocalBuildInfo'@ for the component being built.
65 buildCLBI
:: PreBuildComponentInputs
-> ComponentLocalBuildInfo
66 buildCLBI
= targetCLBI
. targetInfo
68 -- | Get the @'BuildInfo'@ of the component being built.
69 buildBI
:: PreBuildComponentInputs
-> BuildInfo
70 buildBI
= componentBuildInfo
. buildComponent
72 -- | Get the @'Compiler'@ being used to build the component.
73 buildCompiler
:: PreBuildComponentInputs
-> Compiler
74 buildCompiler
= compiler
. localBuildInfo