forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypes.hs
More file actions
129 lines (112 loc) · 3.84 KB
/
Types.hs
File metadata and controls
129 lines (112 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
-- | All data types.
module Stack.Build.Types where
import Control.DeepSeq
import Control.Exception
import Data.Aeson
import Data.Binary (Binary(..))
import Data.Data
import Data.Hashable
import Data.Map.Strict (Map)
import Data.Maybe
import Data.Monoid
import Data.Text (Text)
import Distribution.Package hiding (Package,PackageName)
import GHC.Generics
import Path (Path, Abs, File)
import Prelude hiding (FilePath)
import Stack.Package
import Stack.Types
import System.Exit (ExitCode)
data StackBuildException
= MissingTool Dependency
| Couldn'tFindPkgId PackageName
| MissingDep Package PackageName VersionRange
| MissingDep2 PackageName PackageName VersionRange
| MismatchedLocalDep PackageName Version PackageName VersionRange
| MismatchedDep PackageName Version PackageName VersionRange
| StackageDepVerMismatch PackageName Version VersionRange
| StackageVersionMismatch PackageName Version Version
| DependencyIssues [StackBuildException]
| GHCVersionMismatch (Maybe Version) Version (Maybe (Path Abs File))
-- ^ Path to the stack.yaml file
| Couldn'tParseTargets [Text]
| UnknownTargets [PackageName]
| TestSuiteFailure (Path Abs File) (Maybe (Path Abs File)) ExitCode
deriving (Typeable,Show)
instance Exception StackBuildException
-- | Configuration for building.
data BuildOpts =
BuildOpts {boptsTargets :: !(Either [Text] [PackageName])
-- ^ Right value indicates that we're only installing
-- dependencies, no local packages
,boptsLibProfile :: !Bool
,boptsExeProfile :: !Bool
,boptsEnableOptimizations :: !(Maybe Bool)
,boptsFinalAction :: !FinalAction
,boptsDryrun :: !Bool
,boptsGhcOptions :: ![Text]
,boptsFlags :: !(Map PackageName (Map FlagName Bool))
}
deriving (Show)
-- | Configuration for testing.
data TestConfig =
TestConfig {tconfigTargets :: ![Text]
}
deriving (Show)
-- | Configuration for haddocking.
data HaddockConfig =
HaddockConfig {hconfigTargets :: ![Text]
}
deriving (Show)
-- | Configuration for benchmarking.
data BenchmarkConfig =
BenchmarkConfig {benchTargets :: ![Text]
,benchInDocker :: !Bool}
deriving (Show)
-- | Generated config for a package build.
data GenConfig =
GenConfig {gconfigOptimize :: !Bool
,gconfigLibProfiling :: !Bool
,gconfigExeProfiling :: !Bool
,gconfigGhcOptions :: ![Text]
,gconfigFlags :: !(Map FlagName Bool)
,gconfigPkgId :: Maybe GhcPkgId}
deriving (Generic,Show)
instance FromJSON GenConfig
instance ToJSON GenConfig
defaultGenConfig :: GenConfig
defaultGenConfig =
GenConfig {gconfigOptimize = False
,gconfigLibProfiling = False
,gconfigExeProfiling = False
,gconfigGhcOptions = []
,gconfigFlags = mempty
,gconfigPkgId = Nothing}
-- | Run a Setup.hs action after building a package, before installing.
data FinalAction
= DoTests
| DoBenchmarks
| DoHaddock
| DoNothing
deriving (Eq,Bounded,Enum,Show)
data Dependencies =
Dependencies {depsLibraries :: [PackageName]
,depsTools :: [PackageName]}
deriving (Show,Typeable,Data)
-- | Used for mutex locking on the install step. Beats magic ().
data InstallLock = InstallLock
-- | Mutex for reading/writing .config files in dist/ of
-- packages. Shake works in parallel, without this there are race
-- conditions.
data ConfigLock = ConfigLock
-- | Package dependency oracle.
newtype PkgDepsOracle =
PkgDeps PackageName
deriving (Show,Typeable,Eq,Hashable,Binary,NFData)