{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RankNTypes #-}
module Distribution.Simple.LocalBuildInfo
( LocalBuildInfo (..)
, localComponentId
, localUnitId
, localCompatPackageKey
, buildDir
, packageRoot
, progPrefix
, progSuffix
, interpretSymbolicPathLBI
, mbWorkDirLBI
, absoluteWorkingDirLBI
, buildWays
, 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 Distribution.Compat.Prelude
import Prelude ()
import Distribution.Types.Component
import Distribution.Types.ComponentLocalBuildInfo
import Distribution.Types.ComponentName
import Distribution.Types.LocalBuildInfo
import Distribution.Types.PackageDescription
import Distribution.Types.PackageId
import Distribution.Types.TargetInfo
import Distribution.Types.UnitId
import Distribution.Types.UnqualComponentName
import qualified Distribution.Compat.Graph as Graph
import qualified Distribution.InstalledPackageInfo as Installed
import Distribution.ModuleName
import Distribution.Package
import Distribution.PackageDescription
import Distribution.Pretty
import Distribution.Simple.Compiler
import Distribution.Simple.Flag
import Distribution.Simple.InstallDirs hiding
( absoluteInstallDirs
, prefixRelativeInstallDirs
, substPathTemplate
)
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Simple.PackageIndex
import Distribution.Simple.Setup.Common
import Distribution.Simple.Setup.Config
import Distribution.Simple.Utils
import Distribution.Utils.Path
import Data.List (stripPrefix)
import qualified System.Directory as Directory
( canonicalizePath
, doesDirectoryExist
)
componentBuildDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> SymbolicPath Pkg (Dir Build)
componentBuildDir :: LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
componentBuildDir LocalBuildInfo
lbi ComponentLocalBuildInfo
clbi =
(LocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
buildDir LocalBuildInfo
lbi SymbolicPath Pkg ('Dir Build)
-> RelativePath Build ('Dir Build) -> SymbolicPath Pkg ('Dir Build)
forall p q r. PathLike p q r => p -> q -> r
</>) (RelativePath Build ('Dir Build) -> SymbolicPath Pkg ('Dir Build))
-> RelativePath Build ('Dir Build) -> SymbolicPath Pkg ('Dir Build)
forall a b. (a -> b) -> a -> b
$
String -> RelativePath Build ('Dir Build)
forall from (to :: FileOrDir).
HasCallStack =>
String -> RelativePath from to
makeRelativePathEx (String -> RelativePath Build ('Dir Build))
-> String -> RelativePath Build ('Dir Build)
forall a b. (a -> b) -> a -> b
$
case ComponentLocalBuildInfo -> ComponentName
componentLocalName ComponentLocalBuildInfo
clbi of
CLibName LibraryName
LMainLibName ->
if UnitId -> String
forall a. Pretty a => a -> String
prettyShow (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi) String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== ComponentId -> String
forall a. Pretty a => a -> String
prettyShow (ComponentLocalBuildInfo -> ComponentId
componentComponentId ComponentLocalBuildInfo
clbi)
then String
""
else UnitId -> String
forall a. Pretty a => a -> String
prettyShow (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi)
CLibName (LSubLibName UnqualComponentName
s) ->
if UnitId -> String
forall a. Pretty a => a -> String
prettyShow (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi) String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== ComponentId -> String
forall a. Pretty a => a -> String
prettyShow (ComponentLocalBuildInfo -> ComponentId
componentComponentId ComponentLocalBuildInfo
clbi)
then UnqualComponentName -> String
unUnqualComponentName UnqualComponentName
s
else UnitId -> String
forall a. Pretty a => a -> String
prettyShow (ComponentLocalBuildInfo -> UnitId
componentUnitId ComponentLocalBuildInfo
clbi)
CFLibName UnqualComponentName
s -> UnqualComponentName -> String
unUnqualComponentName UnqualComponentName
s
CExeName UnqualComponentName
s -> UnqualComponentName -> String
unUnqualComponentName UnqualComponentName
s
CTestName UnqualComponentName
s -> UnqualComponentName -> String
unUnqualComponentName UnqualComponentName
s
CBenchName UnqualComponentName
s -> UnqualComponentName -> String
unUnqualComponentName UnqualComponentName
s
interpretSymbolicPathLBI :: LocalBuildInfo -> SymbolicPathX allowAbsolute Pkg to -> FilePath
interpretSymbolicPathLBI :: forall (allowAbsolute :: AllowAbsolute) (to :: FileOrDir).
LocalBuildInfo -> SymbolicPathX allowAbsolute Pkg to -> String
interpretSymbolicPathLBI LocalBuildInfo
lbi =
Maybe (SymbolicPath CWD ('Dir Pkg))
-> SymbolicPathX allowAbsolute Pkg to -> String
forall from (allowAbsolute :: AllowAbsolute) (to :: FileOrDir).
Maybe (SymbolicPath CWD ('Dir from))
-> SymbolicPathX allowAbsolute from to -> String
interpretSymbolicPath (LocalBuildInfo -> Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDirLBI LocalBuildInfo
lbi)
mbWorkDirLBI :: LocalBuildInfo -> Maybe (SymbolicPath CWD (Dir Pkg))
mbWorkDirLBI :: LocalBuildInfo -> Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDirLBI =
Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall a. Flag a -> Maybe a
flagToMaybe (Flag (SymbolicPath CWD ('Dir Pkg))
-> Maybe (SymbolicPath CWD ('Dir Pkg)))
-> (LocalBuildInfo -> Flag (SymbolicPath CWD ('Dir Pkg)))
-> LocalBuildInfo
-> Maybe (SymbolicPath CWD ('Dir Pkg))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CommonSetupFlags -> Flag (SymbolicPath CWD ('Dir Pkg))
setupWorkingDir (CommonSetupFlags -> Flag (SymbolicPath CWD ('Dir Pkg)))
-> (LocalBuildInfo -> CommonSetupFlags)
-> LocalBuildInfo
-> Flag (SymbolicPath CWD ('Dir Pkg))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfigFlags -> CommonSetupFlags
configCommonFlags (ConfigFlags -> CommonSetupFlags)
-> (LocalBuildInfo -> ConfigFlags)
-> LocalBuildInfo
-> CommonSetupFlags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocalBuildInfo -> ConfigFlags
configFlags
absoluteWorkingDirLBI :: LocalBuildInfo -> IO (AbsolutePath (Dir Pkg))
absoluteWorkingDirLBI :: LocalBuildInfo -> IO (AbsolutePath ('Dir Pkg))
absoluteWorkingDirLBI LocalBuildInfo
lbi = Maybe (SymbolicPath CWD ('Dir Pkg)) -> IO (AbsolutePath ('Dir Pkg))
forall (to :: FileOrDir).
Maybe (SymbolicPath CWD to) -> IO (AbsolutePath to)
absoluteWorkingDir (LocalBuildInfo -> Maybe (SymbolicPath CWD ('Dir Pkg))
mbWorkDirLBI LocalBuildInfo
lbi)
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 a. a -> IO a
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 a. a -> IO a
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{$sel:componentGraph:LocalBuildInfo :: LocalBuildInfo -> Graph ComponentLocalBuildInfo
componentGraph = Graph ComponentLocalBuildInfo
compGraph}) =
Graph ComponentLocalBuildInfo -> [ComponentLocalBuildInfo]
forall a. Graph a -> [a]
Graph.topSort Graph ComponentLocalBuildInfo
compGraph
depLibraryPaths
:: Bool
-> Bool
-> LocalBuildInfo
-> ComponentLocalBuildInfo
-> IO [FilePath]
depLibraryPaths :: Bool
-> Bool -> LocalBuildInfo -> ComponentLocalBuildInfo -> IO [String]
depLibraryPaths
Bool
inplace
Bool
relative
lbi :: LocalBuildInfo
lbi@( LocalBuildInfo
{ $sel:localPkgDescr:LocalBuildInfo :: LocalBuildInfo -> PackageDescription
localPkgDescr = PackageDescription
pkgDescr
, $sel:installedPkgs:LocalBuildInfo :: LocalBuildInfo -> InstalledPackageIndex
installedPkgs = InstalledPackageIndex
installed
}
)
ComponentLocalBuildInfo
clbi = do
let installDirs :: InstallDirs String
installDirs = PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs String
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 :: String
relDir
| Bool
executable = InstallDirs String -> String
forall dir. InstallDirs dir -> dir
bindir InstallDirs String
installDirs
| Bool
otherwise = InstallDirs String -> String
forall dir. InstallDirs dir -> dir
libdir InstallDirs String
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 :: [String]
internalLibs =
[ ComponentLocalBuildInfo -> String
getLibDir (TargetInfo -> ComponentLocalBuildInfo
targetCLBI TargetInfo
sub_target)
| TargetInfo
sub_target <-
PackageDescription -> LocalBuildInfo -> [UnitId] -> [TargetInfo]
neededTargetsInBuildOrder'
PackageDescription
pkgDescr
LocalBuildInfo
lbi
[UnitId]
internalDeps
]
getLibDir :: ComponentLocalBuildInfo -> String
getLibDir ComponentLocalBuildInfo
sub_clbi
| Bool
inplace = LocalBuildInfo -> SymbolicPath Pkg ('Dir Build) -> String
forall (allowAbsolute :: AllowAbsolute) (to :: FileOrDir).
LocalBuildInfo -> SymbolicPathX allowAbsolute Pkg to -> String
interpretSymbolicPathLBI LocalBuildInfo
lbi (SymbolicPath Pkg ('Dir Build) -> String)
-> SymbolicPath Pkg ('Dir Build) -> String
forall a b. (a -> b) -> a -> b
$ LocalBuildInfo
-> ComponentLocalBuildInfo -> SymbolicPath Pkg ('Dir Build)
componentBuildDir LocalBuildInfo
lbi ComponentLocalBuildInfo
sub_clbi
| Bool
otherwise = InstallDirs String -> String
forall dir. InstallDirs dir -> dir
dynlibdir (PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs String
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 (InstalledPackageIndex -> [InstalledPackageInfo]
forall a. PackageIndex a -> [a]
allPackages InstalledPackageIndex
installed)
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 a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [UnitId]
internalDeps)
getDynDir :: InstalledPackageInfo -> [String]
getDynDir InstalledPackageInfo
pkg = case InstalledPackageInfo -> [String]
Installed.libraryDynDirs InstalledPackageInfo
pkg of
[] -> InstalledPackageInfo -> [String]
Installed.libraryDirs InstalledPackageInfo
pkg
[String]
d -> [String]
d
allDepLibDirs :: [String]
allDepLibDirs = (InstalledPackageInfo -> [String])
-> [InstalledPackageInfo] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap InstalledPackageInfo -> [String]
getDynDir [InstalledPackageInfo]
external_ipkgs
allDepLibDirs' :: [String]
allDepLibDirs' = [String]
internalLibs [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
allDepLibDirs
[String]
allDepLibDirsC <- (String -> IO String) -> [String] -> IO [String]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse String -> IO String
canonicalizePathNoFail [String]
allDepLibDirs'
let p :: String
p = InstallDirs String -> String
forall dir. InstallDirs dir -> dir
prefix InstallDirs String
installDirs
prefixRelative :: String -> Bool
prefixRelative String
l = Maybe String -> Bool
forall a. Maybe a -> Bool
isJust (String -> String -> Maybe String
forall a. Eq a => [a] -> [a] -> Maybe [a]
stripPrefix String
p String
l)
libPaths :: [String]
libPaths
| Bool
relative
Bool -> Bool -> Bool
&& String -> Bool
prefixRelative String
relDir =
(String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map
( \String
l ->
if String -> Bool
prefixRelative String
l
then String -> String -> String
shortRelativePath String
relDir String
l
else String
l
)
[String]
allDepLibDirsC
| Bool
otherwise = [String]
allDepLibDirsC
[String] -> IO [String]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([String] -> IO [String]) -> [String] -> IO [String]
forall a b. (a -> b) -> a -> b
$ [String] -> [String]
forall a. Ord a => [a] -> [a]
ordNub [String]
libPaths
where
canonicalizePathNoFail :: String -> IO String
canonicalizePathNoFail String
p = do
Bool
exists <- String -> IO Bool
Directory.doesDirectoryExist String
p
if Bool
exists
then String -> IO String
Directory.canonicalizePath String
p
else String -> IO String
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return String
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 String
absoluteInstallDirs PackageDescription
pkg LocalBuildInfo
lbi CopyDest
copydest =
PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs String
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 String
absoluteComponentInstallDirs
PackageDescription
pkg
(LocalBuildInfo{$sel:compiler:LocalBuildInfo :: LocalBuildInfo -> Compiler
compiler = Compiler
comp, $sel:hostPlatform:LocalBuildInfo :: LocalBuildInfo -> Platform
hostPlatform = Platform
plat, $sel:installDirTemplates:LocalBuildInfo :: LocalBuildInfo -> InstallDirTemplates
installDirTemplates = InstallDirTemplates
installDirs})
UnitId
uid
CopyDest
copydest =
PackageId
-> UnitId
-> CompilerInfo
-> CopyDest
-> Platform
-> InstallDirTemplates
-> InstallDirs String
InstallDirs.absoluteInstallDirs
(PackageDescription -> PackageId
forall pkg. Package pkg => pkg -> PackageId
packageId PackageDescription
pkg)
UnitId
uid
(Compiler -> CompilerInfo
compilerInfo Compiler
comp)
CopyDest
copydest
Platform
plat
InstallDirTemplates
installDirs
absoluteInstallCommandDirs
:: PackageDescription
-> LocalBuildInfo
-> UnitId
-> CopyDest
-> InstallDirs FilePath
absoluteInstallCommandDirs :: PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs String
absoluteInstallCommandDirs PackageDescription
pkg LocalBuildInfo
lbi UnitId
uid CopyDest
copydest =
InstallDirs String
dirs
{
datadir = datadir dirs'
,
docdir = docdir dirs'
, htmldir = htmldir dirs'
, haddockdir = haddockdir dirs'
}
where
dirs :: InstallDirs String
dirs = PackageDescription
-> LocalBuildInfo -> UnitId -> CopyDest -> InstallDirs String
absoluteComponentInstallDirs PackageDescription
pkg LocalBuildInfo
lbi UnitId
uid CopyDest
copydest
dirs' :: InstallDirs String
dirs' = PackageDescription
-> LocalBuildInfo -> CopyDest -> InstallDirs String
absoluteInstallDirs PackageDescription
pkg LocalBuildInfo
lbi CopyDest
copydest
prefixRelativeInstallDirs
:: PackageId
-> LocalBuildInfo
-> InstallDirs (Maybe FilePath)
prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo -> InstallDirs (Maybe String)
prefixRelativeInstallDirs PackageId
pkg_descr LocalBuildInfo
lbi =
PackageId -> LocalBuildInfo -> UnitId -> InstallDirs (Maybe String)
prefixRelativeComponentInstallDirs PackageId
pkg_descr LocalBuildInfo
lbi (LocalBuildInfo -> UnitId
localUnitId LocalBuildInfo
lbi)
prefixRelativeComponentInstallDirs
:: PackageId
-> LocalBuildInfo
-> UnitId
-> InstallDirs (Maybe FilePath)
prefixRelativeComponentInstallDirs :: PackageId -> LocalBuildInfo -> UnitId -> InstallDirs (Maybe String)
prefixRelativeComponentInstallDirs
PackageId
pkg_descr
(LocalBuildInfo{$sel:compiler:LocalBuildInfo :: LocalBuildInfo -> Compiler
compiler = Compiler
comp, $sel:hostPlatform:LocalBuildInfo :: LocalBuildInfo -> Platform
hostPlatform = Platform
plat, $sel:installDirTemplates:LocalBuildInfo :: LocalBuildInfo -> InstallDirTemplates
installDirTemplates = InstallDirTemplates
installDirs})
UnitId
uid =
PackageId
-> UnitId
-> CompilerInfo
-> Platform
-> InstallDirTemplates
-> InstallDirs (Maybe String)
InstallDirs.prefixRelativeInstallDirs
(PackageId -> PackageId
forall pkg. Package pkg => pkg -> PackageId
packageId PackageId
pkg_descr)
UnitId
uid
(Compiler -> CompilerInfo
compilerInfo Compiler
comp)
Platform
plat
InstallDirTemplates
installDirs
substPathTemplate
:: PackageId
-> LocalBuildInfo
-> UnitId
-> PathTemplate
-> FilePath
substPathTemplate :: PackageId -> LocalBuildInfo -> UnitId -> PathTemplate -> String
substPathTemplate
PackageId
pkgid
(LocalBuildInfo{$sel:compiler:LocalBuildInfo :: LocalBuildInfo -> Compiler
compiler = Compiler
comp, $sel:hostPlatform:LocalBuildInfo :: LocalBuildInfo -> Platform
hostPlatform = Platform
plat})
UnitId
uid =
PathTemplate -> String
fromPathTemplate
(PathTemplate -> String)
-> (PathTemplate -> PathTemplate) -> PathTemplate -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PathTemplateEnv -> PathTemplate -> PathTemplate
InstallDirs.substPathTemplate PathTemplateEnv
env)
where
env :: PathTemplateEnv
env =
PackageId -> UnitId -> CompilerInfo -> Platform -> PathTemplateEnv
initialPathTemplateEnv
PackageId
pkgid
UnitId
uid
(Compiler -> CompilerInfo
compilerInfo Compiler
comp)
Platform
plat