forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigParser.hs
More file actions
149 lines (147 loc) · 6.08 KB
/
ConfigParser.hs
File metadata and controls
149 lines (147 loc) · 6.08 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{-# LANGUAGE NoImplicitPrelude #-}
module Stack.Options.ConfigParser where
import Data.Char
import qualified Data.Set as Set
import Options.Applicative
import Options.Applicative.Builder.Extra
import Path
import Stack.Constants
import Stack.Options.BuildMonoidParser
import Stack.Options.DockerParser
import Stack.Options.GhcBuildParser
import Stack.Options.GhcVariantParser
import Stack.Options.NixParser
import Stack.Options.Utils
import Stack.Prelude
import Stack.Types.Config
import qualified System.FilePath as FilePath
-- | Command-line arguments parser for configuration.
configOptsParser :: FilePath -> GlobalOptsContext -> Parser ConfigMonoid
configOptsParser currentDir hide0 =
(\stackRoot workDir buildOpts dockerOpts nixOpts systemGHC installGHC arch ghcVariant ghcBuild jobs includes libs overrideGccPath overrideHpack skipGHCCheck skipMsys localBin modifyCodePage allowDifferentUser dumpLogs -> mempty
{ configMonoidStackRoot = stackRoot
, configMonoidWorkDir = workDir
, configMonoidBuildOpts = buildOpts
, configMonoidDockerOpts = dockerOpts
, configMonoidNixOpts = nixOpts
, configMonoidSystemGHC = systemGHC
, configMonoidInstallGHC = installGHC
, configMonoidSkipGHCCheck = skipGHCCheck
, configMonoidArch = arch
, configMonoidGHCVariant = ghcVariant
, configMonoidGHCBuild = ghcBuild
, configMonoidJobs = jobs
, configMonoidExtraIncludeDirs = includes
, configMonoidExtraLibDirs = libs
, configMonoidOverrideGccPath = overrideGccPath
, configMonoidOverrideHpack = overrideHpack
, configMonoidSkipMsys = skipMsys
, configMonoidLocalBinPath = localBin
, configMonoidModifyCodePage = modifyCodePage
, configMonoidAllowDifferentUser = allowDifferentUser
, configMonoidDumpLogs = dumpLogs
})
<$> optionalFirst (absDirOption
( long stackRootOptionName
<> metavar (map toUpper stackRootOptionName)
<> help ("Absolute path to the global stack root directory " ++
"(Overrides any STACK_ROOT environment variable)")
<> hide
))
<*> optionalFirst (option (eitherReader (mapLeft showWorkDirError . parseRelDir))
( long "work-dir"
<> metavar "WORK-DIR"
<> completer (pathCompleterWith (defaultPathCompleterOpts { pcoAbsolute = False, pcoFileFilter = const False }))
<> help ("Relative path of work directory " ++
"(Overrides any STACK_WORK environment variable, default is '.stack-work')")
<> hide
))
<*> buildOptsMonoidParser hide0
<*> dockerOptsParser True
<*> nixOptsParser True
<*> firstBoolFlags
"system-ghc"
"using the system installed GHC (on the PATH) if it is available and its version matches. Disabled by default."
hide
<*> firstBoolFlags
"install-ghc"
"downloading and installing GHC if necessary (can be done manually with stack setup)"
hide
<*> optionalFirst (strOption
( long "arch"
<> metavar "ARCH"
<> help "System architecture, e.g. i386, x86_64"
<> hide
))
<*> optionalFirst (ghcVariantParser (hide0 /= OuterGlobalOpts))
<*> optionalFirst (ghcBuildParser (hide0 /= OuterGlobalOpts))
<*> optionalFirst (option auto
( long "jobs"
<> short 'j'
<> metavar "JOBS"
<> help "Number of concurrent jobs to run"
<> hide
))
<*> fmap Set.fromList (many ((currentDir FilePath.</>) <$> strOption
( long "extra-include-dirs"
<> metavar "DIR"
<> completer dirCompleter
<> help "Extra directories to check for C header files"
<> hide
)))
<*> fmap Set.fromList (many ((currentDir FilePath.</>) <$> strOption
( long "extra-lib-dirs"
<> metavar "DIR"
<> completer dirCompleter
<> help "Extra directories to check for libraries"
<> hide
)))
<*> optionalFirst (absFileOption
( long "with-gcc"
<> metavar "PATH-TO-GCC"
<> help "Use gcc found at PATH-TO-GCC"
<> hide
))
<*> optionalFirst (strOption
( long "with-hpack"
<> metavar "HPACK"
<> help "Use HPACK executable (overrides bundled Hpack)"
<> hide
))
<*> firstBoolFlags
"skip-ghc-check"
"skipping the GHC version and architecture check"
hide
<*> firstBoolFlags
"skip-msys"
"skipping the local MSYS installation (Windows only)"
hide
<*> optionalFirst (strOption
( long "local-bin-path"
<> metavar "DIR"
<> completer dirCompleter
<> help "Install binaries to DIR"
<> hide
))
<*> firstBoolFlags
"modify-code-page"
"setting the codepage to support UTF-8 (Windows only)"
hide
<*> firstBoolFlags
"allow-different-user"
("permission for users other than the owner of the stack root " ++
"directory to use a stack installation (POSIX only)")
hide
<*> fmap toDumpLogs
(firstBoolFlags
"dump-logs"
"dump the build output logs for local packages to the console"
hide)
where
hide = hideMods (hide0 /= OuterGlobalOpts)
toDumpLogs (First (Just True)) = First (Just DumpAllLogs)
toDumpLogs (First (Just False)) = First (Just DumpNoLogs)
toDumpLogs (First Nothing) = First Nothing
showWorkDirError err = show err ++
"\nNote that --work-dir must be a relative child directory, because work-dirs outside of the package are not supported by Cabal." ++
"\nSee https://github.com/commercialhaskell/stack/issues/2954"