module Stack.Constants.Config
( distDirFromDir
, workDirFromDir
, distRelativeDir
, imageStagingDir
, projectDockerSandboxDir
, configCacheFile
, configCabalMod
, buildCacheFile
, testSuccessFile
, testBuiltFile
, hpcRelativeDir
, hpcDirFromDir
, objectInterfaceDirL
, templatesDir
) where
import Stack.Prelude
import Stack.Constants
import Stack.Types.Compiler
import Stack.Types.Config
import Stack.Types.PackageIdentifier
import Path
objectInterfaceDirL :: HasBuildConfig env => Getting r env (Path Abs Dir)
objectInterfaceDirL = to $ \env ->
let workDir = view workDirL env
root = view projectRootL env
in root </> workDir </> $(mkRelDir "odir/")
buildCacheFile :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
buildCacheFile dir =
liftM
(</> $(mkRelFile "stack-build-cache"))
(distDirFromDir dir)
testSuccessFile :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
testSuccessFile dir =
liftM
(</> $(mkRelFile "stack-test-success"))
(distDirFromDir dir)
testBuiltFile :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
testBuiltFile dir =
liftM
(</> $(mkRelFile "stack-test-built"))
(distDirFromDir dir)
configCacheFile :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
configCacheFile dir =
liftM
(</> $(mkRelFile "stack-config-cache"))
(distDirFromDir dir)
configCabalMod :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs File)
configCabalMod dir =
liftM
(</> $(mkRelFile "stack-cabal-mod"))
(distDirFromDir dir)
hpcDirFromDir
:: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs Dir)
hpcDirFromDir fp =
liftM (fp </>) hpcRelativeDir
hpcRelativeDir :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> m (Path Rel Dir)
hpcRelativeDir =
liftM (</> $(mkRelDir "hpc")) distRelativeDir
distDirFromDir :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs Dir)
distDirFromDir fp =
liftM (fp </>) distRelativeDir
workDirFromDir :: (MonadReader env m, HasEnvConfig env)
=> Path Abs Dir
-> m (Path Abs Dir)
workDirFromDir fp = view $ workDirL.to (fp </>)
templatesDir :: Config -> Path Abs Dir
templatesDir config = configStackRoot config </> $(mkRelDir "templates")
distRelativeDir :: (MonadThrow m, MonadReader env m, HasEnvConfig env)
=> m (Path Rel Dir)
distRelativeDir = do
cabalPkgVer <- view cabalVersionL
platform <- platformGhcRelDir
wc <- view $ actualCompilerVersionL.to whichCompiler
envDir <-
parseRelDir $
(if wc == Ghcjs then (++ "_ghcjs") else id) $
packageIdentifierString $
PackageIdentifier cabalPackageName cabalPkgVer
platformAndCabal <- useShaPathOnWindows (platform </> envDir)
workDir <- view workDirL
return $
workDir </>
$(mkRelDir "dist") </>
platformAndCabal
projectDockerSandboxDir :: (MonadReader env m, HasConfig env)
=> Path Abs Dir
-> m (Path Abs Dir)
projectDockerSandboxDir projectRoot = do
workDir <- view workDirL
return $ projectRoot </> workDir </> $(mkRelDir "docker/")
imageStagingDir :: (MonadReader env m, HasConfig env, MonadThrow m)
=> Path Abs Dir
-> Int
-> m (Path Abs Dir)
imageStagingDir projectRoot imageIdx = do
workDir <- view workDirL
idxRelDir <- parseRelDir (show imageIdx)
return $ projectRoot </> workDir </> $(mkRelDir "image") </> idxRelDir