Commit 313edf53 authored by Edward Z. Yang's avatar Edward Z. Yang Committed by GitHub
Browse files

Merge pull request #3542 from ezyang/enabled-refactor

Introduce new ComponentEnabledSpec, removing testEnabled/benchmarkEna…
parents 44b7e283 193f49da
......@@ -64,7 +64,6 @@ module Distribution.PackageDescription (
hasTests,
withTest,
testModules,
enabledTests,
-- * Benchmarks
Benchmark(..),
......@@ -76,7 +75,6 @@ module Distribution.PackageDescription (
hasBenchmarks,
withBenchmark,
benchmarkModules,
enabledBenchmarks,
-- * Build information
BuildInfo(..),
......@@ -176,7 +174,7 @@ data PackageDescription
-- PackageDescription we are, the contents of this field are
-- either nonsense, or the collected dependencies of *all* the
-- components in this package. buildDepends is initialized by
-- 'finalizePackageDescription' and 'flattenPackageDescription';
-- 'finalizePD' and 'flattenPackageDescription';
-- prior to that, dependency info is stored in the 'CondTree'
-- built around a 'GenericPackageDescription'. When this
-- resolution is done, dependency info is written to the inner
......@@ -447,8 +445,12 @@ hasPublicLib p = any f (libraries p)
hasLibs :: PackageDescription -> Bool
hasLibs p = any (buildable . libBuildInfo) (libraries p)
-- |If the package description has a library section, call the given
-- function with the library build info as argument.
-- | If the package description has a buildable library section,
-- call the given function with the library build info as argument.
-- You probably want 'withLibLBI' if you have a 'LocalBuildInfo',
-- see the note in
-- "Distribution.Simple.LocalBuildInfo#buildable_vs_enabled_components"
-- for more information.
withLib :: PackageDescription -> (Library -> IO ()) -> IO ()
withLib pkg_descr f =
sequence_ [f lib | lib <- libraries pkg_descr, buildable (libBuildInfo lib)]
......@@ -532,7 +534,10 @@ hasExes :: PackageDescription -> Bool
hasExes p = any (buildable . buildInfo) (executables p)
-- | Perform the action on each buildable 'Executable' in the package
-- description.
-- description. You probably want 'withExeLBI' if you have a
-- 'LocalBuildInfo', see the note in
-- "Distribution.Simple.LocalBuildInfo#buildable_vs_enabled_components"
-- for more information.
withExe :: PackageDescription -> (Executable -> IO ()) -> IO ()
withExe pkg_descr f =
sequence_ [f exe | exe <- executables pkg_descr, buildable (buildInfo exe)]
......@@ -549,13 +554,7 @@ exeModules exe = otherModules (buildInfo exe)
data TestSuite = TestSuite {
testName :: String,
testInterface :: TestSuiteInterface,
testBuildInfo :: BuildInfo,
testEnabled :: Bool
-- TODO: By having a 'testEnabled' field in the PackageDescription, we
-- are mixing build status information (i.e., arguments to 'configure')
-- with static package description information. This is undesirable, but
-- a better solution is waiting on the next overhaul to the
-- GenericPackageDescription -> PackageDescription resolution process.
testBuildInfo :: BuildInfo
}
deriving (Generic, Show, Read, Eq, Typeable, Data)
......@@ -593,8 +592,7 @@ instance Monoid TestSuite where
mempty = TestSuite {
testName = mempty,
testInterface = mempty,
testBuildInfo = mempty,
testEnabled = False
testBuildInfo = mempty
}
mappend = (Semi.<>)
......@@ -602,8 +600,7 @@ instance Semigroup TestSuite where
a <> b = TestSuite {
testName = combine' testName,
testInterface = combine testInterface,
testBuildInfo = combine testBuildInfo,
testEnabled = testEnabled a || testEnabled b
testBuildInfo = combine testBuildInfo
}
where combine field = field a `mappend` field b
combine' f = case (f a, f b) of
......@@ -627,14 +624,14 @@ emptyTestSuite = mempty
hasTests :: PackageDescription -> Bool
hasTests = any (buildable . testBuildInfo) . testSuites
-- | Get all the enabled test suites from a package.
enabledTests :: PackageDescription -> [TestSuite]
enabledTests = filter testEnabled . testSuites
-- | Perform an action on each buildable 'TestSuite' in a package.
-- You probably want 'withTestLBI' if you have a 'LocalBuildInfo', see the note in
-- "Distribution.Simple.LocalBuildInfo#buildable_vs_enabled_components"
-- for more information.
withTest :: PackageDescription -> (TestSuite -> IO ()) -> IO ()
withTest pkg_descr f =
mapM_ f $ filter (buildable . testBuildInfo) $ enabledTests pkg_descr
sequence_ [ f test | test <- testSuites pkg_descr, buildable (testBuildInfo test) ]
-- | Get all the module names from a test suite.
testModules :: TestSuite -> [ModuleName]
......@@ -695,9 +692,7 @@ testType test = case testInterface test of
data Benchmark = Benchmark {
benchmarkName :: String,
benchmarkInterface :: BenchmarkInterface,
benchmarkBuildInfo :: BuildInfo,
benchmarkEnabled :: Bool
-- TODO: See TODO for 'testEnabled'.
benchmarkBuildInfo :: BuildInfo
}
deriving (Generic, Show, Read, Eq, Typeable, Data)
......@@ -731,8 +726,7 @@ instance Monoid Benchmark where
mempty = Benchmark {
benchmarkName = mempty,
benchmarkInterface = mempty,
benchmarkBuildInfo = mempty,
benchmarkEnabled = False
benchmarkBuildInfo = mempty
}
mappend = (Semi.<>)
......@@ -740,8 +734,7 @@ instance Semigroup Benchmark where
a <> b = Benchmark {
benchmarkName = combine' benchmarkName,
benchmarkInterface = combine benchmarkInterface,
benchmarkBuildInfo = combine benchmarkBuildInfo,
benchmarkEnabled = benchmarkEnabled a || benchmarkEnabled b
benchmarkBuildInfo = combine benchmarkBuildInfo
}
where combine field = field a `mappend` field b
combine' f = case (f a, f b) of
......@@ -765,14 +758,14 @@ emptyBenchmark = mempty
hasBenchmarks :: PackageDescription -> Bool
hasBenchmarks = any (buildable . benchmarkBuildInfo) . benchmarks
-- | Get all the enabled benchmarks from a package.
enabledBenchmarks :: PackageDescription -> [Benchmark]
enabledBenchmarks = filter benchmarkEnabled . benchmarks
-- | Perform an action on each buildable 'Benchmark' in a package.
-- You probably want 'withBenchLBI' if you have a 'LocalBuildInfo', see the note in
-- "Distribution.Simple.LocalBuildInfo#buildable_vs_enabled_components"
-- for more information.
withBenchmark :: PackageDescription -> (Benchmark -> IO ()) -> IO ()
withBenchmark pkg_descr f =
mapM_ f $ filter (buildable . benchmarkBuildInfo) $ enabledBenchmarks pkg_descr
sequence_ [f bench | bench <- benchmarks pkg_descr, buildable (benchmarkBuildInfo bench)]
-- | Get all the module names from a benchmark.
benchmarkModules :: Benchmark -> [ModuleName]
......@@ -935,12 +928,10 @@ allBuildInfo pkg_descr = [ bi | lib <- libraries pkg_descr
, buildable bi ]
++ [ bi | tst <- testSuites pkg_descr
, let bi = testBuildInfo tst
, buildable bi
, testEnabled tst ]
, buildable bi ]
++ [ bi | tst <- benchmarks pkg_descr
, let bi = benchmarkBuildInfo tst
, buildable bi
, benchmarkEnabled tst ]
, buildable bi ]
--FIXME: many of the places where this is used, we actually want to look at
-- unbuildable bits too, probably need separate functions
......
......@@ -43,6 +43,7 @@ import Distribution.Simple.Utils hiding (findPackageDesc, notice)
import Distribution.Version
import Distribution.Package
import Distribution.Text
import Distribution.Simple.LocalBuildInfo hiding (compiler)
import Language.Haskell.Extension
import Data.Maybe
......@@ -1282,8 +1283,8 @@ checkPackageVersions pkg =
-- pick a single "typical" configuration and check if that has an
-- open upper bound. To get a typical configuration we finalise
-- using no package index and the current platform.
finalised = finalizePackageDescription
[] (const True) buildPlatform
finalised = finalizePD
[] defaultComponentEnabled (const True) buildPlatform
(unknownCompilerInfo
(CompilerId buildCompilerFlavor (Version [] [])) NoAbiTag)
[] pkg
......@@ -1294,7 +1295,7 @@ checkPackageVersions pkg =
baseDeps =
[ vr | Dependency (PackageName "base") vr <- buildDepends pkg' ]
-- Just in case finalizePackageDescription fails for any reason,
-- Just in case finalizePD fails for any reason,
-- or if the package doesn't depend on the base package at all,
-- then we will just skip the check, since boundedAbove noVersion = True
_ -> noVersion
......
......@@ -11,12 +11,13 @@
-- Portability : portable
--
-- This is about the cabal configurations feature. It exports
-- 'finalizePackageDescription' and 'flattenPackageDescription' which are
-- 'finalizePD' and 'flattenPackageDescription' which are
-- functions for converting 'GenericPackageDescription's down to
-- 'PackageDescription's. It has code for working with the tree of conditions
-- and resolving or flattening conditions.
module Distribution.PackageDescription.Configuration (
finalizePD,
finalizePackageDescription,
flattenPackageDescription,
......@@ -48,6 +49,7 @@ import Distribution.Text
import Distribution.Compat.ReadP as ReadP hiding ( char )
import qualified Distribution.Compat.ReadP as ReadP ( char )
import Distribution.Compat.Semigroup as Semi
import Distribution.Simple.LocalBuildInfo
import Control.Arrow (first)
import Data.Char ( isAlphaNum )
......@@ -211,6 +213,7 @@ instance Semigroup d => Semigroup (DepTestRslt d) where
resolveWithFlags ::
[(FlagName,[Bool])]
-- ^ Domain for each flag name, will be tested in order.
-> ComponentEnabledSpec
-> OS -- ^ OS as returned by Distribution.System.buildOS
-> Arch -- ^ Arch as returned by Distribution.System.buildArch
-> CompilerInfo -- ^ Compiler information
......@@ -220,7 +223,7 @@ resolveWithFlags ::
-> Either [Dependency] (TargetSet PDTagged, FlagAssignment)
-- ^ Either the missing dependencies (error case), or a pair of
-- (set of build targets with dependencies, chosen flag assignments)
resolveWithFlags dom os arch impl constrs trees checkDeps =
resolveWithFlags dom enabled os arch impl constrs trees checkDeps =
either (Left . fromDepMapUnion) Right $ explore (build [] dom)
where
extraConstrs = toDepMap constrs
......@@ -245,7 +248,7 @@ resolveWithFlags dom os arch impl constrs trees checkDeps =
-- apply additional constraints to all dependencies
first (`constrainBy` extraConstrs) .
simplifyCondTree (env flags)
deps = overallDependencies targetSet
deps = overallDependencies enabled targetSet
in case checkDeps (fromDepMap deps) of
DepOk | null ts -> Right (targetSet, flags)
| otherwise -> tryAll $ map explore ts
......@@ -416,15 +419,15 @@ newtype TargetSet a = TargetSet [(DependencyMap, a)]
-- | Combine the target-specific dependencies in a TargetSet to give the
-- dependencies for the package as a whole.
overallDependencies :: TargetSet PDTagged -> DependencyMap
overallDependencies (TargetSet targets) = mconcat depss
overallDependencies :: ComponentEnabledSpec -> TargetSet PDTagged -> DependencyMap
overallDependencies enabled (TargetSet targets) = mconcat depss
where
(depss, _) = unzip $ filter (removeDisabledSections . snd) targets
removeDisabledSections :: PDTagged -> Bool
removeDisabledSections (Lib _ l) = buildable (libBuildInfo l)
removeDisabledSections (Exe _ e) = buildable (buildInfo e)
removeDisabledSections (Test _ t) = testEnabled t && buildable (testBuildInfo t)
removeDisabledSections (Bench _ b) = benchmarkEnabled b && buildable (benchmarkBuildInfo b)
removeDisabledSections (Lib _ l) = componentEnabled enabled (CLib l)
removeDisabledSections (Exe _ e) = componentEnabled enabled (CExe e)
removeDisabledSections (Test _ t) = componentEnabled enabled (CTest t)
removeDisabledSections (Bench _ b) = componentEnabled enabled (CBench b)
removeDisabledSections PDNull = True
-- Apply extra constraints to a dependency map.
......@@ -505,6 +508,10 @@ flattenTaggedTargets (TargetSet targets) = foldr untag ([], [], [], []) targets
-- Convert GenericPackageDescription to PackageDescription
--
-- ezyang: Arguably, this should be:
-- data PDTagged = PDComp String Component
-- | PDNull
-- Also, what the heck is the String? The componentName?
data PDTagged = Lib String Library
| Exe String Executable
| Test String TestSuite
......@@ -547,8 +554,9 @@ instance Semigroup PDTagged where
-- On success, it will return the package description and the full flag
-- assignment chosen.
--
finalizePackageDescription ::
finalizePD ::
FlagAssignment -- ^ Explicitly specified flag assignments
-> ComponentEnabledSpec
-> (Dependency -> Bool) -- ^ Is a given dependency satisfiable from the set of
-- available packages? If this is unknown then use
-- True.
......@@ -560,7 +568,7 @@ finalizePackageDescription ::
(PackageDescription, FlagAssignment)
-- ^ Either missing dependencies or the resolved package
-- description along with the flag assignments chosen.
finalizePackageDescription userflags satisfyDep
finalizePD userflags enabled satisfyDep
(Platform arch os) impl constraints
(GenericPackageDescription pkg flags libs0 exes0 tests0 bms0) =
case resolveFlags of
......@@ -569,7 +577,7 @@ finalizePackageDescription userflags satisfyDep
, executables = exes'
, testSuites = tests'
, benchmarks = bms'
, buildDepends = fromDepMap (overallDependencies targetSet)
, buildDepends = fromDepMap (overallDependencies enabled targetSet)
}
, flagVals )
......@@ -582,7 +590,7 @@ finalizePackageDescription userflags satisfyDep
++ map (\(name,tree) -> mapTreeData (Bench name) tree) bms0
resolveFlags =
case resolveWithFlags flagChoices os arch impl constraints condTrees check of
case resolveWithFlags flagChoices enabled os arch impl constraints condTrees check of
Right (targetSet, fs) ->
let (libs, exes, tests, bms) = flattenTaggedTargets targetSet in
Right ( (map (\(n,l) -> (libFillInDefaults l) { libName = n }) libs,
......@@ -604,6 +612,20 @@ finalizePackageDescription userflags satisfyDep
then DepOk
else MissingDeps missingDeps
{-# DEPRECATED finalizePackageDescription "This function now always assumes tests and benchmarks are disabled; use finalizePD with ComponentEnabledSpec to specify something more specific." #-}
finalizePackageDescription ::
FlagAssignment -- ^ Explicitly specified flag assignments
-> (Dependency -> Bool) -- ^ Is a given dependency satisfiable from the set of
-- available packages? If this is unknown then use
-- True.
-> Platform -- ^ The 'Arch' and 'OS'
-> CompilerInfo -- ^ Compiler information
-> [Dependency] -- ^ Additional constraints
-> GenericPackageDescription
-> Either [Dependency]
(PackageDescription, FlagAssignment)
finalizePackageDescription flags = finalizePD flags defaultComponentEnabled
{-
let tst_p = (CondNode [1::Int] [Distribution.Package.Dependency "a" AnyVersion] [])
let tst_p2 = (CondNode [1::Int] [Distribution.Package.Dependency "a" (EarlierVersion (Version [1,0] [])), Distribution.Package.Dependency "a" (LaterVersion (Version [2,0] []))] [])
......
......@@ -152,10 +152,10 @@ ppTestSuites suites =
maybeTestType | testInterface testsuite == mempty = Nothing
| otherwise = Just (testType testsuite)
ppTestSuite (TestSuite _ _ buildInfo' _)
(Just (TestSuite _ _ buildInfo2 _)) =
ppDiffFields binfoFieldDescrs buildInfo' buildInfo2
$+$ ppCustomFields (customFieldsBI buildInfo')
ppTestSuite test' (Just test2) =
ppDiffFields binfoFieldDescrs
(testBuildInfo test') (testBuildInfo test2)
$+$ ppCustomFields (customFieldsBI (testBuildInfo test'))
testSuiteMainIs test = case testInterface test of
TestSuiteExeV10 _ f -> Just f
......@@ -182,10 +182,10 @@ ppBenchmarks suites =
maybeBenchmarkType | benchmarkInterface benchmark == mempty = Nothing
| otherwise = Just (benchmarkType benchmark)
ppBenchmark (Benchmark _ _ buildInfo' _)
(Just (Benchmark _ _ buildInfo2 _)) =
ppDiffFields binfoFieldDescrs buildInfo' buildInfo2
$+$ ppCustomFields (customFieldsBI buildInfo')
ppBenchmark bench' (Just bench2) =
ppDiffFields binfoFieldDescrs
(benchmarkBuildInfo bench') (benchmarkBuildInfo bench2)
$+$ ppCustomFields (customFieldsBI (benchmarkBuildInfo bench'))
benchmarkMainIs benchmark = case benchmarkInterface benchmark of
BenchmarkExeV10 _ f -> Just f
......
......@@ -40,9 +40,7 @@ bench args pkg_descr lbi flags = do
let verbosity = fromFlag $ benchmarkVerbosity flags
benchmarkNames = args
pkgBenchmarks = PD.benchmarks pkg_descr
enabledBenchmarks = [ t | t <- pkgBenchmarks
, PD.benchmarkEnabled t
, PD.buildable (PD.benchmarkBuildInfo t) ]
enabledBenchmarks = map fst (LBI.enabledBenchLBIs pkg_descr lbi)
-- Run the benchmark
doBench :: PD.Benchmark -> IO ExitCode
......
......@@ -81,7 +81,7 @@ build pkg_descr lbi flags suffixes
-- a --assume-deps-up-to-date with multiple arguments. Arguably, we should
-- error early in this case.
targets <- readBuildTargets pkg_descr (buildArgs flags)
(cname, _) <- checkBuildTargets verbosity pkg_descr targets >>= \r -> case r of
(cname, _) <- checkBuildTargets verbosity pkg_descr lbi targets >>= \r -> case r of
[] -> die "In --assume-deps-up-to-date mode you must specify a target"
[target'] -> return target'
_ -> die "In --assume-deps-up-to-date mode you can only build a single target"
......@@ -106,7 +106,7 @@ build pkg_descr lbi flags suffixes
lbi' suffixes comp clbi distPref
| otherwise = do
targets <- readBuildTargets pkg_descr (buildArgs flags)
targets' <- checkBuildTargets verbosity pkg_descr targets
targets' <- checkBuildTargets verbosity pkg_descr lbi targets
let componentsToBuild = componentsInBuildOrder lbi (map fst targets')
info verbosity $ "Component build order: "
++ intercalate ", " (map (showComponentName . componentLocalName) componentsToBuild)
......@@ -145,9 +145,10 @@ repl pkg_descr lbi flags suffixes args = do
targets <- readBuildTargets pkg_descr args
targets' <- case targets of
-- This seems DEEPLY questionable.
[] -> return $ take 1 [ componentName c
| c <- pkgEnabledComponents pkg_descr ]
[target] -> fmap (map fst) (checkBuildTargets verbosity pkg_descr [target])
| c <- pkgBuildableComponents pkg_descr ]
[target] -> fmap (map fst) (checkBuildTargets verbosity pkg_descr lbi [target])
_ -> die $ "The 'repl' command does not support multiple targets at once."
let componentsToBuild = componentsInBuildOrder lbi targets'
componentForRepl = last componentsToBuild
......
......@@ -947,16 +947,17 @@ caseFold = lowercase
--
-- Also swizzle into a more convenient form.
--
checkBuildTargets :: Verbosity -> PackageDescription -> [BuildTarget]
checkBuildTargets :: Verbosity -> PackageDescription -> LocalBuildInfo -> [BuildTarget]
-> IO [(ComponentName, Maybe (Either ModuleName FilePath))]
checkBuildTargets _ pkg [] =
return [ (componentName c, Nothing) | c <- pkgEnabledComponents pkg ]
checkBuildTargets _ pkg lbi [] =
return [ (componentName c, Nothing) | c <- enabledComponents pkg lbi ]
checkBuildTargets verbosity pkg targets = do
checkBuildTargets verbosity pkg lbi targets = do
let (enabled, disabled) =
partitionEithers
[ case componentDisabledReason (getComponent pkg cname) of
[ case componentDisabledReason (componentEnabledSpec lbi)
(getComponent pkg cname) of
Nothing -> Left target'
Just reason -> Right (cname, reason)
| target <- targets
......
......@@ -373,6 +373,12 @@ configure (pkg_descr0', pbi) cfg = do
let internalPackageSet :: InstalledPackageIndex
internalPackageSet = getInternalPackages pkg_descr0
-- Make a data structure describing what components are enabled.
let enabled :: ComponentEnabledSpec
enabled = ComponentEnabledSpec
{ testsEnabled = fromFlag (configTests cfg)
, benchmarksEnabled = fromFlag (configBenchmarks cfg) }
-- allConstraints: The set of all 'Dependency's we have. Used ONLY
-- to 'configureFinalizedPackage'.
-- requiredDepsMap: A map from 'PackageName' to the specifically
......@@ -410,7 +416,7 @@ configure (pkg_descr0', pbi) cfg = do
-- cleaner to then configure the dependencies afterwards.
(pkg_descr :: PackageDescription,
flags :: FlagAssignment)
<- configureFinalizedPackage verbosity cfg
<- configureFinalizedPackage verbosity cfg enabled
allConstraints
(dependencySatisfiable
(fromFlagOrDefault False (configExactConfiguration cfg))
......@@ -571,7 +577,7 @@ configure (pkg_descr0', pbi) cfg = do
-- From there, we build a ComponentLocalBuildInfo for each of the
-- components, which lets us actually build each component.
buildComponents <-
case mkComponentsGraph pkg_descr internalPkgDeps of
case mkComponentsGraph enabled pkg_descr internalPkgDeps of
Left componentCycle -> reportComponentCycle componentCycle
Right comps ->
mkComponentsLocalBuildInfo cfg comp packageDependsIndex pkg_descr
......@@ -668,6 +674,7 @@ configure (pkg_descr0', pbi) cfg = do
let lbi = LocalBuildInfo {
configFlags = cfg',
flagAssignment = flags,
componentEnabledSpec = enabled,
extraConfigArgs = [], -- Currently configure does not
-- take extra args, but if it
-- did they would go here.
......@@ -800,7 +807,7 @@ checkExactConfiguration pkg_descr0 cfg = do
--
-- It must be *any libraries that might be* defined rather than the
-- actual definitions, because these depend on conditionals in the .cabal
-- file, and we haven't resolved them yet. finalizePackageDescription
-- file, and we haven't resolved them yet. finalizePD
-- does the resolution of conditionals, and it takes internalPackageSet
-- as part of its input.
getInternalPackages :: GenericPackageDescription
......@@ -825,7 +832,7 @@ getInternalPackages pkg_descr0 =
-- | Returns true if a dependency is satisfiable. This is to be passed
-- to finalizePackageDescription.
-- to finalizePD.
dependencySatisfiable
:: Bool
-> InstalledPackageIndex -- ^ installed set
......@@ -841,7 +848,7 @@ dependencySatisfiable
-- line. Thus we only consult the 'requiredDepsMap'. Note that
-- we're not doing the version range check, so if there's some
-- dependency that wasn't specified on the command line,
-- 'finalizePackageDescription' will fail.
-- 'finalizePD' will fail.
--
-- TODO: mention '--exact-configuration' in the error message
-- when this fails?
......@@ -884,7 +891,7 @@ relaxPackageDeps (RelaxDepsSome allowNewerDeps') gpd =
else d
-- | Finalize a generic package description. The workhorse is
-- 'finalizePackageDescription' but there's a bit of other nattering
-- 'finalizePD' but there's a bit of other nattering
-- about necessary.
--
-- TODO: what exactly is the business with @flaggedTests@ and
......@@ -892,6 +899,7 @@ relaxPackageDeps (RelaxDepsSome allowNewerDeps') gpd =
configureFinalizedPackage
:: Verbosity
-> ConfigFlags
-> ComponentEnabledSpec
-> [Dependency]
-> (Dependency -> Bool) -- ^ tests if a dependency is satisfiable.
-- Might say it's satisfiable even when not.
......@@ -899,27 +907,18 @@ configureFinalizedPackage
-> Platform
-> GenericPackageDescription
-> IO (PackageDescription, FlagAssignment)
configureFinalizedPackage verbosity cfg
configureFinalizedPackage verbosity cfg enabled
allConstraints satisfies comp compPlatform pkg_descr0 = do
let enableTest t = t { testEnabled = fromFlag (configTests cfg) }
flaggedTests = map (\(n, t) -> (n, mapTreeData enableTest t))
(condTestSuites pkg_descr0)
enableBenchmark bm = bm { benchmarkEnabled =
fromFlag (configBenchmarks cfg) }
flaggedBenchmarks = map (\(n, bm) ->
(n, mapTreeData enableBenchmark bm))
(condBenchmarks pkg_descr0)
pkg_descr0'' = pkg_descr0 { condTestSuites = flaggedTests
, condBenchmarks = flaggedBenchmarks }
(pkg_descr0', flags) <-
case finalizePackageDescription
case finalizePD
(configConfigurationsFlags cfg)
enabled
satisfies
compPlatform
(compilerInfo comp)
allConstraints
pkg_descr0''
pkg_descr0
of Right r -> return r
Left missing ->
die $ "Encountered missing dependencies:\n"
......@@ -1435,13 +1434,15 @@ configCompilerAux = fmap (\(a,_,b) -> (a,b)) . configCompilerAuxEx
-- (although it is in the absence of Backpack.)
--
-- TODO: tighten up the type of 'internalPkgDeps'
mkComponentsGraph :: PackageDescription
mkComponentsGraph :: ComponentEnabledSpec
-> PackageDescription
-> [PackageId]
-> Either [ComponentName]
[(Component, [ComponentName])]
mkComponentsGraph pkg_descr internalPkgDeps =
mkComponentsGraph enabled pkg_descr internalPkgDeps =
let graph = [ (c, componentName c, componentDeps c)
| c <- pkgEnabledComponents pkg_descr ]
| c <- pkgBuildableComponents pkg_descr
, componentEnabled enabled c ]
in case checkComponentsCyclic graph of
Just ccycle -> Left [ cname | (_,cname,_) <- ccycle ]
Nothing -> Right [ (c, cdeps) | (c, _, cdeps) <- topSortFromEdges graph ]
......
......@@ -61,7 +61,7 @@ install pkg_descr lbi flags
| fromFlag (copyAssumeDepsUpToDate flags) = do
checkHasLibsOrExes
targets <- readBuildTargets pkg_descr (copyArgs flags)
targets' <- checkBuildTargets verbosity pkg_descr targets
targets' <- checkBuildTargets verbosity pkg_descr lbi targets
case targets' of
_ | null (copyArgs flags)
-> copyPackage verbosity pkg_descr lbi distPref copydest
......@@ -74,7 +74,7 @@ install pkg_descr lbi flags
| otherwise = do
checkHasLibsOrExes
targets <- readBuildTargets pkg_descr (copyArgs flags)
targets' <- checkBuildTargets verbosity pkg_descr targets
targets' <- checkBuildTargets verbosity pkg_descr lbi targets
copyPackage verbosity pkg_descr lbi distPref copydest
......
......@@ -38,11 +38,9 @@ module Distribution.Simple.LocalBuildInfo (
foldComponent,
componentName,
componentBuildInfo,
componentEnabled,
componentDisabledReason,
ComponentDisabledReason(..),
componentBuildable,
pkgComponents,
pkgEnabledComponents,
pkgBuildableComponents,
lookupComponent,
getComponent,
maybeGetDefaultLibraryLocalBuildInfo,
......@@ -58,7 +56,19 @@ module Distribution.Simple.LocalBuildInfo (
withComponentsLBI,
withLibLBI,
withExeLBI,
withBenchLBI,
withTestLBI,
enabledTestLBIs,
enabledBenchLBIs,
enabledComponents,
-- $buildable_vs_enabled_components
ComponentEnabledSpec(..),