{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE TypeFamilies #-}
module Distribution.Client.ProjectPlanning.Types (
SolverInstallPlan,
ElaboratedInstallPlan,
normaliseConfiguredPackage,
ElaboratedConfiguredPackage(..),
elabDistDirParams,
elabExeDependencyPaths,
elabLibDependencies,
elabOrderLibDependencies,
elabExeDependencies,
elabOrderExeDependencies,
elabSetupDependencies,
elabPkgConfigDependencies,
elabInplaceDependencyBuildCacheFiles,
elabRequiresRegistration,
dataDirsEnvironmentForPlan,
elabPlanPackageName,
elabConfiguredName,
elabComponentName,
ElaboratedPackageOrComponent(..),
ElaboratedComponent(..),
ElaboratedPackage(..),
pkgOrderDependencies,
ElaboratedPlanPackage,
ElaboratedSharedConfig(..),
ElaboratedReadyPackage,
BuildStyle(..),
CabalFileText,
ComponentTarget(..),
showComponentTarget,
showTestComponentTarget,
showBenchComponentTarget,
SubComponentTarget(..),
isSubLibComponentTarget,
isForeignLibComponentTarget,
isExeComponentTarget,
isTestComponentTarget,
isBenchComponentTarget,
componentOptionalStanza,
SetupScriptStyle(..),
) where
import Distribution.Client.Compat.Prelude
import Prelude ()
import Distribution.Client.TargetSelector
( SubComponentTarget(..) )
import Distribution.Client.PackageHash
import Distribution.Client.Types
import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Client.InstallPlan
( GenericInstallPlan, GenericPlanPackage(..) )
import Distribution.Client.SolverInstallPlan
( SolverInstallPlan )
import Distribution.Client.DistDirLayout
import Distribution.Backpack
import Distribution.Backpack.ModuleShape
import Distribution.Verbosity (normal)
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.PkgconfigVersion
import Distribution.Types.PackageDescription (PackageDescription(..))
import Distribution.Package
import Distribution.System
import qualified Distribution.PackageDescription as Cabal
import Distribution.InstalledPackageInfo (InstalledPackageInfo)
import Distribution.Simple.Compiler
import Distribution.Simple.Build.PathsModule (pkgPathEnvVar)
import qualified Distribution.Simple.BuildTarget as Cabal
import Distribution.Simple.Program
import Distribution.ModuleName (ModuleName)
import Distribution.Simple.LocalBuildInfo
( ComponentName(..), LibraryName(..) )
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Simple.InstallDirs (PathTemplate)
import Distribution.Simple.Setup
( HaddockTarget, TestShowDetails, DumpBuildInfo (..), ReplOptions )
import Distribution.Version
import qualified Distribution.Solver.Types.ComponentDeps as CD
import Distribution.Solver.Types.ComponentDeps (ComponentDeps)
import Distribution.Solver.Types.OptionalStanza
import Distribution.Compat.Graph (IsNode(..))
import Distribution.Simple.Utils (ordNub)
import qualified Data.Map as Map
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Monoid as Mon
import System.FilePath ((</>))
type ElaboratedInstallPlan
= GenericInstallPlan InstalledPackageInfo
ElaboratedConfiguredPackage
type ElaboratedPlanPackage
= GenericPlanPackage InstalledPackageInfo
ElaboratedConfiguredPackage
elabPlanPackageName :: Verbosity -> ElaboratedPlanPackage -> String
elabPlanPackageName :: Verbosity -> ElaboratedPlanPackage -> String
elabPlanPackageName Verbosity
verbosity (PreExisting InstalledPackageInfo
ipkg)
| Verbosity
verbosity Verbosity -> Verbosity -> Bool
forall a. Ord a => a -> a -> Bool
<= Verbosity
normal = PackageName -> String
forall a. Pretty a => a -> String
prettyShow (InstalledPackageInfo -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName InstalledPackageInfo
ipkg)
| Bool
otherwise = UnitId -> String
forall a. Pretty a => a -> String
prettyShow (InstalledPackageInfo -> UnitId
forall pkg. HasUnitId pkg => pkg -> UnitId
installedUnitId InstalledPackageInfo
ipkg)
elabPlanPackageName Verbosity
verbosity (Configured ElaboratedConfiguredPackage
elab)
= Verbosity -> ElaboratedConfiguredPackage -> String
elabConfiguredName Verbosity
verbosity ElaboratedConfiguredPackage
elab
elabPlanPackageName Verbosity
verbosity (Installed ElaboratedConfiguredPackage
elab)
= Verbosity -> ElaboratedConfiguredPackage -> String
elabConfiguredName Verbosity
verbosity ElaboratedConfiguredPackage
elab
data ElaboratedSharedConfig
= ElaboratedSharedConfig {
ElaboratedSharedConfig -> Platform
pkgConfigPlatform :: Platform,
ElaboratedSharedConfig -> Compiler
pkgConfigCompiler :: Compiler,
ElaboratedSharedConfig -> ProgramDb
pkgConfigCompilerProgs :: ProgramDb,
ElaboratedSharedConfig -> ReplOptions
pkgConfigReplOptions :: ReplOptions
}
deriving (Int -> ElaboratedSharedConfig -> ShowS
[ElaboratedSharedConfig] -> ShowS
ElaboratedSharedConfig -> String
(Int -> ElaboratedSharedConfig -> ShowS)
-> (ElaboratedSharedConfig -> String)
-> ([ElaboratedSharedConfig] -> ShowS)
-> Show ElaboratedSharedConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElaboratedSharedConfig] -> ShowS
$cshowList :: [ElaboratedSharedConfig] -> ShowS
show :: ElaboratedSharedConfig -> String
$cshow :: ElaboratedSharedConfig -> String
showsPrec :: Int -> ElaboratedSharedConfig -> ShowS
$cshowsPrec :: Int -> ElaboratedSharedConfig -> ShowS
Show, (forall x. ElaboratedSharedConfig -> Rep ElaboratedSharedConfig x)
-> (forall x.
Rep ElaboratedSharedConfig x -> ElaboratedSharedConfig)
-> Generic ElaboratedSharedConfig
forall x. Rep ElaboratedSharedConfig x -> ElaboratedSharedConfig
forall x. ElaboratedSharedConfig -> Rep ElaboratedSharedConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ElaboratedSharedConfig x -> ElaboratedSharedConfig
$cfrom :: forall x. ElaboratedSharedConfig -> Rep ElaboratedSharedConfig x
Generic, Typeable)
instance Binary ElaboratedSharedConfig
instance Structured ElaboratedSharedConfig
data ElaboratedConfiguredPackage
= ElaboratedConfiguredPackage {
ElaboratedConfiguredPackage -> UnitId
elabUnitId :: UnitId,
ElaboratedConfiguredPackage -> ComponentId
elabComponentId :: ComponentId,
ElaboratedConfiguredPackage -> Map ModuleName Module
elabInstantiatedWith :: Map ModuleName Module,
ElaboratedConfiguredPackage -> Map ModuleName OpenModule
elabLinkedInstantiatedWith :: Map ModuleName OpenModule,
ElaboratedConfiguredPackage -> Bool
elabIsCanonical :: Bool,
ElaboratedConfiguredPackage -> PackageId
elabPkgSourceId :: PackageId,
ElaboratedConfiguredPackage -> ModuleShape
elabModuleShape :: ModuleShape,
ElaboratedConfiguredPackage -> FlagAssignment
elabFlagAssignment :: Cabal.FlagAssignment,
ElaboratedConfiguredPackage -> FlagAssignment
elabFlagDefaults :: Cabal.FlagAssignment,
ElaboratedConfiguredPackage -> PackageDescription
elabPkgDescription :: Cabal.PackageDescription,
ElaboratedConfiguredPackage -> PackageLocation (Maybe String)
elabPkgSourceLocation :: PackageLocation (Maybe FilePath),
ElaboratedConfiguredPackage -> Maybe PackageSourceHash
elabPkgSourceHash :: Maybe PackageSourceHash,
ElaboratedConfiguredPackage -> Bool
elabLocalToProject :: Bool,
ElaboratedConfiguredPackage -> BuildStyle
elabBuildStyle :: BuildStyle,
ElaboratedConfiguredPackage -> ComponentRequestedSpec
elabEnabledSpec :: ComponentRequestedSpec,
ElaboratedConfiguredPackage -> OptionalStanzaSet
elabStanzasAvailable :: OptionalStanzaSet,
ElaboratedConfiguredPackage -> OptionalStanzaMap (Maybe Bool)
elabStanzasRequested :: OptionalStanzaMap (Maybe Bool),
ElaboratedConfiguredPackage -> [Maybe PackageDB]
elabPackageDbs :: [Maybe PackageDB],
ElaboratedConfiguredPackage -> PackageDBStack
elabSetupPackageDBStack :: PackageDBStack,
ElaboratedConfiguredPackage -> PackageDBStack
elabBuildPackageDBStack :: PackageDBStack,
ElaboratedConfiguredPackage -> PackageDBStack
elabRegisterPackageDBStack :: PackageDBStack,
ElaboratedConfiguredPackage -> PackageDBStack
elabInplaceSetupPackageDBStack :: PackageDBStack,
ElaboratedConfiguredPackage -> PackageDBStack
elabInplaceBuildPackageDBStack :: PackageDBStack,
ElaboratedConfiguredPackage -> PackageDBStack
elabInplaceRegisterPackageDBStack :: PackageDBStack,
ElaboratedConfiguredPackage -> Maybe CabalFileText
elabPkgDescriptionOverride :: Maybe CabalFileText,
ElaboratedConfiguredPackage -> Bool
elabVanillaLib :: Bool,
ElaboratedConfiguredPackage -> Bool
elabSharedLib :: Bool,
ElaboratedConfiguredPackage -> Bool
elabStaticLib :: Bool,
ElaboratedConfiguredPackage -> Bool
elabDynExe :: Bool,
ElaboratedConfiguredPackage -> Bool
elabFullyStaticExe :: Bool,
ElaboratedConfiguredPackage -> Bool
elabGHCiLib :: Bool,
ElaboratedConfiguredPackage -> Bool
elabProfLib :: Bool,
ElaboratedConfiguredPackage -> Bool
elabProfExe :: Bool,
ElaboratedConfiguredPackage -> ProfDetailLevel
elabProfLibDetail :: ProfDetailLevel,
ElaboratedConfiguredPackage -> ProfDetailLevel
elabProfExeDetail :: ProfDetailLevel,
ElaboratedConfiguredPackage -> Bool
elabCoverage :: Bool,
ElaboratedConfiguredPackage -> OptimisationLevel
elabOptimization :: OptimisationLevel,
ElaboratedConfiguredPackage -> Bool
elabSplitObjs :: Bool,
ElaboratedConfiguredPackage -> Bool
elabSplitSections :: Bool,
ElaboratedConfiguredPackage -> Bool
elabStripLibs :: Bool,
ElaboratedConfiguredPackage -> Bool
elabStripExes :: Bool,
ElaboratedConfiguredPackage -> DebugInfoLevel
elabDebugInfo :: DebugInfoLevel,
ElaboratedConfiguredPackage -> DumpBuildInfo
elabDumpBuildInfo :: DumpBuildInfo,
ElaboratedConfiguredPackage -> Map String String
elabProgramPaths :: Map String FilePath,
ElaboratedConfiguredPackage -> Map String [String]
elabProgramArgs :: Map String [String],
:: [FilePath],
ElaboratedConfiguredPackage -> [String]
elabConfigureScriptArgs :: [String],
:: [FilePath],
:: [FilePath],
:: [FilePath],
:: [FilePath],
ElaboratedConfiguredPackage -> Maybe PathTemplate
elabProgPrefix :: Maybe PathTemplate,
ElaboratedConfiguredPackage -> Maybe PathTemplate
elabProgSuffix :: Maybe PathTemplate,
ElaboratedConfiguredPackage -> InstallDirs String
elabInstallDirs :: InstallDirs.InstallDirs FilePath,
ElaboratedConfiguredPackage -> Bool
elabHaddockHoogle :: Bool,
ElaboratedConfiguredPackage -> Bool
elabHaddockHtml :: Bool,
ElaboratedConfiguredPackage -> Maybe String
elabHaddockHtmlLocation :: Maybe String,
ElaboratedConfiguredPackage -> Bool
elabHaddockForeignLibs :: Bool,
ElaboratedConfiguredPackage -> HaddockTarget
elabHaddockForHackage :: HaddockTarget,
ElaboratedConfiguredPackage -> Bool
elabHaddockExecutables :: Bool,
ElaboratedConfiguredPackage -> Bool
elabHaddockTestSuites :: Bool,
ElaboratedConfiguredPackage -> Bool
elabHaddockBenchmarks :: Bool,
ElaboratedConfiguredPackage -> Bool
elabHaddockInternal :: Bool,
ElaboratedConfiguredPackage -> Maybe String
elabHaddockCss :: Maybe FilePath,
ElaboratedConfiguredPackage -> Bool
elabHaddockLinkedSource :: Bool,
ElaboratedConfiguredPackage -> Bool
elabHaddockQuickJump :: Bool,
ElaboratedConfiguredPackage -> Maybe String
elabHaddockHscolourCss :: Maybe FilePath,
ElaboratedConfiguredPackage -> Maybe PathTemplate
elabHaddockContents :: Maybe PathTemplate,
ElaboratedConfiguredPackage -> Maybe PathTemplate
elabTestMachineLog :: Maybe PathTemplate,
ElaboratedConfiguredPackage -> Maybe PathTemplate
elabTestHumanLog :: Maybe PathTemplate,
ElaboratedConfiguredPackage -> Maybe TestShowDetails
elabTestShowDetails :: Maybe TestShowDetails,
ElaboratedConfiguredPackage -> Bool
elabTestKeepTix :: Bool,
ElaboratedConfiguredPackage -> Maybe String
elabTestWrapper :: Maybe FilePath,
ElaboratedConfiguredPackage -> Bool
elabTestFailWhenNoTestSuites :: Bool,
ElaboratedConfiguredPackage -> [PathTemplate]
elabTestTestOptions :: [PathTemplate],
ElaboratedConfiguredPackage -> [PathTemplate]
elabBenchmarkOptions :: [PathTemplate],
ElaboratedConfiguredPackage -> SetupScriptStyle
elabSetupScriptStyle :: SetupScriptStyle,
ElaboratedConfiguredPackage -> Version
elabSetupScriptCliVersion :: Version,
ElaboratedConfiguredPackage -> [ComponentTarget]
elabConfigureTargets :: [ComponentTarget],
ElaboratedConfiguredPackage -> [ComponentTarget]
elabBuildTargets :: [ComponentTarget],
ElaboratedConfiguredPackage -> [ComponentTarget]
elabTestTargets :: [ComponentTarget],
ElaboratedConfiguredPackage -> [ComponentTarget]
elabBenchTargets :: [ComponentTarget],
ElaboratedConfiguredPackage -> Maybe ComponentTarget
elabReplTarget :: Maybe ComponentTarget,
ElaboratedConfiguredPackage -> [ComponentTarget]
elabHaddockTargets :: [ComponentTarget],
ElaboratedConfiguredPackage -> Bool
elabBuildHaddocks :: Bool,
ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp :: ElaboratedPackageOrComponent
}
deriving (ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage -> Bool
(ElaboratedConfiguredPackage
-> ElaboratedConfiguredPackage -> Bool)
-> (ElaboratedConfiguredPackage
-> ElaboratedConfiguredPackage -> Bool)
-> Eq ElaboratedConfiguredPackage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage -> Bool
$c/= :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage -> Bool
== :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage -> Bool
$c== :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage -> Bool
Eq, Int -> ElaboratedConfiguredPackage -> ShowS
[ElaboratedConfiguredPackage] -> ShowS
ElaboratedConfiguredPackage -> String
(Int -> ElaboratedConfiguredPackage -> ShowS)
-> (ElaboratedConfiguredPackage -> String)
-> ([ElaboratedConfiguredPackage] -> ShowS)
-> Show ElaboratedConfiguredPackage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElaboratedConfiguredPackage] -> ShowS
$cshowList :: [ElaboratedConfiguredPackage] -> ShowS
show :: ElaboratedConfiguredPackage -> String
$cshow :: ElaboratedConfiguredPackage -> String
showsPrec :: Int -> ElaboratedConfiguredPackage -> ShowS
$cshowsPrec :: Int -> ElaboratedConfiguredPackage -> ShowS
Show, (forall x.
ElaboratedConfiguredPackage -> Rep ElaboratedConfiguredPackage x)
-> (forall x.
Rep ElaboratedConfiguredPackage x -> ElaboratedConfiguredPackage)
-> Generic ElaboratedConfiguredPackage
forall x.
Rep ElaboratedConfiguredPackage x -> ElaboratedConfiguredPackage
forall x.
ElaboratedConfiguredPackage -> Rep ElaboratedConfiguredPackage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ElaboratedConfiguredPackage x -> ElaboratedConfiguredPackage
$cfrom :: forall x.
ElaboratedConfiguredPackage -> Rep ElaboratedConfiguredPackage x
Generic, Typeable)
normaliseConfiguredPackage :: ElaboratedSharedConfig
-> ElaboratedConfiguredPackage
-> ElaboratedConfiguredPackage
normaliseConfiguredPackage :: ElaboratedSharedConfig
-> ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage
normaliseConfiguredPackage ElaboratedSharedConfig{ProgramDb
pkgConfigCompilerProgs :: ProgramDb
pkgConfigCompilerProgs :: ElaboratedSharedConfig -> ProgramDb
pkgConfigCompilerProgs} ElaboratedConfiguredPackage
pkg =
ElaboratedConfiguredPackage
pkg { elabProgramArgs :: Map String [String]
elabProgramArgs = (String -> [String] -> Maybe [String])
-> Map String [String] -> Map String [String]
forall k a b. (k -> a -> Maybe b) -> Map k a -> Map k b
Map.mapMaybeWithKey String -> [String] -> Maybe [String]
lookupFilter (ElaboratedConfiguredPackage -> Map String [String]
elabProgramArgs ElaboratedConfiguredPackage
pkg) }
where
knownProgramDb :: ProgramDb
knownProgramDb = [Program] -> ProgramDb -> ProgramDb
addKnownPrograms [Program]
builtinPrograms ProgramDb
pkgConfigCompilerProgs
pkgDesc :: PackageDescription
pkgDesc :: PackageDescription
pkgDesc = ElaboratedConfiguredPackage -> PackageDescription
elabPkgDescription ElaboratedConfiguredPackage
pkg
removeEmpty :: [String] -> Maybe [String]
removeEmpty :: [String] -> Maybe [String]
removeEmpty [] = Maybe [String]
forall a. Maybe a
Nothing
removeEmpty [String]
xs = [String] -> Maybe [String]
forall a. a -> Maybe a
Just [String]
xs
lookupFilter :: String -> [String] -> Maybe [String]
lookupFilter :: String -> [String] -> Maybe [String]
lookupFilter String
n [String]
args = [String] -> Maybe [String]
removeEmpty ([String] -> Maybe [String]) -> [String] -> Maybe [String]
forall a b. (a -> b) -> a -> b
$ case String -> ProgramDb -> Maybe Program
lookupKnownProgram String
n ProgramDb
knownProgramDb of
Just Program
p -> Program
-> Maybe Version -> PackageDescription -> [String] -> [String]
programNormaliseArgs Program
p (Program -> Maybe Version
getVersion Program
p) PackageDescription
pkgDesc [String]
args
Maybe Program
Nothing -> [String]
args
getVersion :: Program -> Maybe Version
getVersion :: Program -> Maybe Version
getVersion Program
p = Program -> ProgramDb -> Maybe ConfiguredProgram
lookupProgram Program
p ProgramDb
knownProgramDb Maybe ConfiguredProgram
-> (ConfiguredProgram -> Maybe Version) -> Maybe Version
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ConfiguredProgram -> Maybe Version
programVersion
elabRequiresRegistration :: ElaboratedConfiguredPackage -> Bool
elabRequiresRegistration :: ElaboratedConfiguredPackage -> Bool
elabRequiresRegistration ElaboratedConfiguredPackage
elab =
case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabComponent ElaboratedComponent
comp ->
case ElaboratedComponent -> Maybe ComponentName
compComponentName ElaboratedComponent
comp of
Just ComponentName
cn -> ComponentName -> Bool
is_lib ComponentName
cn Bool -> Bool -> Bool
&& Bool
build_target
Maybe ComponentName
_ -> Bool
False
ElabPackage ElaboratedPackage
pkg ->
Bool
build_target Bool -> Bool -> Bool
|| (ElaboratedConfiguredPackage -> BuildStyle
elabBuildStyle ElaboratedConfiguredPackage
elab BuildStyle -> BuildStyle -> Bool
forall a. Eq a => a -> a -> Bool
== BuildStyle
BuildAndInstall Bool -> Bool -> Bool
&&
PackageDescription -> Bool
Cabal.hasPublicLib (ElaboratedConfiguredPackage -> PackageDescription
elabPkgDescription ElaboratedConfiguredPackage
elab))
Bool -> Bool -> Bool
|| (ComponentTarget -> Bool) -> [ComponentTarget] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (ElaboratedPackage -> ComponentTarget -> Bool
depends_on_lib ElaboratedPackage
pkg) (ElaboratedConfiguredPackage -> [ComponentTarget]
elabBuildTargets ElaboratedConfiguredPackage
elab)
where
depends_on_lib :: ElaboratedPackage -> ComponentTarget -> Bool
depends_on_lib ElaboratedPackage
pkg (ComponentTarget ComponentName
cn SubComponentTarget
_) =
Bool -> Bool
not ([()] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ((Component -> Bool) -> ComponentDeps [()] -> [()]
forall a. Monoid a => (Component -> Bool) -> ComponentDeps a -> a
CD.select (Component -> Component -> Bool
forall a. Eq a => a -> a -> Bool
== ComponentName -> Component
CD.componentNameToComponent ComponentName
cn)
(ElaboratedPackage -> ComponentDeps [()]
pkgDependsOnSelfLib ElaboratedPackage
pkg)))
build_target :: Bool
build_target =
if Bool -> Bool
not ([ComponentTarget] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (ElaboratedConfiguredPackage -> [ComponentTarget]
elabBuildTargets ElaboratedConfiguredPackage
elab))
then (ComponentTarget -> Bool) -> [ComponentTarget] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ComponentTarget -> Bool
is_lib_target (ElaboratedConfiguredPackage -> [ComponentTarget]
elabBuildTargets ElaboratedConfiguredPackage
elab)
else PackageDescription -> Bool
Cabal.hasLibs (ElaboratedConfiguredPackage -> PackageDescription
elabPkgDescription ElaboratedConfiguredPackage
elab)
is_lib_target :: ComponentTarget -> Bool
is_lib_target (ComponentTarget ComponentName
cn SubComponentTarget
WholeComponent) = ComponentName -> Bool
is_lib ComponentName
cn
is_lib_target ComponentTarget
_ = Bool
False
is_lib :: ComponentName -> Bool
is_lib (CLibName LibraryName
_) = Bool
True
is_lib ComponentName
_ = Bool
False
dataDirsEnvironmentForPlan :: DistDirLayout
-> ElaboratedInstallPlan
-> [(String, Maybe FilePath)]
dataDirsEnvironmentForPlan :: DistDirLayout -> ElaboratedInstallPlan -> [(String, Maybe String)]
dataDirsEnvironmentForPlan DistDirLayout
distDirLayout = [Maybe (String, Maybe String)] -> [(String, Maybe String)]
forall a. [Maybe a] -> [a]
catMaybes
([Maybe (String, Maybe String)] -> [(String, Maybe String)])
-> (ElaboratedInstallPlan -> [Maybe (String, Maybe String)])
-> ElaboratedInstallPlan
-> [(String, Maybe String)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ElaboratedPlanPackage -> Maybe (String, Maybe String))
-> [ElaboratedPlanPackage] -> [Maybe (String, Maybe String)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((InstalledPackageInfo -> Maybe (String, Maybe String))
-> (ElaboratedConfiguredPackage -> Maybe (String, Maybe String))
-> ElaboratedPlanPackage
-> Maybe (String, Maybe String)
forall ipkg a srcpkg.
(ipkg -> a) -> (srcpkg -> a) -> GenericPlanPackage ipkg srcpkg -> a
InstallPlan.foldPlanPackage
(Maybe (String, Maybe String)
-> InstalledPackageInfo -> Maybe (String, Maybe String)
forall a b. a -> b -> a
const Maybe (String, Maybe String)
forall a. Maybe a
Nothing)
(DistDirLayout
-> ElaboratedConfiguredPackage -> Maybe (String, Maybe String)
dataDirEnvVarForPackage DistDirLayout
distDirLayout))
([ElaboratedPlanPackage] -> [Maybe (String, Maybe String)])
-> (ElaboratedInstallPlan -> [ElaboratedPlanPackage])
-> ElaboratedInstallPlan
-> [Maybe (String, Maybe String)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ElaboratedInstallPlan -> [ElaboratedPlanPackage]
forall ipkg srcpkg.
GenericInstallPlan ipkg srcpkg -> [GenericPlanPackage ipkg srcpkg]
InstallPlan.toList
dataDirEnvVarForPackage :: DistDirLayout
-> ElaboratedConfiguredPackage
-> Maybe (String, Maybe FilePath)
dataDirEnvVarForPackage :: DistDirLayout
-> ElaboratedConfiguredPackage -> Maybe (String, Maybe String)
dataDirEnvVarForPackage DistDirLayout
distDirLayout ElaboratedConfiguredPackage
pkg =
case ElaboratedConfiguredPackage -> BuildStyle
elabBuildStyle ElaboratedConfiguredPackage
pkg
of BuildStyle
BuildAndInstall -> Maybe (String, Maybe String)
forall a. Maybe a
Nothing
BuildStyle
BuildInplaceOnly -> (String, Maybe String) -> Maybe (String, Maybe String)
forall a. a -> Maybe a
Just
( PackageDescription -> ShowS
pkgPathEnvVar (ElaboratedConfiguredPackage -> PackageDescription
elabPkgDescription ElaboratedConfiguredPackage
pkg) String
"datadir"
, String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ PackageLocation (Maybe String) -> String
srcPath (ElaboratedConfiguredPackage -> PackageLocation (Maybe String)
elabPkgSourceLocation ElaboratedConfiguredPackage
pkg)
String -> ShowS
</> PackageDescription -> String
dataDir (ElaboratedConfiguredPackage -> PackageDescription
elabPkgDescription ElaboratedConfiguredPackage
pkg))
where
srcPath :: PackageLocation (Maybe String) -> String
srcPath (LocalUnpackedPackage String
path) = String
path
srcPath (LocalTarballPackage String
_path) = String
unpackedPath
srcPath (RemoteTarballPackage URI
_uri Maybe String
_localTar) = String
unpackedPath
srcPath (RepoTarballPackage Repo
_repo PackageId
_packageId Maybe String
_localTar) = String
unpackedPath
srcPath (RemoteSourceRepoPackage SourceRepoMaybe
_sourceRepo (Just String
localCheckout)) = String
localCheckout
srcPath (RemoteSourceRepoPackage SourceRepoMaybe
_sourceRepo Maybe String
Nothing) = ShowS
forall a. HasCallStack => String -> a
error
String
"calling dataDirEnvVarForPackage on a not-downloaded repo is an error"
unpackedPath :: String
unpackedPath =
DistDirLayout -> PackageId -> String
distUnpackedSrcDirectory DistDirLayout
distDirLayout (PackageId -> String) -> PackageId -> String
forall a b. (a -> b) -> a -> b
$ ElaboratedConfiguredPackage -> PackageId
elabPkgSourceId ElaboratedConfiguredPackage
pkg
instance Package ElaboratedConfiguredPackage where
packageId :: ElaboratedConfiguredPackage -> PackageId
packageId = ElaboratedConfiguredPackage -> PackageId
elabPkgSourceId
instance HasConfiguredId ElaboratedConfiguredPackage where
configuredId :: ElaboratedConfiguredPackage -> ConfiguredId
configuredId ElaboratedConfiguredPackage
elab =
PackageId -> Maybe ComponentName -> ComponentId -> ConfiguredId
ConfiguredId (ElaboratedConfiguredPackage -> PackageId
forall pkg. Package pkg => pkg -> PackageId
packageId ElaboratedConfiguredPackage
elab) (ElaboratedConfiguredPackage -> Maybe ComponentName
elabComponentName ElaboratedConfiguredPackage
elab) (ElaboratedConfiguredPackage -> ComponentId
elabComponentId ElaboratedConfiguredPackage
elab)
instance HasUnitId ElaboratedConfiguredPackage where
installedUnitId :: ElaboratedConfiguredPackage -> UnitId
installedUnitId = ElaboratedConfiguredPackage -> UnitId
elabUnitId
instance IsNode ElaboratedConfiguredPackage where
type Key ElaboratedConfiguredPackage = UnitId
nodeKey :: ElaboratedConfiguredPackage -> Key ElaboratedConfiguredPackage
nodeKey = ElaboratedConfiguredPackage -> UnitId
ElaboratedConfiguredPackage -> Key ElaboratedConfiguredPackage
elabUnitId
nodeNeighbors :: ElaboratedConfiguredPackage -> [Key ElaboratedConfiguredPackage]
nodeNeighbors = ElaboratedConfiguredPackage -> [UnitId]
ElaboratedConfiguredPackage -> [Key ElaboratedConfiguredPackage]
elabOrderDependencies
instance Binary ElaboratedConfiguredPackage
instance Structured ElaboratedConfiguredPackage
data ElaboratedPackageOrComponent
= ElabPackage ElaboratedPackage
| ElabComponent ElaboratedComponent
deriving (ElaboratedPackageOrComponent
-> ElaboratedPackageOrComponent -> Bool
(ElaboratedPackageOrComponent
-> ElaboratedPackageOrComponent -> Bool)
-> (ElaboratedPackageOrComponent
-> ElaboratedPackageOrComponent -> Bool)
-> Eq ElaboratedPackageOrComponent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElaboratedPackageOrComponent
-> ElaboratedPackageOrComponent -> Bool
$c/= :: ElaboratedPackageOrComponent
-> ElaboratedPackageOrComponent -> Bool
== :: ElaboratedPackageOrComponent
-> ElaboratedPackageOrComponent -> Bool
$c== :: ElaboratedPackageOrComponent
-> ElaboratedPackageOrComponent -> Bool
Eq, Int -> ElaboratedPackageOrComponent -> ShowS
[ElaboratedPackageOrComponent] -> ShowS
ElaboratedPackageOrComponent -> String
(Int -> ElaboratedPackageOrComponent -> ShowS)
-> (ElaboratedPackageOrComponent -> String)
-> ([ElaboratedPackageOrComponent] -> ShowS)
-> Show ElaboratedPackageOrComponent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElaboratedPackageOrComponent] -> ShowS
$cshowList :: [ElaboratedPackageOrComponent] -> ShowS
show :: ElaboratedPackageOrComponent -> String
$cshow :: ElaboratedPackageOrComponent -> String
showsPrec :: Int -> ElaboratedPackageOrComponent -> ShowS
$cshowsPrec :: Int -> ElaboratedPackageOrComponent -> ShowS
Show, (forall x.
ElaboratedPackageOrComponent -> Rep ElaboratedPackageOrComponent x)
-> (forall x.
Rep ElaboratedPackageOrComponent x -> ElaboratedPackageOrComponent)
-> Generic ElaboratedPackageOrComponent
forall x.
Rep ElaboratedPackageOrComponent x -> ElaboratedPackageOrComponent
forall x.
ElaboratedPackageOrComponent -> Rep ElaboratedPackageOrComponent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ElaboratedPackageOrComponent x -> ElaboratedPackageOrComponent
$cfrom :: forall x.
ElaboratedPackageOrComponent -> Rep ElaboratedPackageOrComponent x
Generic)
instance Binary ElaboratedPackageOrComponent
instance Structured ElaboratedPackageOrComponent
elabComponentName :: ElaboratedConfiguredPackage -> Maybe ComponentName
elabComponentName :: ElaboratedConfiguredPackage -> Maybe ComponentName
elabComponentName ElaboratedConfiguredPackage
elab =
case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabPackage ElaboratedPackage
_ -> ComponentName -> Maybe ComponentName
forall a. a -> Maybe a
Just (ComponentName -> Maybe ComponentName)
-> ComponentName -> Maybe ComponentName
forall a b. (a -> b) -> a -> b
$ LibraryName -> ComponentName
CLibName LibraryName
LMainLibName
ElabComponent ElaboratedComponent
comp -> ElaboratedComponent -> Maybe ComponentName
compComponentName ElaboratedComponent
comp
elabConfiguredName :: Verbosity -> ElaboratedConfiguredPackage -> String
elabConfiguredName :: Verbosity -> ElaboratedConfiguredPackage -> String
elabConfiguredName Verbosity
verbosity ElaboratedConfiguredPackage
elab
| Verbosity
verbosity Verbosity -> Verbosity -> Bool
forall a. Ord a => a -> a -> Bool
<= Verbosity
normal
= (case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabPackage ElaboratedPackage
_ -> String
""
ElabComponent ElaboratedComponent
comp ->
case ElaboratedComponent -> Maybe ComponentName
compComponentName ElaboratedComponent
comp of
Maybe ComponentName
Nothing -> String
"setup from "
Just (CLibName LibraryName
LMainLibName) -> String
""
Just ComponentName
cname -> ComponentName -> String
forall a. Pretty a => a -> String
prettyShow ComponentName
cname String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" from ")
String -> ShowS
forall a. [a] -> [a] -> [a]
++ PackageId -> String
forall a. Pretty a => a -> String
prettyShow (ElaboratedConfiguredPackage -> PackageId
forall pkg. Package pkg => pkg -> PackageId
packageId ElaboratedConfiguredPackage
elab)
| Bool
otherwise
= UnitId -> String
forall a. Pretty a => a -> String
prettyShow (ElaboratedConfiguredPackage -> UnitId
elabUnitId ElaboratedConfiguredPackage
elab)
elabDistDirParams :: ElaboratedSharedConfig -> ElaboratedConfiguredPackage -> DistDirParams
elabDistDirParams :: ElaboratedSharedConfig
-> ElaboratedConfiguredPackage -> DistDirParams
elabDistDirParams ElaboratedSharedConfig
shared ElaboratedConfiguredPackage
elab = DistDirParams :: UnitId
-> PackageId
-> ComponentId
-> Maybe ComponentName
-> CompilerId
-> Platform
-> OptimisationLevel
-> DistDirParams
DistDirParams {
distParamUnitId :: UnitId
distParamUnitId = ElaboratedConfiguredPackage -> UnitId
forall pkg. HasUnitId pkg => pkg -> UnitId
installedUnitId ElaboratedConfiguredPackage
elab,
distParamComponentId :: ComponentId
distParamComponentId = ElaboratedConfiguredPackage -> ComponentId
elabComponentId ElaboratedConfiguredPackage
elab,
distParamPackageId :: PackageId
distParamPackageId = ElaboratedConfiguredPackage -> PackageId
elabPkgSourceId ElaboratedConfiguredPackage
elab,
distParamComponentName :: Maybe ComponentName
distParamComponentName = case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabComponent ElaboratedComponent
comp -> ElaboratedComponent -> Maybe ComponentName
compComponentName ElaboratedComponent
comp
ElabPackage ElaboratedPackage
_ -> Maybe ComponentName
forall a. Maybe a
Nothing,
distParamCompilerId :: CompilerId
distParamCompilerId = Compiler -> CompilerId
compilerId (ElaboratedSharedConfig -> Compiler
pkgConfigCompiler ElaboratedSharedConfig
shared),
distParamPlatform :: Platform
distParamPlatform = ElaboratedSharedConfig -> Platform
pkgConfigPlatform ElaboratedSharedConfig
shared,
distParamOptimization :: OptimisationLevel
distParamOptimization = ElaboratedConfiguredPackage -> OptimisationLevel
elabOptimization ElaboratedConfiguredPackage
elab
}
elabOrderDependencies :: ElaboratedConfiguredPackage -> [UnitId]
elabOrderDependencies :: ElaboratedConfiguredPackage -> [UnitId]
elabOrderDependencies ElaboratedConfiguredPackage
elab =
case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabPackage ElaboratedPackage
pkg -> [UnitId] -> [UnitId]
forall a. Ord a => [a] -> [a]
ordNub (ComponentDeps [UnitId] -> [UnitId]
forall a. Monoid a => ComponentDeps a -> a
CD.flatDeps (ElaboratedPackage -> ComponentDeps [UnitId]
pkgOrderDependencies ElaboratedPackage
pkg))
ElabComponent ElaboratedComponent
comp -> ElaboratedComponent -> [UnitId]
compOrderDependencies ElaboratedComponent
comp
elabOrderLibDependencies :: ElaboratedConfiguredPackage -> [UnitId]
elabOrderLibDependencies :: ElaboratedConfiguredPackage -> [UnitId]
elabOrderLibDependencies ElaboratedConfiguredPackage
elab =
case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabPackage ElaboratedPackage
pkg -> (ConfiguredId -> UnitId) -> [ConfiguredId] -> [UnitId]
forall a b. (a -> b) -> [a] -> [b]
map (ComponentId -> UnitId
newSimpleUnitId (ComponentId -> UnitId)
-> (ConfiguredId -> ComponentId) -> ConfiguredId -> UnitId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfiguredId -> ComponentId
confInstId) ([ConfiguredId] -> [UnitId]) -> [ConfiguredId] -> [UnitId]
forall a b. (a -> b) -> a -> b
$
[ConfiguredId] -> [ConfiguredId]
forall a. Ord a => [a] -> [a]
ordNub ([ConfiguredId] -> [ConfiguredId])
-> [ConfiguredId] -> [ConfiguredId]
forall a b. (a -> b) -> a -> b
$ ComponentDeps [ConfiguredId] -> [ConfiguredId]
forall a. Monoid a => ComponentDeps a -> a
CD.flatDeps (ElaboratedPackage -> ComponentDeps [ConfiguredId]
pkgLibDependencies ElaboratedPackage
pkg)
ElabComponent ElaboratedComponent
comp -> ElaboratedComponent -> [UnitId]
compOrderLibDependencies ElaboratedComponent
comp
elabLibDependencies :: ElaboratedConfiguredPackage -> [ConfiguredId]
elabLibDependencies :: ElaboratedConfiguredPackage -> [ConfiguredId]
elabLibDependencies ElaboratedConfiguredPackage
elab =
case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabPackage ElaboratedPackage
pkg -> [ConfiguredId] -> [ConfiguredId]
forall a. Ord a => [a] -> [a]
ordNub (ComponentDeps [ConfiguredId] -> [ConfiguredId]
forall a. Monoid a => ComponentDeps a -> a
CD.nonSetupDeps (ElaboratedPackage -> ComponentDeps [ConfiguredId]
pkgLibDependencies ElaboratedPackage
pkg))
ElabComponent ElaboratedComponent
comp -> ElaboratedComponent -> [ConfiguredId]
compLibDependencies ElaboratedComponent
comp
elabOrderExeDependencies :: ElaboratedConfiguredPackage -> [UnitId]
elabOrderExeDependencies :: ElaboratedConfiguredPackage -> [UnitId]
elabOrderExeDependencies =
(ComponentId -> UnitId) -> [ComponentId] -> [UnitId]
forall a b. (a -> b) -> [a] -> [b]
map ComponentId -> UnitId
newSimpleUnitId ([ComponentId] -> [UnitId])
-> (ElaboratedConfiguredPackage -> [ComponentId])
-> ElaboratedConfiguredPackage
-> [UnitId]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ElaboratedConfiguredPackage -> [ComponentId]
elabExeDependencies
elabExeDependencies :: ElaboratedConfiguredPackage -> [ComponentId]
elabExeDependencies :: ElaboratedConfiguredPackage -> [ComponentId]
elabExeDependencies ElaboratedConfiguredPackage
elab = (ConfiguredId -> ComponentId) -> [ConfiguredId] -> [ComponentId]
forall a b. (a -> b) -> [a] -> [b]
map ConfiguredId -> ComponentId
confInstId ([ConfiguredId] -> [ComponentId])
-> [ConfiguredId] -> [ComponentId]
forall a b. (a -> b) -> a -> b
$
case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabPackage ElaboratedPackage
pkg -> ComponentDeps [ConfiguredId] -> [ConfiguredId]
forall a. Monoid a => ComponentDeps a -> a
CD.nonSetupDeps (ElaboratedPackage -> ComponentDeps [ConfiguredId]
pkgExeDependencies ElaboratedPackage
pkg)
ElabComponent ElaboratedComponent
comp -> ElaboratedComponent -> [ConfiguredId]
compExeDependencies ElaboratedComponent
comp
elabExeDependencyPaths :: ElaboratedConfiguredPackage -> [FilePath]
elabExeDependencyPaths :: ElaboratedConfiguredPackage -> [String]
elabExeDependencyPaths ElaboratedConfiguredPackage
elab =
case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabPackage ElaboratedPackage
pkg -> ((ConfiguredId, String) -> String)
-> [(ConfiguredId, String)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (ConfiguredId, String) -> String
forall a b. (a, b) -> b
snd ([(ConfiguredId, String)] -> [String])
-> [(ConfiguredId, String)] -> [String]
forall a b. (a -> b) -> a -> b
$ ComponentDeps [(ConfiguredId, String)] -> [(ConfiguredId, String)]
forall a. Monoid a => ComponentDeps a -> a
CD.nonSetupDeps (ElaboratedPackage -> ComponentDeps [(ConfiguredId, String)]
pkgExeDependencyPaths ElaboratedPackage
pkg)
ElabComponent ElaboratedComponent
comp -> ((ConfiguredId, String) -> String)
-> [(ConfiguredId, String)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (ConfiguredId, String) -> String
forall a b. (a, b) -> b
snd (ElaboratedComponent -> [(ConfiguredId, String)]
compExeDependencyPaths ElaboratedComponent
comp)
elabSetupDependencies :: ElaboratedConfiguredPackage -> [ConfiguredId]
elabSetupDependencies :: ElaboratedConfiguredPackage -> [ConfiguredId]
elabSetupDependencies ElaboratedConfiguredPackage
elab =
case ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp ElaboratedConfiguredPackage
elab of
ElabPackage ElaboratedPackage
pkg -> ComponentDeps [ConfiguredId] -> [ConfiguredId]
forall a. Monoid a => ComponentDeps a -> a
CD.setupDeps (ElaboratedPackage -> ComponentDeps [ConfiguredId]
pkgLibDependencies ElaboratedPackage
pkg)
ElabComponent ElaboratedComponent
_ -> []
elabPkgConfigDependencies :: ElaboratedConfiguredPackage -> [(PkgconfigName, Maybe PkgconfigVersion)]
elabPkgConfigDependencies :: ElaboratedConfiguredPackage
-> [(PkgconfigName, Maybe PkgconfigVersion)]
elabPkgConfigDependencies ElaboratedConfiguredPackage { elabPkgOrComp :: ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp = ElabPackage ElaboratedPackage
pkg }
= ElaboratedPackage -> [(PkgconfigName, Maybe PkgconfigVersion)]
pkgPkgConfigDependencies ElaboratedPackage
pkg
elabPkgConfigDependencies ElaboratedConfiguredPackage { elabPkgOrComp :: ElaboratedConfiguredPackage -> ElaboratedPackageOrComponent
elabPkgOrComp = ElabComponent ElaboratedComponent
comp }
= ElaboratedComponent -> [(PkgconfigName, Maybe PkgconfigVersion)]
compPkgConfigDependencies ElaboratedComponent
comp
elabInplaceDependencyBuildCacheFiles
:: DistDirLayout
-> ElaboratedSharedConfig
-> ElaboratedInstallPlan
-> ElaboratedConfiguredPackage
-> [FilePath]
elabInplaceDependencyBuildCacheFiles :: DistDirLayout
-> ElaboratedSharedConfig
-> ElaboratedInstallPlan
-> ElaboratedConfiguredPackage
-> [String]
elabInplaceDependencyBuildCacheFiles DistDirLayout
layout ElaboratedSharedConfig
sconf ElaboratedInstallPlan
plan ElaboratedConfiguredPackage
root_elab =
ElaboratedPlanPackage -> [String]
go (ElaboratedPlanPackage -> [String])
-> [ElaboratedPlanPackage] -> [String]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ElaboratedInstallPlan -> UnitId -> [ElaboratedPlanPackage]
forall ipkg srcpkg.
GenericInstallPlan ipkg srcpkg
-> UnitId -> [GenericPlanPackage ipkg srcpkg]
InstallPlan.directDeps ElaboratedInstallPlan
plan (ElaboratedConfiguredPackage -> Key ElaboratedConfiguredPackage
forall a. IsNode a => a -> Key a
nodeKey ElaboratedConfiguredPackage
root_elab)
where
go :: ElaboratedPlanPackage -> [String]
go = (InstalledPackageInfo -> [String])
-> (ElaboratedConfiguredPackage -> [String])
-> ElaboratedPlanPackage
-> [String]
forall ipkg a srcpkg.
(ipkg -> a) -> (srcpkg -> a) -> GenericPlanPackage ipkg srcpkg -> a
InstallPlan.foldPlanPackage ([String] -> InstalledPackageInfo -> [String]
forall a b. a -> b -> a
const []) ((ElaboratedConfiguredPackage -> [String])
-> ElaboratedPlanPackage -> [String])
-> (ElaboratedConfiguredPackage -> [String])
-> ElaboratedPlanPackage
-> [String]
forall a b. (a -> b) -> a -> b
$ \ElaboratedConfiguredPackage
elab -> do
Bool -> [()]
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (ElaboratedConfiguredPackage -> BuildStyle
elabBuildStyle ElaboratedConfiguredPackage
elab BuildStyle -> BuildStyle -> Bool
forall a. Eq a => a -> a -> Bool
== BuildStyle
BuildInplaceOnly)
String -> [String]
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> [String]) -> String -> [String]
forall a b. (a -> b) -> a -> b
$ DistDirLayout -> DistDirParams -> ShowS
distPackageCacheFile DistDirLayout
layout (ElaboratedSharedConfig
-> ElaboratedConfiguredPackage -> DistDirParams
elabDistDirParams ElaboratedSharedConfig
sconf ElaboratedConfiguredPackage
elab) String
"build"
data ElaboratedComponent
= ElaboratedComponent {
ElaboratedComponent -> Component
compSolverName :: CD.Component,
ElaboratedComponent -> Maybe ComponentName
compComponentName :: Maybe ComponentName,
ElaboratedComponent -> [ConfiguredId]
compLibDependencies :: [ConfiguredId],
ElaboratedComponent -> [OpenUnitId]
compLinkedLibDependencies :: [OpenUnitId],
ElaboratedComponent -> [ConfiguredId]
compExeDependencies :: [ConfiguredId],
ElaboratedComponent -> [(PkgconfigName, Maybe PkgconfigVersion)]
compPkgConfigDependencies :: [(PkgconfigName, Maybe PkgconfigVersion)],
ElaboratedComponent -> [(ConfiguredId, String)]
compExeDependencyPaths :: [(ConfiguredId, FilePath)],
ElaboratedComponent -> [UnitId]
compOrderLibDependencies :: [UnitId]
}
deriving (ElaboratedComponent -> ElaboratedComponent -> Bool
(ElaboratedComponent -> ElaboratedComponent -> Bool)
-> (ElaboratedComponent -> ElaboratedComponent -> Bool)
-> Eq ElaboratedComponent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElaboratedComponent -> ElaboratedComponent -> Bool
$c/= :: ElaboratedComponent -> ElaboratedComponent -> Bool
== :: ElaboratedComponent -> ElaboratedComponent -> Bool
$c== :: ElaboratedComponent -> ElaboratedComponent -> Bool
Eq, Int -> ElaboratedComponent -> ShowS
[ElaboratedComponent] -> ShowS
ElaboratedComponent -> String
(Int -> ElaboratedComponent -> ShowS)
-> (ElaboratedComponent -> String)
-> ([ElaboratedComponent] -> ShowS)
-> Show ElaboratedComponent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElaboratedComponent] -> ShowS
$cshowList :: [ElaboratedComponent] -> ShowS
show :: ElaboratedComponent -> String
$cshow :: ElaboratedComponent -> String
showsPrec :: Int -> ElaboratedComponent -> ShowS
$cshowsPrec :: Int -> ElaboratedComponent -> ShowS
Show, (forall x. ElaboratedComponent -> Rep ElaboratedComponent x)
-> (forall x. Rep ElaboratedComponent x -> ElaboratedComponent)
-> Generic ElaboratedComponent
forall x. Rep ElaboratedComponent x -> ElaboratedComponent
forall x. ElaboratedComponent -> Rep ElaboratedComponent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ElaboratedComponent x -> ElaboratedComponent
$cfrom :: forall x. ElaboratedComponent -> Rep ElaboratedComponent x
Generic)
instance Binary ElaboratedComponent
instance Structured ElaboratedComponent
compOrderDependencies :: ElaboratedComponent -> [UnitId]
compOrderDependencies :: ElaboratedComponent -> [UnitId]
compOrderDependencies ElaboratedComponent
comp =
ElaboratedComponent -> [UnitId]
compOrderLibDependencies ElaboratedComponent
comp
[UnitId] -> [UnitId] -> [UnitId]
forall a. [a] -> [a] -> [a]
++ ElaboratedComponent -> [UnitId]
compOrderExeDependencies ElaboratedComponent
comp
compOrderExeDependencies :: ElaboratedComponent -> [UnitId]
compOrderExeDependencies :: ElaboratedComponent -> [UnitId]
compOrderExeDependencies = (ConfiguredId -> UnitId) -> [ConfiguredId] -> [UnitId]
forall a b. (a -> b) -> [a] -> [b]
map (ComponentId -> UnitId
newSimpleUnitId (ComponentId -> UnitId)
-> (ConfiguredId -> ComponentId) -> ConfiguredId -> UnitId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfiguredId -> ComponentId
confInstId) ([ConfiguredId] -> [UnitId])
-> (ElaboratedComponent -> [ConfiguredId])
-> ElaboratedComponent
-> [UnitId]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ElaboratedComponent -> [ConfiguredId]
compExeDependencies
data ElaboratedPackage
= ElaboratedPackage {
ElaboratedPackage -> ComponentId
pkgInstalledId :: InstalledPackageId,
ElaboratedPackage -> ComponentDeps [ConfiguredId]
pkgLibDependencies :: ComponentDeps [ConfiguredId],
ElaboratedPackage -> ComponentDeps [()]
pkgDependsOnSelfLib :: ComponentDeps [()],
ElaboratedPackage -> ComponentDeps [ConfiguredId]
pkgExeDependencies :: ComponentDeps [ConfiguredId],
ElaboratedPackage -> ComponentDeps [(ConfiguredId, String)]
pkgExeDependencyPaths :: ComponentDeps [(ConfiguredId, FilePath)],
ElaboratedPackage -> [(PkgconfigName, Maybe PkgconfigVersion)]
pkgPkgConfigDependencies :: [(PkgconfigName, Maybe PkgconfigVersion)],
ElaboratedPackage -> OptionalStanzaSet
pkgStanzasEnabled :: OptionalStanzaSet
}
deriving (ElaboratedPackage -> ElaboratedPackage -> Bool
(ElaboratedPackage -> ElaboratedPackage -> Bool)
-> (ElaboratedPackage -> ElaboratedPackage -> Bool)
-> Eq ElaboratedPackage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElaboratedPackage -> ElaboratedPackage -> Bool
$c/= :: ElaboratedPackage -> ElaboratedPackage -> Bool
== :: ElaboratedPackage -> ElaboratedPackage -> Bool
$c== :: ElaboratedPackage -> ElaboratedPackage -> Bool
Eq, Int -> ElaboratedPackage -> ShowS
[ElaboratedPackage] -> ShowS
ElaboratedPackage -> String
(Int -> ElaboratedPackage -> ShowS)
-> (ElaboratedPackage -> String)
-> ([ElaboratedPackage] -> ShowS)
-> Show ElaboratedPackage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElaboratedPackage] -> ShowS
$cshowList :: [ElaboratedPackage] -> ShowS
show :: ElaboratedPackage -> String
$cshow :: ElaboratedPackage -> String
showsPrec :: Int -> ElaboratedPackage -> ShowS
$cshowsPrec :: Int -> ElaboratedPackage -> ShowS
Show, (forall x. ElaboratedPackage -> Rep ElaboratedPackage x)
-> (forall x. Rep ElaboratedPackage x -> ElaboratedPackage)
-> Generic ElaboratedPackage
forall x. Rep ElaboratedPackage x -> ElaboratedPackage
forall x. ElaboratedPackage -> Rep ElaboratedPackage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ElaboratedPackage x -> ElaboratedPackage
$cfrom :: forall x. ElaboratedPackage -> Rep ElaboratedPackage x
Generic)
instance Binary ElaboratedPackage
instance Structured ElaboratedPackage
pkgOrderDependencies :: ElaboratedPackage -> ComponentDeps [UnitId]
pkgOrderDependencies :: ElaboratedPackage -> ComponentDeps [UnitId]
pkgOrderDependencies ElaboratedPackage
pkg =
([ConfiguredId] -> [UnitId])
-> ComponentDeps [ConfiguredId] -> ComponentDeps [UnitId]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((ConfiguredId -> UnitId) -> [ConfiguredId] -> [UnitId]
forall a b. (a -> b) -> [a] -> [b]
map (ComponentId -> UnitId
newSimpleUnitId (ComponentId -> UnitId)
-> (ConfiguredId -> ComponentId) -> ConfiguredId -> UnitId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfiguredId -> ComponentId
confInstId)) (ElaboratedPackage -> ComponentDeps [ConfiguredId]
pkgLibDependencies ElaboratedPackage
pkg) ComponentDeps [UnitId]
-> ComponentDeps [UnitId] -> ComponentDeps [UnitId]
forall a. Monoid a => a -> a -> a
`Mon.mappend`
([ConfiguredId] -> [UnitId])
-> ComponentDeps [ConfiguredId] -> ComponentDeps [UnitId]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((ConfiguredId -> UnitId) -> [ConfiguredId] -> [UnitId]
forall a b. (a -> b) -> [a] -> [b]
map (ComponentId -> UnitId
newSimpleUnitId (ComponentId -> UnitId)
-> (ConfiguredId -> ComponentId) -> ConfiguredId -> UnitId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConfiguredId -> ComponentId
confInstId)) (ElaboratedPackage -> ComponentDeps [ConfiguredId]
pkgExeDependencies ElaboratedPackage
pkg)
data BuildStyle =
BuildAndInstall
| BuildInplaceOnly
deriving (BuildStyle -> BuildStyle -> Bool
(BuildStyle -> BuildStyle -> Bool)
-> (BuildStyle -> BuildStyle -> Bool) -> Eq BuildStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuildStyle -> BuildStyle -> Bool
$c/= :: BuildStyle -> BuildStyle -> Bool
== :: BuildStyle -> BuildStyle -> Bool
$c== :: BuildStyle -> BuildStyle -> Bool
Eq, Int -> BuildStyle -> ShowS
[BuildStyle] -> ShowS
BuildStyle -> String
(Int -> BuildStyle -> ShowS)
-> (BuildStyle -> String)
-> ([BuildStyle] -> ShowS)
-> Show BuildStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuildStyle] -> ShowS
$cshowList :: [BuildStyle] -> ShowS
show :: BuildStyle -> String
$cshow :: BuildStyle -> String
showsPrec :: Int -> BuildStyle -> ShowS
$cshowsPrec :: Int -> BuildStyle -> ShowS
Show, (forall x. BuildStyle -> Rep BuildStyle x)
-> (forall x. Rep BuildStyle x -> BuildStyle) -> Generic BuildStyle
forall x. Rep BuildStyle x -> BuildStyle
forall x. BuildStyle -> Rep BuildStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BuildStyle x -> BuildStyle
$cfrom :: forall x. BuildStyle -> Rep BuildStyle x
Generic)
instance Binary BuildStyle
instance Structured BuildStyle
instance Semigroup BuildStyle where
BuildStyle
BuildInplaceOnly <> :: BuildStyle -> BuildStyle -> BuildStyle
<> BuildStyle
_ = BuildStyle
BuildInplaceOnly
BuildStyle
_ <> BuildStyle
BuildInplaceOnly = BuildStyle
BuildInplaceOnly
BuildStyle
_ <> BuildStyle
_ = BuildStyle
BuildAndInstall
instance Monoid BuildStyle where
mempty :: BuildStyle
mempty = BuildStyle
BuildAndInstall
mappend :: BuildStyle -> BuildStyle -> BuildStyle
mappend = BuildStyle -> BuildStyle -> BuildStyle
forall a. Semigroup a => a -> a -> a
(<>)
type CabalFileText = LBS.ByteString
type ElaboratedReadyPackage = GenericReadyPackage ElaboratedConfiguredPackage
data ComponentTarget = ComponentTarget ComponentName SubComponentTarget
deriving (ComponentTarget -> ComponentTarget -> Bool
(ComponentTarget -> ComponentTarget -> Bool)
-> (ComponentTarget -> ComponentTarget -> Bool)
-> Eq ComponentTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComponentTarget -> ComponentTarget -> Bool
$c/= :: ComponentTarget -> ComponentTarget -> Bool
== :: ComponentTarget -> ComponentTarget -> Bool
$c== :: ComponentTarget -> ComponentTarget -> Bool
Eq, Eq ComponentTarget
Eq ComponentTarget
-> (ComponentTarget -> ComponentTarget -> Ordering)
-> (ComponentTarget -> ComponentTarget -> Bool)
-> (ComponentTarget -> ComponentTarget -> Bool)
-> (ComponentTarget -> ComponentTarget -> Bool)
-> (ComponentTarget -> ComponentTarget -> Bool)
-> (ComponentTarget -> ComponentTarget -> ComponentTarget)
-> (ComponentTarget -> ComponentTarget -> ComponentTarget)
-> Ord ComponentTarget
ComponentTarget -> ComponentTarget -> Bool
ComponentTarget -> ComponentTarget -> Ordering
ComponentTarget -> ComponentTarget -> ComponentTarget
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ComponentTarget -> ComponentTarget -> ComponentTarget
$cmin :: ComponentTarget -> ComponentTarget -> ComponentTarget
max :: ComponentTarget -> ComponentTarget -> ComponentTarget
$cmax :: ComponentTarget -> ComponentTarget -> ComponentTarget
>= :: ComponentTarget -> ComponentTarget -> Bool
$c>= :: ComponentTarget -> ComponentTarget -> Bool
> :: ComponentTarget -> ComponentTarget -> Bool
$c> :: ComponentTarget -> ComponentTarget -> Bool
<= :: ComponentTarget -> ComponentTarget -> Bool
$c<= :: ComponentTarget -> ComponentTarget -> Bool
< :: ComponentTarget -> ComponentTarget -> Bool
$c< :: ComponentTarget -> ComponentTarget -> Bool
compare :: ComponentTarget -> ComponentTarget -> Ordering
$ccompare :: ComponentTarget -> ComponentTarget -> Ordering
$cp1Ord :: Eq ComponentTarget
Ord, Int -> ComponentTarget -> ShowS
[ComponentTarget] -> ShowS
ComponentTarget -> String
(Int -> ComponentTarget -> ShowS)
-> (ComponentTarget -> String)
-> ([ComponentTarget] -> ShowS)
-> Show ComponentTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComponentTarget] -> ShowS
$cshowList :: [ComponentTarget] -> ShowS
show :: ComponentTarget -> String
$cshow :: ComponentTarget -> String
showsPrec :: Int -> ComponentTarget -> ShowS
$cshowsPrec :: Int -> ComponentTarget -> ShowS
Show, (forall x. ComponentTarget -> Rep ComponentTarget x)
-> (forall x. Rep ComponentTarget x -> ComponentTarget)
-> Generic ComponentTarget
forall x. Rep ComponentTarget x -> ComponentTarget
forall x. ComponentTarget -> Rep ComponentTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComponentTarget x -> ComponentTarget
$cfrom :: forall x. ComponentTarget -> Rep ComponentTarget x
Generic)
instance Binary ComponentTarget
instance Structured ComponentTarget
showComponentTarget :: PackageId -> ComponentTarget -> String
showComponentTarget :: PackageId -> ComponentTarget -> String
showComponentTarget PackageId
pkgid =
PackageId -> BuildTarget -> String
Cabal.showBuildTarget PackageId
pkgid (BuildTarget -> String)
-> (ComponentTarget -> BuildTarget) -> ComponentTarget -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ComponentTarget -> BuildTarget
toBuildTarget
where
toBuildTarget :: ComponentTarget -> Cabal.BuildTarget
toBuildTarget :: ComponentTarget -> BuildTarget
toBuildTarget (ComponentTarget ComponentName
cname SubComponentTarget
subtarget) =
case SubComponentTarget
subtarget of
SubComponentTarget
WholeComponent -> ComponentName -> BuildTarget
Cabal.BuildTargetComponent ComponentName
cname
ModuleTarget ModuleName
mname -> ComponentName -> ModuleName -> BuildTarget
Cabal.BuildTargetModule ComponentName
cname ModuleName
mname
FileTarget String
fname -> ComponentName -> String -> BuildTarget
Cabal.BuildTargetFile ComponentName
cname String
fname
showTestComponentTarget :: PackageId -> ComponentTarget -> Maybe String
showTestComponentTarget :: PackageId -> ComponentTarget -> Maybe String
showTestComponentTarget PackageId
_ (ComponentTarget (CTestName UnqualComponentName
n) SubComponentTarget
_) = String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow UnqualComponentName
n
showTestComponentTarget PackageId
_ ComponentTarget
_ = Maybe String
forall a. Maybe a
Nothing
isTestComponentTarget :: ComponentTarget -> Bool
isTestComponentTarget :: ComponentTarget -> Bool
isTestComponentTarget (ComponentTarget (CTestName UnqualComponentName
_) SubComponentTarget
_) = Bool
True
isTestComponentTarget ComponentTarget
_ = Bool
False
showBenchComponentTarget :: PackageId -> ComponentTarget -> Maybe String
showBenchComponentTarget :: PackageId -> ComponentTarget -> Maybe String
showBenchComponentTarget PackageId
_ (ComponentTarget (CBenchName UnqualComponentName
n) SubComponentTarget
_) = String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow UnqualComponentName
n
showBenchComponentTarget PackageId
_ ComponentTarget
_ = Maybe String
forall a. Maybe a
Nothing
isBenchComponentTarget :: ComponentTarget -> Bool
isBenchComponentTarget :: ComponentTarget -> Bool
isBenchComponentTarget (ComponentTarget (CBenchName UnqualComponentName
_) SubComponentTarget
_) = Bool
True
isBenchComponentTarget ComponentTarget
_ = Bool
False
isForeignLibComponentTarget :: ComponentTarget -> Bool
isForeignLibComponentTarget :: ComponentTarget -> Bool
isForeignLibComponentTarget (ComponentTarget (CFLibName UnqualComponentName
_) SubComponentTarget
_) = Bool
True
isForeignLibComponentTarget ComponentTarget
_ = Bool
False
isExeComponentTarget :: ComponentTarget -> Bool
isExeComponentTarget :: ComponentTarget -> Bool
isExeComponentTarget (ComponentTarget (CExeName UnqualComponentName
_) SubComponentTarget
_ ) = Bool
True
isExeComponentTarget ComponentTarget
_ = Bool
False
isSubLibComponentTarget :: ComponentTarget -> Bool
isSubLibComponentTarget :: ComponentTarget -> Bool
isSubLibComponentTarget (ComponentTarget (CLibName (LSubLibName UnqualComponentName
_)) SubComponentTarget
_) = Bool
True
isSubLibComponentTarget ComponentTarget
_ = Bool
False
componentOptionalStanza :: CD.Component -> Maybe OptionalStanza
componentOptionalStanza :: Component -> Maybe OptionalStanza
componentOptionalStanza (CD.ComponentTest UnqualComponentName
_) = OptionalStanza -> Maybe OptionalStanza
forall a. a -> Maybe a
Just OptionalStanza
TestStanzas
componentOptionalStanza (CD.ComponentBench UnqualComponentName
_) = OptionalStanza -> Maybe OptionalStanza
forall a. a -> Maybe a
Just OptionalStanza
BenchStanzas
componentOptionalStanza Component
_ = Maybe OptionalStanza
forall a. Maybe a
Nothing
data SetupScriptStyle = SetupCustomExplicitDeps
| SetupCustomImplicitDeps
| SetupNonCustomExternalLib
| SetupNonCustomInternalLib
deriving (SetupScriptStyle -> SetupScriptStyle -> Bool
(SetupScriptStyle -> SetupScriptStyle -> Bool)
-> (SetupScriptStyle -> SetupScriptStyle -> Bool)
-> Eq SetupScriptStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetupScriptStyle -> SetupScriptStyle -> Bool
$c/= :: SetupScriptStyle -> SetupScriptStyle -> Bool
== :: SetupScriptStyle -> SetupScriptStyle -> Bool
$c== :: SetupScriptStyle -> SetupScriptStyle -> Bool
Eq, Int -> SetupScriptStyle -> ShowS
[SetupScriptStyle] -> ShowS
SetupScriptStyle -> String
(Int -> SetupScriptStyle -> ShowS)
-> (SetupScriptStyle -> String)
-> ([SetupScriptStyle] -> ShowS)
-> Show SetupScriptStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetupScriptStyle] -> ShowS
$cshowList :: [SetupScriptStyle] -> ShowS
show :: SetupScriptStyle -> String
$cshow :: SetupScriptStyle -> String
showsPrec :: Int -> SetupScriptStyle -> ShowS
$cshowsPrec :: Int -> SetupScriptStyle -> ShowS
Show, (forall x. SetupScriptStyle -> Rep SetupScriptStyle x)
-> (forall x. Rep SetupScriptStyle x -> SetupScriptStyle)
-> Generic SetupScriptStyle
forall x. Rep SetupScriptStyle x -> SetupScriptStyle
forall x. SetupScriptStyle -> Rep SetupScriptStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetupScriptStyle x -> SetupScriptStyle
$cfrom :: forall x. SetupScriptStyle -> Rep SetupScriptStyle x
Generic, Typeable)
instance Binary SetupScriptStyle
instance Structured SetupScriptStyle