forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.hs
More file actions
122 lines (116 loc) · 4.69 KB
/
Build.hs
File metadata and controls
122 lines (116 loc) · 4.69 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
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RecordWildCards #-}
-- | Build configuration
module Stack.Config.Build where
import Stack.Prelude
import Stack.Types.Config
-- | Interprets BuildOptsMonoid options.
buildOptsFromMonoid :: BuildOptsMonoid -> BuildOpts
buildOptsFromMonoid BuildOptsMonoid{..} = BuildOpts
{ boptsLibProfile = fromFirst
(boptsLibProfile defaultBuildOpts)
(buildMonoidLibProfile <>
First (if tracing || profiling then Just True else Nothing))
, boptsExeProfile = fromFirst
(boptsExeProfile defaultBuildOpts)
(buildMonoidExeProfile <>
First (if tracing || profiling then Just True else Nothing))
, boptsLibStrip = fromFirst
(boptsLibStrip defaultBuildOpts)
(buildMonoidLibStrip <>
First (if noStripping then Just False else Nothing))
, boptsExeStrip = fromFirst
(boptsExeStrip defaultBuildOpts)
(buildMonoidExeStrip <>
First (if noStripping then Just False else Nothing))
, boptsHaddock = fromFirst
(boptsHaddock defaultBuildOpts)
buildMonoidHaddock
, boptsHaddockOpts = haddockOptsFromMonoid buildMonoidHaddockOpts
, boptsOpenHaddocks = fromFirst
(boptsOpenHaddocks defaultBuildOpts)
buildMonoidOpenHaddocks
, boptsHaddockDeps = getFirst buildMonoidHaddockDeps
, boptsHaddockInternal = fromFirst
(boptsHaddockInternal defaultBuildOpts)
buildMonoidHaddockInternal
, boptsHaddockHyperlinkSource = fromFirst
(boptsHaddockHyperlinkSource defaultBuildOpts)
buildMonoidHaddockHyperlinkSource
, boptsInstallExes = fromFirst
(boptsInstallExes defaultBuildOpts)
buildMonoidInstallExes
, boptsInstallCompilerTool = fromFirst
(boptsInstallCompilerTool defaultBuildOpts)
buildMonoidInstallCompilerTool
, boptsPreFetch = fromFirst
(boptsPreFetch defaultBuildOpts)
buildMonoidPreFetch
, boptsKeepGoing = getFirst buildMonoidKeepGoing
, boptsKeepTmpFiles = getFirst buildMonoidKeepTmpFiles
, boptsForceDirty = fromFirst
(boptsForceDirty defaultBuildOpts)
buildMonoidForceDirty
, boptsTests = fromFirst (boptsTests defaultBuildOpts) buildMonoidTests
, boptsTestOpts =
testOptsFromMonoid buildMonoidTestOpts additionalArgs
, boptsBenchmarks = fromFirst
(boptsBenchmarks defaultBuildOpts)
buildMonoidBenchmarks
, boptsBenchmarkOpts =
benchmarkOptsFromMonoid buildMonoidBenchmarkOpts additionalArgs
, boptsReconfigure = fromFirst
(boptsReconfigure defaultBuildOpts)
buildMonoidReconfigure
, boptsCabalVerbose = fromFirst
(boptsCabalVerbose defaultBuildOpts)
buildMonoidCabalVerbose
, boptsSplitObjs = fromFirst
(boptsSplitObjs defaultBuildOpts)
buildMonoidSplitObjs
, boptsSkipComponents = buildMonoidSkipComponents
, boptsInterleavedOutput = fromFirst
(boptsInterleavedOutput defaultBuildOpts)
buildMonoidInterleavedOutput
}
where
-- These options are not directly used in bopts, instead they
-- transform other options.
tracing = getAny buildMonoidTrace
profiling = getAny buildMonoidProfile
noStripping = getAny buildMonoidNoStrip
-- Additional args for tracing / profiling
additionalArgs =
if tracing || profiling
then Just $ "+RTS" : catMaybes [trac, prof, Just "-RTS"]
else Nothing
trac =
if tracing
then Just "-xc"
else Nothing
prof =
if profiling
then Just "-p"
else Nothing
haddockOptsFromMonoid :: HaddockOptsMonoid -> HaddockOpts
haddockOptsFromMonoid HaddockOptsMonoid{..} =
defaultHaddockOpts
{hoAdditionalArgs = hoMonoidAdditionalArgs}
testOptsFromMonoid :: TestOptsMonoid -> Maybe [String] -> TestOpts
testOptsFromMonoid TestOptsMonoid{..} madditional =
defaultTestOpts
{ toRerunTests = fromFirst (toRerunTests defaultTestOpts) toMonoidRerunTests
, toAdditionalArgs = fromMaybe [] madditional <> toMonoidAdditionalArgs
, toCoverage = fromFirst (toCoverage defaultTestOpts) toMonoidCoverage
, toDisableRun = fromFirst (toDisableRun defaultTestOpts) toMonoidDisableRun
}
benchmarkOptsFromMonoid :: BenchmarkOptsMonoid -> Maybe [String] -> BenchmarkOpts
benchmarkOptsFromMonoid BenchmarkOptsMonoid{..} madditional =
defaultBenchmarkOpts
{ beoAdditionalArgs =
fmap (\args -> unwords args <> " ") madditional <>
getFirst beoMonoidAdditionalArgs
, beoDisableRun = fromFirst
(beoDisableRun defaultBenchmarkOpts)
beoMonoidDisableRun
}