{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module Distribution.Simple.LocalBuildInfo (
LocalBuildInfo(..),
localComponentId,
localUnitId,
localCompatPackageKey,
Component(..),
ComponentName(..),
LibraryName(..),
defaultLibName,
showComponentName,
componentNameString,
ComponentLocalBuildInfo(..),
componentBuildDir,
foldComponent,
componentName,
componentBuildInfo,
componentBuildable,
pkgComponents,
pkgBuildableComponents,
lookupComponent,
getComponent,
allComponentsInBuildOrder,
depLibraryPaths,
allLibModules,
withAllComponentsInBuildOrder,
withLibLBI,
withExeLBI,
withBenchLBI,
withTestLBI,
enabledTestLBIs,
enabledBenchLBIs,
module Distribution.Simple.InstallDirs,
absoluteInstallDirs, prefixRelativeInstallDirs,
absoluteInstallCommandDirs,
absoluteComponentInstallDirs, prefixRelativeComponentInstallDirs,
substPathTemplate,
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Types.Component
import Distribution.Types.PackageId
import Distribution.Types.UnitId
import Distribution.Types.ComponentName
import Distribution.Types.UnqualComponentName
import Distribution.Types.PackageDescription
import Distribution.Types.ComponentLocalBuildInfo
import Distribution.Types.LocalBuildInfo
import Distribution.Types.TargetInfo
import Distribution.Simple.InstallDirs hiding (absoluteInstallDirs,
prefixRelativeInstallDirs,
substPathTemplate, )
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.PackageDescription
import qualified Distribution.InstalledPackageInfo as Installed
import Distribution.Package
import Distribution.ModuleName
import Distribution.Simple.Compiler
import Distribution.Simple.PackageIndex
import Distribution.Simple.Utils
import Distribution.Pretty
import qualified Distribution.Compat.Graph as Graph
import Data.List (stripPrefix)
import System.FilePath
import System.Directory (doesDirectoryExist, canonicalizePath)
componentBuildDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> FilePath
componentBuildDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> FilePath
componentBuildDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi
= LocalBuildInfo -> FilePath
buildDir LocalBuildInfo
lbi FilePath -> FilePath -> FilePath
</>
case ComponentLocalBuildInfo -> ComponentName
componentLocalName ComponentLocalBuildInfo
clbi of
CLibName LibraryName
LMainLibName ->
if UnitId -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi) FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
== ComponentId -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow (ComponentLocalBuildInfo -> ComponentId
componentComponentId ComponentLocalBuildInfo
clbi)
then FilePath
""
else UnitId -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi)
CLibName (LSubLibName UnqualComponentName
s) ->
if UnitId -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi) FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
== ComponentId -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow (ComponentLocalBuildInfo -> ComponentId
componentComponentId ComponentLocalBuildInfo
clbi)
then UnqualComponentName -> FilePath
unUnqualComponentName UnqualComponentName
s
else UnitId -> FilePath
forall a. Pretty a => a -> FilePath
prettyShow (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi)
CFLibName UnqualComponentName
s -> UnqualComponentName -> FilePath
unUnqualComponentName UnqualComponentName
s
CExeName UnqualComponentName
s -> UnqualComponentName -> FilePath
unUnqualComponentName UnqualComponentName
s
CTestName UnqualComponentName
s -> UnqualComponentName -> FilePath
unUnqualComponentName UnqualComponentName
s
CBenchName UnqualComponentName
s -> UnqualComponentName -> FilePath
unUnqualComponentName UnqualComponentName
s
withLibLBI :: PackageDescription -> LocalBuildInfo
-> (Library -> ComponentLocalBuildInfo -> IO ()) -> IO ()
withLibLBI :: PackageDescription
-> LocalBuildInfo
-> (Library -> ComponentLocalBuildInfo -> IO ())
-> IO ()
withLibLBI PackageDescription
pkg LocalBuildInfo
lbi Library -> ComponentLocalBuildInfo -> IO ()
f =
PackageDescription
-> LocalBuildInfo -> (TargetInfo -> IO ()) -> IO ()
withAllTargetsInBuildOrder' PackageDescription
pkg LocalBuildInfo
lbi ((TargetInfo -> IO ()) -> IO ()) -> (TargetInfo -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \TargetInfo
target ->
case TargetInfo -> Component
targetComponent TargetInfo
target of
CLib Library
lib -> Library -> ComponentLocalBuildInfo -> IO ()
f Library
lib (TargetInfo -> ComponentLocalBuildInfo
targetCLBI TargetInfo
target)
Component
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
withExeLBI :: PackageDescription -> LocalBuildInfo
-> (Executable -> ComponentLocalBuildInfo -> IO ()) -> IO ()
withExeLBI :: PackageDescription
-> LocalBuildInfo
-> (Executable -> ComponentLocalBuildInfo -> IO ())
-> IO ()
withExeLBI PackageDescription
pkg LocalBuildInfo
lbi Executable -> ComponentLocalBuildInfo -> IO ()
f =
PackageDescription
-> LocalBuildInfo -> (TargetInfo -> IO ()) -> IO ()
withAllTargetsInBuildOrder' PackageDescription
pkg LocalBuildInfo
lbi ((TargetInfo -> IO ()) -> IO ()) -> (TargetInfo -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \TargetInfo
target ->
case TargetInfo -> Component
targetComponent TargetInfo
target of
CExe Executable
exe -> Executable -> ComponentLocalBuildInfo -> IO ()
f Executable
exe (TargetInfo -> ComponentLocalBuildInfo
targetCLBI TargetInfo
target)
Component
_ -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
withBenchLBI :: PackageDescription -> LocalBuildInfo
-> (Benchmark -> ComponentLocalBuildInfo -> IO ()) -> IO ()
withBenchLBI :: PackageDescription
-> LocalBuildInfo
-> (Benchmark -> ComponentLocalBuildInfo -> IO ())
-> IO ()
withBenchLBI PackageDescription
pkg LocalBuildInfo
lbi Benchmark -> ComponentLocalBuildInfo -> IO ()
f =
[IO ()] -> IO ()
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_ [ Benchmark -> ComponentLocalBuildInfo -> IO ()
f Benchmark
bench ComponentLocalBuildInfo
clbi | (Benchmark
bench, ComponentLocalBuildInfo
clbi) <- PackageDescription
-> LocalBuildInfo -> [(Benchmark, ComponentLocalBuildInfo)]
enabledBenchLBIs PackageDescription
pkg LocalBuildInfo
lbi ]
withTestLBI :: PackageDescription -> LocalBuildInfo
-> (TestSuite -> ComponentLocalBuildInfo -> IO ()) -> IO ()
withTestLBI :: PackageDescription
-> LocalBuildInfo
-> (TestSuite -> ComponentLocalBuildInfo -> IO ())
-> IO ()
withTestLBI PackageDescription
pkg LocalBuildInfo
lbi TestSuite -> ComponentLocalBuildInfo -> IO ()
f =
[IO ()] -> IO ()
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_ [ TestSuite -> ComponentLocalBuildInfo -> IO ()
f TestSuite
test ComponentLocalBuildInfo
clbi | (TestSuite
test, ComponentLocalBuildInfo
clbi) <- PackageDescription
-> LocalBuildInfo -> [(TestSuite, ComponentLocalBuildInfo)]
enabledTestLBIs PackageDescription
pkg LocalBuildInfo
lbi ]
enabledTestLBIs :: PackageDescription -> LocalBuildInfo
-> [(TestSuite, ComponentLocalBuildInfo)]
enabledTestLBIs :: PackageDescription
-> LocalBuildInfo -> [(TestSuite, ComponentLocalBuildInfo)]
enabledTestLBIs PackageDescription
pkg LocalBuildInfo
lbi =
[ (TestSuite
test, TargetInfo -> ComponentLocalBuildInfo
targetCLBI TargetInfo
target)
| TargetInfo
target <- PackageDescription -> LocalBuildInfo -> [TargetInfo]
allTargetsInBuildOrder' PackageDescription
pkg LocalBuildInfo
lbi
, CTest TestSuite
test <- [TargetInfo -> Component
targetComponent TargetInfo
target] ]
enabledBenchLBIs :: PackageDescription -> LocalBuildInfo
-> [(Benchmark, ComponentLocalBuildInfo)]
enabledBenchLBIs :: PackageDescription
-> LocalBuildInfo -> [(Benchmark, ComponentLocalBuildInfo)]
enabledBenchLBIs PackageDescription
pkg LocalBuildInfo
lbi =
[ (Benchmark
bench, TargetInfo -> ComponentLocalBuildInfo
targetCLBI TargetInfo
target)
| TargetInfo
target <- PackageDescription -> LocalBuildInfo -> [TargetInfo]
allTargetsInBuildOrder' PackageDescription
pkg LocalBuildInfo
lbi
, CBench Benchmark
bench <- [TargetInfo -> Component
targetComponent TargetInfo
target] ]
withAllComponentsInBuildOrder :: PackageDescription -> LocalBuildInfo
-> (Component -> ComponentLocalBuildInfo -> IO ())
-> IO ()
withAllComponentsInBuildOrder :: PackageDescription
-> LocalBuildInfo
-> (Component -> ComponentLocalBuildInfo -> IO ())
-> IO ()
withAllComponentsInBuildOrder PackageDescription
pkg LocalBuildInfo
lbi Component -> ComponentLocalBuildInfo -> IO ()
f =
PackageDescription
-> LocalBuildInfo -> (TargetInfo -> IO ()) -> IO ()
withAllTargetsInBuildOrder' PackageDescription
pkg LocalBuildInfo
lbi ((TargetInfo -> IO ()) -> IO ()) -> (TargetInfo -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \TargetInfo
target ->
Component -> ComponentLocalBuildInfo -> IO ()
f (TargetInfo -> Component
targetComponent TargetInfo
target) (TargetInfo -> ComponentLocalBuildInfo
targetCLBI TargetInfo
target)
allComponentsInBuildOrder :: LocalBuildInfo
-> [ComponentLocalBuildInfo]
allComponentsInBuildOrder :: LocalBuildInfo -> [ComponentLocalBuildInfo]
allComponentsInBuildOrder LocalBuildInfo
lbi =
Graph ComponentLocalBuildInfo -> [ComponentLocalBuildInfo]
forall a. Graph a -> [a]
Graph.topSort (LocalBuildInfo -> Graph ComponentLocalBuildInfo
componentGraph LocalBuildInfo
lbi)
depLibraryPaths :: Bool
-> Bool
-> LocalBuildInfo
-> ComponentLocalBuildInfo
-> IO [FilePath]
depLibraryPaths :: Bool
-> Bool
-> LocalBuildInfo
-> ComponentLocalBuildInfo
-> IO [FilePath]
depLibraryPaths Bool
inplace Bool
relative LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi = do
let pkgDescr :: PackageDescription
pkgDescr = LocalBuildInfo -> PackageDescription
localPkgDescr LocalBuildInfo
lbi
installDirs :: InstallDirs FilePath
installDirs = PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs FilePath
absoluteComponentInstallDirs PackageDescription
pkgDescr LocalBuildInfo
lbi (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi) CopyDest
NoCopyDest
executable :: Bool
executable = case ComponentLocalBuildInfo
clbi of
ExeComponentLocalBuildInfo {} -> Bool
True
ComponentLocalBuildInfo
_ -> Bool
False
relDir :: FilePath
relDir | Bool
executable = InstallDirs FilePath -> FilePath
forall dir. InstallDirs dir -> dir
bindir InstallDirs FilePath
installDirs
| Bool
otherwise = InstallDirs FilePath -> FilePath
forall dir. InstallDirs dir -> dir
libdir InstallDirs FilePath
installDirs
let
internalDeps :: [UnitId]
internalDeps = [ UnitId
uid
| (UnitId
uid, MungedPackageId
_) <- ComponentLocalBuildInfo -> [(UnitId, MungedPackageId)]
componentPackageDeps ComponentLocalBuildInfo
clbi
, TargetInfo
sub_target <- PackageDescription -> LocalBuildInfo -> [TargetInfo]
allTargetsInBuildOrder' PackageDescription
pkgDescr LocalBuildInfo
lbi
, ComponentLocalBuildInfo -> UnitId
componentUnitId (TargetInfo -> ComponentLocalBuildInfo
targetCLBI (TargetInfo
sub_target)) UnitId -> UnitId -> Bool
forall a. Eq a => a -> a -> Bool
== UnitId
uid ]
internalLibs :: [FilePath]
internalLibs = [ ComponentLocalBuildInfo -> FilePath
getLibDir (TargetInfo -> ComponentLocalBuildInfo
targetCLBI TargetInfo
sub_target)
| TargetInfo
sub_target <- PackageDescription -> LocalBuildInfo -> [UnitId] -> [TargetInfo]
neededTargetsInBuildOrder'
PackageDescription
pkgDescr LocalBuildInfo
lbi [UnitId]
internalDeps ]
getLibDir :: ComponentLocalBuildInfo -> FilePath
getLibDir ComponentLocalBuildInfo
sub_clbi
| Bool
inplace = LocalBuildInfo -> ComponentLocalBuildInfo -> FilePath
componentBuildDir LocalBuildInfo
lbi ComponentLocalBuildInfo
sub_clbi
| Bool
otherwise = InstallDirs FilePath -> FilePath
forall dir. InstallDirs dir -> dir
dynlibdir (PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs FilePath
absoluteComponentInstallDirs PackageDescription
pkgDescr LocalBuildInfo
lbi (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
sub_clbi) CopyDest
NoCopyDest)
let external_ipkgs :: [InstalledPackageInfo]
external_ipkgs = (InstalledPackageInfo -> Bool)
-> [InstalledPackageInfo] -> [InstalledPackageInfo]
forall a. (a -> Bool) -> [a] -> [a]
filter InstalledPackageInfo -> Bool
forall pkg. HasUnitId pkg => pkg -> Bool
is_external (PackageIndex InstalledPackageInfo -> [InstalledPackageInfo]
forall a. PackageIndex a -> [a]
allPackages (LocalBuildInfo -> PackageIndex InstalledPackageInfo
installedPkgs LocalBuildInfo
lbi))
is_external :: pkg -> Bool
is_external pkg
ipkg = Bool -> Bool
not (pkg -> UnitId
forall pkg. HasUnitId pkg => pkg -> UnitId
installedUnitId pkg
ipkg UnitId -> [UnitId] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [UnitId]
internalDeps)
getDynDir :: InstalledPackageInfo -> [FilePath]
getDynDir InstalledPackageInfo
pkg = case InstalledPackageInfo -> [FilePath]
Installed.libraryDynDirs InstalledPackageInfo
pkg of
[] -> InstalledPackageInfo -> [FilePath]
Installed.libraryDirs InstalledPackageInfo
pkg
[FilePath]
d -> [FilePath]
d
allDepLibDirs :: [FilePath]
allDepLibDirs = (InstalledPackageInfo -> [FilePath])
-> [InstalledPackageInfo] -> [FilePath]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap InstalledPackageInfo -> [FilePath]
getDynDir [InstalledPackageInfo]
external_ipkgs
allDepLibDirs' :: [FilePath]
allDepLibDirs' = [FilePath]
internalLibs [FilePath] -> [FilePath] -> [FilePath]
forall a. [a] -> [a] -> [a]
++ [FilePath]
allDepLibDirs
[FilePath]
allDepLibDirsC <- (FilePath -> IO FilePath) -> [FilePath] -> IO [FilePath]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse FilePath -> IO FilePath
canonicalizePathNoFail [FilePath]
allDepLibDirs'
let p :: FilePath
p = InstallDirs FilePath -> FilePath
forall dir. InstallDirs dir -> dir
prefix InstallDirs FilePath
installDirs
prefixRelative :: FilePath -> Bool
prefixRelative FilePath
l = Maybe FilePath -> Bool
forall a. Maybe a -> Bool
isJust (FilePath -> FilePath -> Maybe FilePath
forall a. Eq a => [a] -> [a] -> Maybe [a]
stripPrefix FilePath
p FilePath
l)
libPaths :: [FilePath]
libPaths
| Bool
relative Bool -> Bool -> Bool
&&
FilePath -> Bool
prefixRelative FilePath
relDir = (FilePath -> FilePath) -> [FilePath] -> [FilePath]
forall a b. (a -> b) -> [a] -> [b]
map (\FilePath
l ->
if FilePath -> Bool
prefixRelative FilePath
l
then FilePath -> FilePath -> FilePath
shortRelativePath FilePath
relDir FilePath
l
else FilePath
l
) [FilePath]
allDepLibDirsC
| Bool
otherwise = [FilePath]
allDepLibDirsC
[FilePath] -> IO [FilePath]
forall (m :: * -> *) a. Monad m => a -> m a
return [FilePath]
libPaths
where
canonicalizePathNoFail :: FilePath -> IO FilePath
canonicalizePathNoFail FilePath
p = do
Bool
exists <- FilePath -> IO Bool
doesDirectoryExist FilePath
p
if Bool
exists
then FilePath -> IO FilePath
canonicalizePath FilePath
p
else FilePath -> IO FilePath
forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
p
allLibModules :: Library -> ComponentLocalBuildInfo -> [ModuleName]
allLibModules :: Library -> ComponentLocalBuildInfo -> [ModuleName]
allLibModules Library
lib ComponentLocalBuildInfo
clbi =
[ModuleName] -> [ModuleName]
forall a. Ord a => [a] -> [a]
ordNub ([ModuleName] -> [ModuleName]) -> [ModuleName] -> [ModuleName]
forall a b. (a -> b) -> a -> b
$
Library -> [ModuleName]
explicitLibModules Library
lib [ModuleName] -> [ModuleName] -> [ModuleName]
forall a. [a] -> [a] -> [a]
++
case ComponentLocalBuildInfo
clbi of
LibComponentLocalBuildInfo { componentInstantiatedWith :: ComponentLocalBuildInfo -> [(ModuleName, OpenModule)]
componentInstantiatedWith = [(ModuleName, OpenModule)]
insts } -> ((ModuleName, OpenModule) -> ModuleName)
-> [(ModuleName, OpenModule)] -> [ModuleName]
forall a b. (a -> b) -> [a] -> [b]
map (ModuleName, OpenModule) -> ModuleName
forall a b. (a, b) -> a
fst [(ModuleName, OpenModule)]
insts
ComponentLocalBuildInfo
_ -> []
absoluteInstallDirs :: PackageDescription -> LocalBuildInfo
-> CopyDest
-> InstallDirs FilePath
absoluteInstallDirs :: PackageDescription
-> LocalBuildInfo -> CopyDest -> InstallDirs FilePath
absoluteInstallDirs PackageDescription
pkg LocalBuildInfo
lbi CopyDest
copydest =
PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs FilePath
absoluteComponentInstallDirs PackageDescription
pkg LocalBuildInfo
lbi (LocalBuildInfo -> UnitId
localUnitId LocalBuildInfo
lbi) CopyDest
copydest
absoluteComponentInstallDirs :: PackageDescription -> LocalBuildInfo
-> UnitId
-> CopyDest
-> InstallDirs FilePath
absoluteComponentInstallDirs :: PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs FilePath
absoluteComponentInstallDirs PackageDescription
pkg LocalBuildInfo
lbi UnitId
uid CopyDest
copydest =
PackageIdentifier
-> UnitId
-> CompilerInfo
-> CopyDest
-> Platform
-> InstallDirs PathTemplate
-> InstallDirs FilePath
InstallDirs.absoluteInstallDirs
(PackageDescription -> PackageIdentifier
forall pkg. Package pkg => pkg -> PackageIdentifier
packageId PackageDescription
pkg)
UnitId
uid
(Compiler -> CompilerInfo
compilerInfo (LocalBuildInfo -> Compiler
compiler LocalBuildInfo
lbi))
CopyDest
copydest
(LocalBuildInfo -> Platform
hostPlatform LocalBuildInfo
lbi)
(LocalBuildInfo -> InstallDirs PathTemplate
installDirTemplates LocalBuildInfo
lbi)
absoluteInstallCommandDirs :: PackageDescription -> LocalBuildInfo
-> UnitId
-> CopyDest
-> InstallDirs FilePath
absoluteInstallCommandDirs :: PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs FilePath
absoluteInstallCommandDirs PackageDescription
pkg LocalBuildInfo
lbi UnitId
uid CopyDest
copydest =
InstallDirs FilePath
dirs {
datadir :: FilePath
datadir = InstallDirs FilePath -> FilePath
forall dir. InstallDirs dir -> dir
datadir InstallDirs FilePath
dirs',
docdir :: FilePath
docdir = InstallDirs FilePath -> FilePath
forall dir. InstallDirs dir -> dir
docdir InstallDirs FilePath
dirs',
htmldir :: FilePath
htmldir = InstallDirs FilePath -> FilePath
forall dir. InstallDirs dir -> dir
htmldir InstallDirs FilePath
dirs',
haddockdir :: FilePath
haddockdir = InstallDirs FilePath -> FilePath
forall dir. InstallDirs dir -> dir
haddockdir InstallDirs FilePath
dirs'
}
where
dirs :: InstallDirs FilePath
dirs = PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs FilePath
absoluteComponentInstallDirs PackageDescription
pkg LocalBuildInfo
lbi UnitId
uid CopyDest
copydest
dirs' :: InstallDirs FilePath
dirs' = PackageDescription
-> LocalBuildInfo -> CopyDest -> InstallDirs FilePath
absoluteInstallDirs PackageDescription
pkg LocalBuildInfo
lbi CopyDest
copydest
prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo
-> InstallDirs (Maybe FilePath)
prefixRelativeInstallDirs :: PackageIdentifier -> LocalBuildInfo -> InstallDirs (Maybe FilePath)
prefixRelativeInstallDirs PackageIdentifier
pkg_descr LocalBuildInfo
lbi =
PackageIdentifier
-> LocalBuildInfo -> UnitId -> InstallDirs (Maybe FilePath)
prefixRelativeComponentInstallDirs PackageIdentifier
pkg_descr LocalBuildInfo
lbi (LocalBuildInfo -> UnitId
localUnitId LocalBuildInfo
lbi)
prefixRelativeComponentInstallDirs :: PackageId -> LocalBuildInfo
-> UnitId
-> InstallDirs (Maybe FilePath)
prefixRelativeComponentInstallDirs :: PackageIdentifier
-> LocalBuildInfo -> UnitId -> InstallDirs (Maybe FilePath)
prefixRelativeComponentInstallDirs PackageIdentifier
pkg_descr LocalBuildInfo
lbi UnitId
uid =
PackageIdentifier
-> UnitId
-> CompilerInfo
-> Platform
-> InstallDirs PathTemplate
-> InstallDirs (Maybe FilePath)
InstallDirs.prefixRelativeInstallDirs
(PackageIdentifier -> PackageIdentifier
forall pkg. Package pkg => pkg -> PackageIdentifier
packageId PackageIdentifier
pkg_descr)
UnitId
uid
(Compiler -> CompilerInfo
compilerInfo (LocalBuildInfo -> Compiler
compiler LocalBuildInfo
lbi))
(LocalBuildInfo -> Platform
hostPlatform LocalBuildInfo
lbi)
(LocalBuildInfo -> InstallDirs PathTemplate
installDirTemplates LocalBuildInfo
lbi)
substPathTemplate :: PackageId -> LocalBuildInfo
-> UnitId
-> PathTemplate -> FilePath
substPathTemplate :: PackageIdentifier
-> LocalBuildInfo -> UnitId -> PathTemplate -> FilePath
substPathTemplate PackageIdentifier
pkgid LocalBuildInfo
lbi UnitId
uid = PathTemplate -> FilePath
fromPathTemplate
(PathTemplate -> FilePath)
-> (PathTemplate -> PathTemplate) -> PathTemplate -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ( PathTemplateEnv -> PathTemplate -> PathTemplate
InstallDirs.substPathTemplate PathTemplateEnv
env )
where env :: PathTemplateEnv
env = PackageIdentifier
-> UnitId -> CompilerInfo -> Platform -> PathTemplateEnv
initialPathTemplateEnv
PackageIdentifier
pkgid
UnitId
uid
(Compiler -> CompilerInfo
compilerInfo (LocalBuildInfo -> Compiler
compiler LocalBuildInfo
lbi))
(LocalBuildInfo -> Platform
hostPlatform LocalBuildInfo
lbi)