1 {-# LANGUAGE DataKinds #-}
2 {-# LANGUAGE DeriveDataTypeable #-}
3 {-# LANGUAGE DeriveGeneric #-}
5 module Distribution
.Types
.Executable
12 import Distribution
.Compat
.Prelude
15 import Distribution
.ModuleName
16 import Distribution
.Types
.BuildInfo
17 import Distribution
.Types
.ExecutableScope
18 import Distribution
.Types
.UnqualComponentName
19 import Distribution
.Utils
.Path
21 import qualified Distribution
.Types
.BuildInfo
.Lens
as L
23 data Executable
= Executable
24 { exeName
:: UnqualComponentName
25 , modulePath
:: RelativePath Source File
26 , exeScope
:: ExecutableScope
27 , buildInfo
:: BuildInfo
29 deriving (Generic
, Show, Read, Eq
, Ord
, Typeable
, Data
)
31 instance L
.HasBuildInfo Executable
where
32 buildInfo f l
= (\x
-> l
{buildInfo
= x
}) <$> f
(buildInfo l
)
34 instance Binary Executable
35 instance Structured Executable
36 instance NFData Executable
where rnf
= genericRnf
38 instance Monoid Executable
where
42 , modulePath
= unsafeMakeSymbolicPath
""
48 instance Semigroup Executable
where
51 { exeName
= combineNames a b exeName
"executable"
52 , modulePath
= unsafeMakeSymbolicPath
$ combineNames a b
(getSymbolicPath
. modulePath
) "modulePath"
53 , exeScope
= combine exeScope
54 , buildInfo
= combine buildInfo
57 combine field
= field a `mappend` field b
59 emptyExecutable
:: Executable
60 emptyExecutable
= mempty
62 -- | Get all the module names from an exe
63 exeModules
:: Executable
-> [ModuleName
]
64 exeModules exe
= otherModules
(buildInfo exe
)
66 -- | Get all the auto generated module names from an exe
67 -- This are a subset of 'exeModules'.
68 exeModulesAutogen
:: Executable
-> [ModuleName
]
69 exeModulesAutogen exe
= autogenModules
(buildInfo exe
)