module Distribution.Simple.LocalBuildInfo (
LocalBuildInfo(..),
externalPackageDeps,
inplacePackageId,
withLibLBI,
withExeLBI,
withComponentsLBI,
withTestLBI,
ComponentLocalBuildInfo(..),
module Distribution.Simple.InstallDirs,
absoluteInstallDirs, prefixRelativeInstallDirs,
substPathTemplate
) where
import Distribution.Simple.InstallDirs hiding (absoluteInstallDirs,
prefixRelativeInstallDirs,
substPathTemplate, )
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Simple.Program (ProgramConfiguration)
import Distribution.PackageDescription
( PackageDescription(..), withLib, Library, withExe
, Executable(exeName), withTest, TestSuite(..)
, Component(..) )
import Distribution.Package
( PackageId, Package(..), InstalledPackageId(..) )
import Distribution.Simple.Compiler
( Compiler(..), PackageDBStack, OptimisationLevel )
import Distribution.Simple.PackageIndex
( PackageIndex )
import Distribution.Simple.Utils
( die )
import Distribution.Simple.Setup
( ConfigFlags )
import Distribution.Text
( display )
import Data.List (nub)
data executableConfigs :: [(String, ComponentLocalBuildInfo)]LocalBuildInfo = LocalBuildInfo {
configFlags :: ConfigFlags,
extraConfigArgs :: [String],
installDirTemplates :: InstallDirTemplates,
compiler :: Compiler,
buildDir :: FilePath,
scratchDir :: FilePath,
libraryConfig :: Maybe ComponentLocalBuildInfo,
executableConfigs :: [(String, ComponentLocalBuildInfo)],
compBuildOrder :: [Component],
testSuiteConfigs :: [(String, ComponentLocalBuildInfo)],
installedPkgs :: PackageIndex,
pkgDescrFile :: Maybe FilePath,
localPkgDescr :: PackageDescription,
withPrograms :: ProgramConfiguration,
withPackageDB :: PackageDBStack,
withVanillaLib:: Bool,
withProfLib :: Bool,
withSharedLib :: Bool,
withDynExe :: Bool,
withProfExe :: Bool,
withOptimization :: OptimisationLevel,
withGHCiLib :: Bool,
splitObjs :: Bool,
stripExes :: Bool,
progPrefix :: PathTemplate,
progSuffix :: PathTemplate
} deriving (D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
data componentPackageDeps :: [(InstalledPackageId, PackageId)]ComponentLocalBuildInfo = ComponentLocalBuildInfo {
componentPackageDeps :: [(InstalledPackageId, PackageId)]
}
deriving (D:Read ::
(Int -> ReadS a)
-> ReadS [a]
-> ReadPrec a
-> ReadPrec [a]
-> T:Read aRead, D:Show ::
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> T:Show aShow)
externalPackageDeps :: LocalBuildInfo -> [(InstalledPackageId, PackageId)]
externalPackageDeps lbi = nub :: Eq a => [a] -> [a]nub ($) :: (a -> b) -> a -> b$
maybe :: b -> (a -> b) -> Maybe a -> bmaybe [] :: [a][] componentPackageDeps ::
ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]componentPackageDeps (libraryConfig :: LocalBuildInfo -> Maybe ComponentLocalBuildInfolibraryConfig lbi :: LocalBuildInfolbi)
(++) :: [a] -> [a] -> [a]++ concatMap :: (a -> [b]) -> [a] -> [b]concatMap (componentPackageDeps ::
ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]componentPackageDeps (.) :: (b -> c) -> (a -> b) -> a -> c. snd :: (a, b) -> bsnd) (executableConfigs ::
LocalBuildInfo -> [(String, ComponentLocalBuildInfo)]executableConfigs lbi :: LocalBuildInfolbi)
inplacePackageId :: PackageId -> InstalledPackageId
inplacePackageId pkgid = InstalledPackageId :: String -> InstalledPackageIdInstalledPackageId (display :: Text a => a -> Stringdisplay pkgid :: PackageIdpkgid (++) :: [a] -> [a] -> [a]++ "-inplace")
withLibLBI :: PackageDescription -> LocalBuildInfo
-> (Library -> ComponentLocalBuildInfo -> IO ()) -> IO ()
withLibLBI pkg_descr lbi f = withLib :: PackageDescription -> (Library -> IO ()) -> IO ()withLib pkg_descr :: PackageDescriptionpkg_descr ($) :: (a -> b) -> a -> b$ \lib ->
case libraryConfig :: LocalBuildInfo -> Maybe ComponentLocalBuildInfolibraryConfig lbi :: LocalBuildInfolbi of
Just clbi -> f :: Library -> ComponentLocalBuildInfo -> IO ()f lib :: Librarylib clbi :: ComponentLocalBuildInfoclbi
Nothing -> die :: String -> IO adie ($) :: (a -> b) -> a -> b$ "internal error: the package contains a library "
(++) :: [a] -> [a] -> [a]++ "but there is no corresponding configuration data"
withExeLBI :: PackageDescription -> LocalBuildInfo
-> (Executable -> ComponentLocalBuildInfo -> IO ()) -> IO ()
withExeLBI pkg_descr lbi f = withExe :: PackageDescription -> (Executable -> IO ()) -> IO ()withExe pkg_descr :: PackageDescriptionpkg_descr ($) :: (a -> b) -> a -> b$ \exe ->
case lookup :: Eq a => a -> [(a, b)] -> Maybe blookup (exeName :: Executable -> StringexeName exe :: Executableexe) (executableConfigs ::
LocalBuildInfo -> [(String, ComponentLocalBuildInfo)]executableConfigs lbi :: LocalBuildInfolbi) of
Just clbi -> f :: Library -> ComponentLocalBuildInfo -> IO ()f exe :: Executableexe clbi :: ComponentLocalBuildInfoclbi
Nothing -> die :: String -> IO adie ($) :: (a -> b) -> a -> b$ "internal error: the package contains an executable "
(++) :: [a] -> [a] -> [a]++ exeName :: Executable -> StringexeName exe :: Executableexe (++) :: [a] -> [a] -> [a]++ " but there is no corresponding "
(++) :: [a] -> [a] -> [a]++ "configuration data"
withComponentsLBI :: LocalBuildInfo
-> (Component -> ComponentLocalBuildInfo -> IO ())
-> IO ()
withComponentsLBI lbi f = mapM_ :: Monad m => (a -> m b) -> [a] -> m ()mapM_ compF :: Component -> IO ()compF (compBuildOrder :: LocalBuildInfo -> [Component]compBuildOrder lbi :: LocalBuildInfolbi)
where
compF l@(CLib _lib) =
case libraryConfig :: LocalBuildInfo -> Maybe ComponentLocalBuildInfolibraryConfig lbi :: LocalBuildInfolbi of
Just clbi -> f :: Library -> ComponentLocalBuildInfo -> IO ()f l :: Componentl clbi :: ComponentLocalBuildInfoclbi
Nothing -> die :: String -> IO adie ($) :: (a -> b) -> a -> b$ "internal error: the package contains a library "
(++) :: [a] -> [a] -> [a]++ "but there is no corresponding configuration data"
compF r@(CExe exe) =
case lookup :: Eq a => a -> [(a, b)] -> Maybe blookup (exeName :: Executable -> StringexeName exe :: Executableexe) (executableConfigs ::
LocalBuildInfo -> [(String, ComponentLocalBuildInfo)]executableConfigs lbi :: LocalBuildInfolbi) of
Just clbi -> f :: Library -> ComponentLocalBuildInfo -> IO ()f r :: Componentr clbi :: ComponentLocalBuildInfoclbi
Nothing -> die :: String -> IO adie ($) :: (a -> b) -> a -> b$ "internal error: the package contains an executable "
(++) :: [a] -> [a] -> [a]++ exeName :: Executable -> StringexeName exe :: Executableexe (++) :: [a] -> [a] -> [a]++ " but there is no corresponding "
(++) :: [a] -> [a] -> [a]++ "configuration data"
compF t@(CTst test) =
case lookup :: Eq a => a -> [(a, b)] -> Maybe blookup (testName :: TestSuite -> StringtestName test :: TestSuitetest) (testSuiteConfigs ::
LocalBuildInfo -> [(String, ComponentLocalBuildInfo)]testSuiteConfigs lbi :: LocalBuildInfolbi) of
Just clbi -> f :: Library -> ComponentLocalBuildInfo -> IO ()f t :: Componentt clbi :: ComponentLocalBuildInfoclbi
Nothing -> die :: String -> IO adie ($) :: (a -> b) -> a -> b$ "internal error: the package contains a test suite "
(++) :: [a] -> [a] -> [a]++ testName :: TestSuite -> StringtestName test :: TestSuitetest (++) :: [a] -> [a] -> [a]++ " but there is no corresponding "
(++) :: [a] -> [a] -> [a]++ "configuration data"
withTestLBI :: PackageDescription -> LocalBuildInfo
-> (TestSuite -> ComponentLocalBuildInfo -> IO ()) -> IO ()
withTestLBI pkg_descr lbi f =
let wrapper test = case lookup :: Eq a => a -> [(a, b)] -> Maybe blookup (testName :: TestSuite -> StringtestName test :: TestSuitetest) (testSuiteConfigs ::
LocalBuildInfo -> [(String, ComponentLocalBuildInfo)]testSuiteConfigs lbi :: LocalBuildInfolbi) of
Just clbi -> f :: Library -> ComponentLocalBuildInfo -> IO ()f test :: TestSuitetest clbi :: ComponentLocalBuildInfoclbi
Nothing -> die :: String -> IO adie ($) :: (a -> b) -> a -> b$ "internal error: the package contains a test suite "
(++) :: [a] -> [a] -> [a]++ testName :: TestSuite -> StringtestName test :: TestSuitetest (++) :: [a] -> [a] -> [a]++ " but there is no corresponding "
(++) :: [a] -> [a] -> [a]++ "configuration data"
in withTest :: PackageDescription -> (TestSuite -> IO ()) -> IO ()withTest pkg_descr :: PackageDescriptionpkg_descr wrapper :: TestSuite -> IO ()wrapper
absoluteInstallDirs :: PackageDescription -> LocalBuildInfo -> CopyDest
-> InstallDirs FilePath
absoluteInstallDirs pkg lbi copydest =
absoluteInstallDirs ::
PackageIdentifier
-> CompilerId
-> CopyDest
-> InstallDirs PathTemplate
-> InstallDirs FilePathInstallDirs.absoluteInstallDirs
(packageId :: Package pkg => pkg -> PackageIdentifierpackageId pkg :: PackageDescriptionpkg)
(compilerId :: Compiler -> CompilerIdcompilerId (compiler :: LocalBuildInfo -> Compilercompiler lbi :: LocalBuildInfolbi))
copydest :: CopyDestcopydest
(installDirTemplates :: LocalBuildInfo -> InstallDirTemplatesinstallDirTemplates lbi :: LocalBuildInfolbi)
prefixRelativeInstallDirs :: PackageId -> LocalBuildInfo
-> InstallDirs (Maybe FilePath)
prefixRelativeInstallDirs pkg_descr lbi =
prefixRelativeInstallDirs ::
PackageIdentifier
-> CompilerId
-> InstallDirTemplates
-> InstallDirs (Maybe FilePath)InstallDirs.prefixRelativeInstallDirs
(packageId :: Package pkg => pkg -> PackageIdentifierpackageId pkg_descr :: PackageDescriptionpkg_descr)
(compilerId :: Compiler -> CompilerIdcompilerId (compiler :: LocalBuildInfo -> Compilercompiler lbi :: LocalBuildInfolbi))
(installDirTemplates :: LocalBuildInfo -> InstallDirTemplatesinstallDirTemplates lbi :: LocalBuildInfolbi)
substPathTemplate :: PackageId -> LocalBuildInfo
-> PathTemplate -> FilePath
substPathTemplate pkgid lbi = fromPathTemplate :: PathTemplate -> FilePathfromPathTemplate
(.) :: (b -> c) -> (a -> b) -> a -> c. ( substPathTemplate ::
PathTemplateEnv -> PathTemplate -> PathTemplateInstallDirs.substPathTemplate env :: PathTemplateEnvenv )
where env = initialPathTemplateEnv ::
PackageIdentifier -> CompilerId -> PathTemplateEnvinitialPathTemplateEnv
pkgid :: PackageIdpkgid
(compilerId :: Compiler -> CompilerIdcompilerId (compiler :: LocalBuildInfo -> Compilercompiler lbi :: LocalBuildInfolbi))