forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstants.hs
More file actions
189 lines (162 loc) · 5.99 KB
/
Constants.hs
File metadata and controls
189 lines (162 loc) · 5.99 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedStrings #-}
-- | Constants used throughout the project.
module Stack.Constants
(builtConfigFileFromDir
,builtFileFromDir
,configuredFileFromDir
,defaultShakeThreads
,distDirFromDir
,distRelativeDir
,haskellFileExts
,projectDockerSandboxDir
,rawGithubUrl
,stackDotYaml
,stackRootEnvVar
,userDocsDir
,configCacheFile
,buildCacheFile
,stackProgName
)
where
import Control.Monad (liftM)
import Control.Monad.Catch (MonadThrow)
import Control.Monad.Reader (MonadReader)
import Data.Text (Text)
import qualified Data.Text as T
import Path as FL
import Prelude
import Stack.Types.Config
import Stack.Types.PackageIdentifier
import Stack.Types.Version
-- | Extensions used for Haskell files.
haskellFileExts :: [Text]
haskellFileExts = ["hs","hsc","lhs"]
-- | The filename used for completed build indicators.
builtFileFromDir :: (MonadThrow m, MonadReader env m, HasPlatform env)
=> PackageIdentifier -- ^ Cabal version
-> Path Abs Dir
-> m (Path Abs File)
builtFileFromDir cabalPkgVer fp = do
dist <- distDirFromDir cabalPkgVer fp
return (dist </> $(mkRelFile "stack.gen"))
-- | The filename used for completed configure indicators.
configuredFileFromDir :: (MonadThrow m, MonadReader env m, HasPlatform env)
=> PackageIdentifier -- ^ Cabal version
-> Path Abs Dir
-> m (Path Abs File)
configuredFileFromDir cabalPkgVer fp = do
dist <- distDirFromDir cabalPkgVer fp
return (dist </> $(mkRelFile "setup-config"))
-- | The filename used for completed build indicators.
builtConfigFileFromDir :: (MonadThrow m, MonadReader env m, HasPlatform env)
=> PackageIdentifier -- ^ Cabal version
-> Path Abs Dir
-> m (Path Abs File)
builtConfigFileFromDir cabalPkgVer fp =
liftM (fp </>) (builtConfigRelativeFile cabalPkgVer)
-- | Relative location of completed build indicators.
builtConfigRelativeFile :: (MonadThrow m, MonadReader env m, HasPlatform env)
=> PackageIdentifier -- ^ Cabal version
-> m (Path Rel File)
builtConfigRelativeFile cabalPkgVer = do
dist <- distRelativeDir cabalPkgVer
return (dist </> $(mkRelFile "stack.config"))
-- | Default shake thread count for parallel builds.
defaultShakeThreads :: Int
defaultShakeThreads = 4
-- -- | Hoogle database file.
-- hoogleDatabaseFile :: Path Abs Dir -> Path Abs File
-- hoogleDatabaseFile docLoc =
-- docLoc </>
-- $(mkRelFile "default.hoo")
-- -- | Extension for hoogle databases.
-- hoogleDbExtension :: String
-- hoogleDbExtension = "hoo"
-- -- | Extension of haddock files
-- haddockExtension :: String
-- haddockExtension = "haddock"
-- | User documentation directory.
userDocsDir :: Config -> Path Abs Dir
userDocsDir config = configStackRoot config </> $(mkRelDir "doc/")
-- | The filename used for dirtiness check of source files.
buildCacheFile :: (MonadThrow m, MonadReader env m, HasPlatform env)
=> PackageIdentifier -- ^ Cabal version
-> Path Abs Dir -- ^ Package directory.
-> m (Path Abs File)
buildCacheFile cabalPkgVersion dir = do
liftM
(</> $(mkRelFile "stack-build-cache"))
(distDirFromDir cabalPkgVersion dir)
-- | The filename used for dirtiness check of config.
configCacheFile :: (MonadThrow m, MonadReader env m, HasPlatform env)
=> PackageIdentifier -- ^ Cabal version
-> Path Abs Dir -- ^ Package directory.
-> m (Path Abs File)
configCacheFile cabalPkgVersion dir = do
liftM
(</> $(mkRelFile "stack-config-cache"))
(distDirFromDir cabalPkgVersion dir)
-- | Package's build artifacts directory.
distDirFromDir :: (MonadThrow m, MonadReader env m, HasPlatform env)
=> PackageIdentifier -- ^ Cabal version
-> Path Abs Dir
-> m (Path Abs Dir)
distDirFromDir cabalPkgVersion fp =
liftM (fp </>) (distRelativeDir cabalPkgVersion)
-- | Relative location of build artifacts.
distRelativeDir :: (MonadThrow m, MonadReader env m, HasPlatform env)
=> PackageIdentifier -- ^ Cabal version
-> m (Path Rel Dir)
distRelativeDir cabalPkgVer = do
platform <- platformRelDir
cabal <- parseRelDir $ "Cabal-" ++
versionString (packageIdentifierVersion cabalPkgVer)
return $ $(mkRelDir "dist-stack/") </> platform </> cabal
-- pkgIndexDir :: Config -> Path Abs Dir
-- pkgIndexDir config =
-- configStackRoot config </>
-- $(mkRelDir "package-index")
-- pkgIndexFile :: Config -> Path Abs File
-- pkgIndexFile config =
-- pkgIndexDir config </>
-- $(mkRelFile "00-index.tar")
-- | Get a URL for a raw file on Github
rawGithubUrl :: Text -- ^ user/org name
-> Text -- ^ repo name
-> Text -- ^ branch name
-> Text -- ^ filename
-> Text
rawGithubUrl org repo branch file = T.concat
[ "https://raw.githubusercontent.com/"
, org
, "/"
, repo
, "/"
, branch
, "/"
, file
]
-- -- | Hoogle database file.
-- hoogleDatabaseFile :: Path Abs Dir -> Path Abs File
-- hoogleDatabaseFile docLoc =
-- docLoc </>
-- $(mkRelFile "default.hoo")
-- -- | Extension for hoogle databases.
-- hoogleDbExtension :: String
-- hoogleDbExtension = "hoo"
-- -- | Extension of haddock files
-- haddockExtension :: String
-- haddockExtension = "haddock"
-- | Docker sandbox from project root.
projectDockerSandboxDir :: Path Abs Dir -> Path Abs Dir
projectDockerSandboxDir projectRoot = projectRoot </> $(mkRelDir ".docker-sandbox/")
-- | Name of the 'stack' program.
stackProgName :: String
stackProgName = "stack"
-- | The filename used for the stack config file.
stackDotYaml :: Path Rel File
stackDotYaml = $(mkRelFile "stack.yaml")
-- | Environment variable used to override the '~/.stack' location.
stackRootEnvVar :: String
stackRootEnvVar = "STACK_ROOT"