module Stack.Constants
(builtConfigFileFromDir
,builtFileFromDir
,configuredFileFromDir
,defaultShakeThreads
,distDirFromDir
,distRelativeDir
,haskellFileExts
,projectDockerSandboxDir
,rawGithubUrl
,stackDotYaml
,stackRootEnvVar
,userDocsDir
,configCacheFile
,configCabalMod
,buildCacheFile
,stackProgName
,wiredInPackages
,cabalPackageName
,implicitGlobalDir
,hpcDirFromDir
,dotHpc)
where
import Control.Monad.Catch (MonadThrow)
import Control.Monad.Reader
import Data.HashSet (HashSet)
import qualified Data.HashSet as HashSet
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.PackageName
haskellFileExts :: [Text]
haskellFileExts = ["hs","hsc","lhs"]
builtFileFromDir :: (MonadThrow m, MonadReader env m, HasPlatform env,HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
builtFileFromDir fp = do
dist <- distDirFromDir fp
return (dist </> $(mkRelFile "stack.gen"))
configuredFileFromDir :: (MonadThrow m, MonadReader env m, HasPlatform env,HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
configuredFileFromDir fp = do
dist <- distDirFromDir fp
return (dist </> $(mkRelFile "setup-config"))
builtConfigFileFromDir :: (MonadThrow m, MonadReader env m, HasPlatform env,HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
builtConfigFileFromDir fp =
liftM (fp </>) builtConfigRelativeFile
builtConfigRelativeFile :: (MonadThrow m, MonadReader env m, HasPlatform env,HasEnvConfig env)
=> m (Path Rel File)
builtConfigRelativeFile = do
dist <- distRelativeDir
return (dist </> $(mkRelFile "stack.config"))
defaultShakeThreads :: Int
defaultShakeThreads = 4
userDocsDir :: Config -> Path Abs Dir
userDocsDir config = configStackRoot config </> $(mkRelDir "doc/")
buildCacheFile :: (MonadThrow m, MonadReader env m, HasPlatform env,HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
buildCacheFile dir = do
liftM
(</> $(mkRelFile "stack-build-cache"))
(distDirFromDir dir)
configCacheFile :: (MonadThrow m, MonadReader env m, HasPlatform env,HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
configCacheFile dir = do
liftM
(</> $(mkRelFile "stack-config-cache"))
(distDirFromDir dir)
configCabalMod :: (MonadThrow m, MonadReader env m, HasPlatform env,HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
configCabalMod dir = do
liftM
(</> $(mkRelFile "stack-cabal-mod"))
(distDirFromDir dir)
hpcDirFromDir
:: (MonadThrow m, MonadReader env m, HasPlatform env, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs Dir)
hpcDirFromDir dir = do
liftM (</> $(mkRelDir "hpc")) (distDirFromDir dir)
distDirFromDir :: (MonadThrow m, MonadReader env m, HasPlatform env, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs Dir)
distDirFromDir fp =
liftM (fp </>) distRelativeDir
distRelativeDir :: (MonadThrow m, MonadReader env m, HasPlatform env, HasEnvConfig env)
=> m (Path Rel Dir)
distRelativeDir = do
cabalPkgVer <- asks (envConfigCabalVersion . getEnvConfig)
platform <- platformRelDir
cabal <-
parseRelDir $
packageIdentifierString
(PackageIdentifier cabalPackageName cabalPkgVer)
return $
workDirRel </>
$(mkRelDir "dist") </>
platform </>
cabal
rawGithubUrl :: Text
-> Text
-> Text
-> Text
-> Text
rawGithubUrl org repo branch file = T.concat
[ "https://raw.githubusercontent.com/"
, org
, "/"
, repo
, "/"
, branch
, "/"
, file
]
projectDockerSandboxDir :: Path Abs Dir -> Path Abs Dir
projectDockerSandboxDir projectRoot = projectRoot </> workDirRel </> $(mkRelDir "docker/")
stackProgName :: String
stackProgName = "stack"
stackDotYaml :: Path Rel File
stackDotYaml = $(mkRelFile "stack.yaml")
stackRootEnvVar :: String
stackRootEnvVar = "STACK_ROOT"
wiredInPackages :: HashSet PackageName
wiredInPackages =
maybe (error "Parse error in wiredInPackages") HashSet.fromList mparsed
where
mparsed = sequence $ map parsePackageName
[ "ghc-prim"
, "integer-gmp"
, "integer-simple"
, "base"
, "rts"
, "template-haskell"
, "dph-seq"
, "dph-par"
, "ghc"
, "interactive"
]
cabalPackageName :: PackageName
cabalPackageName =
$(mkPackageName "Cabal")
implicitGlobalDir :: Path Abs Dir
-> Path Abs Dir
implicitGlobalDir p =
p </>
$(mkRelDir "global")
dotHpc :: Path Rel Dir
dotHpc = $(mkRelDir ".hpc")