Commit d03fe594 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Refactor ComponentEnabledSpec into ComponentRequestedSpec.



In the previous documentation for 'ComponentEnabledSpec', I claimed
that enabled components were buildable, as well as requested
by the user.  In the course of working on #3847, however,
I realized that I hadn't actually *checked* that the component
was buildable anywhere.  In particular, the 'ComponentDisabled'
reason was *never used*.  This mostly didn't cause problems,
however, because when we 'flattenPD' all non-buildable components
get deleted, so you basically never actually have a non-buildable
'Component'.

But it still seemed a bit silly, so I fixed it by doing this:

1) I introduce a new concept of a component being requested,
which captures the use of --enable-tests and friends.  This
does NOT imply buildability.  Renamed ComponentEnabledSpec
to ComponentRequestedSpec

2) A component is enabled if it is requested and buildable.
If you give me a Component and a ComponentRequestedSpec I
can tell you if it's enabled.  However, if you give me a
ComponentName I can't, because I have no idea if it's buildable.

3) Stopped reexporting ComponentRequestedSpec from
Distribution.Simple.LocalBuildInfo

4) Added a test for attempting to specify a non-buildable
component as a target.  The test is accepting suboptimal
output at the moment, see #3858.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent f0b9ea77
......@@ -99,6 +99,8 @@ extra-source-files:
tests/PackageTests/BuildDeps/TargetSpecificDeps3/MyLibrary.hs
tests/PackageTests/BuildDeps/TargetSpecificDeps3/lemon.hs
tests/PackageTests/BuildDeps/TargetSpecificDeps3/my.cabal
tests/PackageTests/BuildTargetErrors/BuildTargetErrors.cabal
tests/PackageTests/BuildTargetErrors/Main.hs
tests/PackageTests/BuildTestSuiteDetailedV09/Dummy2.hs
tests/PackageTests/BuildToolsPath/A.hs
tests/PackageTests/BuildToolsPath/MyCustomPreprocessor.hs
......@@ -402,7 +404,7 @@ library
Distribution.Types.Component
Distribution.Types.ComponentLocalBuildInfo
Distribution.Types.LocalBuildInfo
Distribution.Types.ComponentEnabledSpec
Distribution.Types.ComponentRequestedSpec
Distribution.Types.TargetInfo
Distribution.Utils.NubList
Distribution.Verbosity
......
......@@ -43,11 +43,11 @@ import Distribution.System
import Distribution.License
import Distribution.Simple.BuildPaths (autogenPathsModuleName)
import Distribution.Simple.CCompiler
import Distribution.Types.ComponentRequestedSpec
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 Control.Monad (mapM)
......@@ -1421,7 +1421,7 @@ checkPackageVersions pkg =
-- open upper bound. To get a typical configuration we finalise
-- using no package index and the current platform.
finalised = finalizePD
[] defaultComponentEnabled (const True)
[] defaultComponentRequestedSpec (const True)
buildPlatform
(unknownCompilerInfo
(CompilerId buildCompilerFlavor (Version [] []))
......
......@@ -48,7 +48,7 @@ import Distribution.Simple.Utils
import Distribution.Text
import Distribution.Compat.ReadP as ReadP hiding ( char )
import qualified Distribution.Compat.ReadP as ReadP ( char )
import Distribution.Simple.LocalBuildInfo
import Distribution.Types.ComponentRequestedSpec
import qualified Data.Map as Map
import Data.Tree ( Tree(Node) )
......@@ -208,7 +208,7 @@ instance Semigroup d => Semigroup (DepTestRslt d) where
resolveWithFlags ::
[(FlagName,[Bool])]
-- ^ Domain for each flag name, will be tested in order.
-> ComponentEnabledSpec
-> ComponentRequestedSpec
-> OS -- ^ OS as returned by Distribution.System.buildOS
-> Arch -- ^ Arch as returned by Distribution.System.buildArch
-> CompilerInfo -- ^ Compiler information
......@@ -416,7 +416,7 @@ 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 :: ComponentEnabledSpec -> TargetSet PDTagged -> DependencyMap
overallDependencies :: ComponentRequestedSpec -> TargetSet PDTagged -> DependencyMap
overallDependencies enabled (TargetSet targets) = mconcat depss
where
(depss, _) = unzip $ filter (removeDisabledSections . snd) targets
......@@ -424,11 +424,11 @@ overallDependencies enabled (TargetSet targets) = mconcat depss
-- UGH. The embedded componentName in the 'Component's here is
-- BLANK. I don't know whose fault this is but I'll use the tag
-- instead. -- ezyang
removeDisabledSections (Lib _) = componentNameEnabled enabled CLibName
removeDisabledSections (SubLib t _) = componentNameEnabled enabled (CSubLibName t)
removeDisabledSections (Exe t _) = componentNameEnabled enabled (CExeName t)
removeDisabledSections (Test t _) = componentNameEnabled enabled (CTestName t)
removeDisabledSections (Bench t _) = componentNameEnabled enabled (CBenchName t)
removeDisabledSections (Lib _) = componentNameRequested enabled CLibName
removeDisabledSections (SubLib t _) = componentNameRequested enabled (CSubLibName t)
removeDisabledSections (Exe t _) = componentNameRequested enabled (CExeName t)
removeDisabledSections (Test t _) = componentNameRequested enabled (CTestName t)
removeDisabledSections (Bench t _) = componentNameRequested enabled (CBenchName t)
removeDisabledSections PDNull = True
-- Apply extra constraints to a dependency map.
......@@ -564,9 +564,13 @@ instance Semigroup PDTagged where
-- On success, it will return the package description and the full flag
-- assignment chosen.
--
-- Note that this drops any stanzas which have @buildable: False@. While
-- this is arguably the right thing to do, it means we give bad error
-- messages in some situations, see #3858.
--
finalizePD ::
FlagAssignment -- ^ Explicitly specified flag assignments
-> ComponentEnabledSpec
-> ComponentRequestedSpec
-> (Dependency -> Bool) -- ^ Is a given dependency satisfiable from the set of
-- available packages? If this is unknown then use
-- True.
......@@ -625,7 +629,7 @@ finalizePD userflags enabled 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." #-}
{-# DEPRECATED finalizePackageDescription "This function now always assumes tests and benchmarks are disabled; use finalizePD with ComponentRequestedSpec to specify something more specific." #-}
finalizePackageDescription ::
FlagAssignment -- ^ Explicitly specified flag assignments
-> (Dependency -> Bool) -- ^ Is a given dependency satisfiable from the set of
......@@ -637,7 +641,7 @@ finalizePackageDescription ::
-> GenericPackageDescription
-> Either [Dependency]
(PackageDescription, FlagAssignment)
finalizePackageDescription flags = finalizePD flags defaultComponentEnabled
finalizePackageDescription flags = finalizePD flags defaultComponentRequestedSpec
{-
let tst_p = (CondNode [1::Int] [Distribution.Package.Dependency "a" AnyVersion] [])
......
......@@ -38,6 +38,7 @@ import Distribution.Compat.Prelude
import Distribution.Types.TargetInfo
import Distribution.Types.LocalBuildInfo
import Distribution.Types.ComponentRequestedSpec
import Distribution.Package
import Distribution.PackageDescription
......@@ -972,11 +973,12 @@ checkBuildTargets verbosity pkg_descr lbi targets = do
let (enabled, disabled) =
partitionEithers
[ case componentNameDisabledReason (componentEnabledSpec lbi) cname of
[ case componentDisabledReason (componentEnabledSpec lbi) comp of
Nothing -> Left target'
Just reason -> Right (cname, reason)
| target <- targets
, let target'@(cname,_) = swizzleTarget target ]
, let target'@(cname,_) = swizzleTarget target
, let comp = getComponent pkg_descr cname ]
case disabled of
[] -> return ()
......
......@@ -80,6 +80,7 @@ import Distribution.Simple.BuildTarget
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Simple.LocalBuildInfo
import Distribution.Types.LocalBuildInfo
import Distribution.Types.ComponentRequestedSpec
import Distribution.Simple.Utils
import Distribution.Simple.Register (createInternalPackageDB)
import Distribution.System
......@@ -400,12 +401,19 @@ configure (pkg_descr0', pbi) cfg = do
internalPackageSet = getInternalPackages pkg_descr0
-- Make a data structure describing what components are enabled.
let enabled :: ComponentEnabledSpec
let enabled :: ComponentRequestedSpec
enabled = case mb_cname of
Just cname -> OneComponentEnabledSpec cname
Nothing -> ComponentEnabledSpec
{ testsEnabled = fromFlag (configTests cfg)
, benchmarksEnabled =
Just cname -> OneComponentRequestedSpec cname
Nothing -> ComponentRequestedSpec
-- The flag name (@--enable-tests@) is a
-- little bit of a misnomer, because
-- just passing this flag won't
-- "enable", in our internal
-- nomenclature; it's just a request; a
-- @buildable: False@ might make it
-- not possible to enable.
{ testsRequested = fromFlag (configTests cfg)
, benchmarksRequested =
fromFlag (configBenchmarks cfg) }
-- Some sanity checks related to enabling components.
when (isJust mb_cname
......@@ -933,7 +941,7 @@ relaxPackageDeps vrtrans (RelaxDepsSome allowNewerDeps') gpd =
configureFinalizedPackage
:: Verbosity
-> ConfigFlags
-> ComponentEnabledSpec
-> ComponentRequestedSpec
-> [Dependency]
-> (Dependency -> Bool) -- ^ tests if a dependency is satisfiable.
-- Might say it's satisfiable even when not.
......@@ -1576,7 +1584,7 @@ configCompilerAux = fmap (\(a,_,b) -> (a,b)) . configCompilerAuxEx
-- libraries are considered internal), create a graph of dependencies
-- between the components. This is NOT necessarily the build order
-- (although it is in the absence of Backpack.)
mkComponentsGraph :: ComponentEnabledSpec
mkComponentsGraph :: ComponentRequestedSpec
-> PackageDescription
-> Map PackageName ComponentName
-> Either [ComponentName]
......
......@@ -57,15 +57,6 @@ module Distribution.Simple.LocalBuildInfo (
enabledTestLBIs,
enabledBenchLBIs,
-- TODO: Don't export me
ComponentEnabledSpec(..),
defaultComponentEnabled,
componentEnabled,
componentDisabledReason,
componentNameEnabled,
componentNameDisabledReason,
ComponentDisabledReason(..),
-- * Installation directories
module Distribution.Simple.InstallDirs,
absoluteInstallDirs, prefixRelativeInstallDirs,
......@@ -78,7 +69,6 @@ import Distribution.Compat.Prelude
import Distribution.Types.Component
import Distribution.Types.ComponentName
import Distribution.Types.ComponentEnabledSpec
import Distribution.Types.PackageDescription
import Distribution.Types.ComponentLocalBuildInfo
import Distribution.Types.LocalBuildInfo
......
......@@ -42,7 +42,7 @@ componentBuildInfo =
-- | Is a component buildable (i.e., not marked with @buildable: False@)?
-- See also this note in
-- "Distribution.Types.ComponentEnabledSpec#buildable_vs_enabled_components".
-- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components".
--
-- @since 2.0.0.0
--
......
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.ComponentEnabledSpec (
module Distribution.Types.ComponentRequestedSpec (
-- $buildable_vs_enabled_components
ComponentEnabledSpec(..),
ComponentRequestedSpec(..),
ComponentDisabledReason(..),
defaultComponentEnabled,
defaultComponentRequestedSpec,
componentNameRequested,
componentEnabled,
componentNameEnabled,
componentDisabledReason,
componentNameDisabledReason,
) where
import Prelude ()
......@@ -23,9 +22,10 @@ import Distribution.Types.ComponentName
-- $buildable_vs_enabled_components
-- #buildable_vs_enabled_components#
--
-- = Note: Buildable versus enabled components
-- = Note: Buildable versus requested versus enabled components
-- What's the difference between a buildable component (ala
-- 'componentBuildable') versus enabled component (ala
-- 'componentBuildable'), a requested component
-- (ala 'componentNameRequested'), and an enabled component (ala
-- 'componentEnabled')?
--
-- A component is __buildable__ if, after resolving flags and
......@@ -34,71 +34,83 @@ import Distribution.Types.ComponentName
-- Cabal file and the package description flattening; once we have
-- a 'PackageDescription' buildability is known.
--
-- A component is __enabled__ if it is buildable, and the user
-- configured (@./Setup configure@) the package to build it,
-- e.g., using @--enable-tests@ or @--enable-benchmarks@.
-- Once we have a 'LocalBuildInfo', whether or not a component
-- is enabled is known.
-- A component is __requested__ if a user specified, via a
-- the flags and arguments passed to configure, that it should be
-- built. E.g., @--enable-tests@ or @--enable-benchmarks@ request
-- all tests and benchmarks, if they are provided. What is requested
-- can be read off directly from 'ComponentRequestedSpec'. A requested
-- component is not always buildable; e.g., a user may @--enable-tests@
-- but one of the test suites may have @buildable: False@.
--
-- A component is __enabled__ if it is BOTH buildable
-- and requested. Once we have a 'LocalBuildInfo', whether or not a
-- component is enabled is known.
--
-- Generally speaking, most Cabal API code cares if a component
-- is enabled, as opposed to buildable. (For example, if you
-- want to run a preprocessor on each component prior to building
-- them, you want to run this on each /enabled/ component.)
-- is enabled. (For example, if you want to run a preprocessor on each
-- component prior to building them, you want to run this on each
-- /enabled/ component.)
--
-- Note that post-configuration, you will generally not see a
-- non-buildable 'Component'. This is because 'flattenPD' will drop
-- any such components from 'PackageDescription'. See #3858 for
-- an example where this causes problems.
-- | Describes what components are enabled by user-interaction.
-- See also this note in
-- "Distribution.Types.ComponentEnabledSpec#buildable_vs_enabled_components".
-- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components".
--
-- @since 2.0.0.0
data ComponentEnabledSpec
= ComponentEnabledSpec { testsEnabled :: Bool,
benchmarksEnabled :: Bool }
| OneComponentEnabledSpec ComponentName
data ComponentRequestedSpec
= ComponentRequestedSpec { testsRequested :: Bool
, benchmarksRequested :: Bool }
| OneComponentRequestedSpec ComponentName
deriving (Generic, Read, Show, Eq)
instance Binary ComponentEnabledSpec
instance Binary ComponentRequestedSpec
-- | The default set of enabled components. Historically tests and
-- benchmarks are NOT enabled by default.
--
-- @since 2.0.0.0
defaultComponentEnabled :: ComponentEnabledSpec
defaultComponentEnabled = ComponentEnabledSpec False False
defaultComponentRequestedSpec :: ComponentRequestedSpec
defaultComponentRequestedSpec = ComponentRequestedSpec False False
-- | Is this component enabled? See also this note in
-- "Distribution.Types.ComponentEnabledSpec#buildable_vs_enabled_components".
-- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components".
--
-- @since 2.0.0.0
componentEnabled :: ComponentEnabledSpec -> Component -> Bool
componentEnabled :: ComponentRequestedSpec -> Component -> Bool
componentEnabled enabled = isNothing . componentDisabledReason enabled
-- | Is this component name enabled? See also this note in
-- "Distribution.Types.ComponentEnabledSpec#buildable_vs_enabled_components".
-- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components".
--
-- @since 2.0.0.0
componentNameEnabled :: ComponentEnabledSpec -> ComponentName -> Bool
componentNameEnabled enabled = isNothing . componentNameDisabledReason enabled
componentNameRequested :: ComponentRequestedSpec -> ComponentName -> Bool
componentNameRequested enabled = isNothing . componentNameNotRequestedReason enabled
-- | Is this component disabled, and if so, why?
--
-- @since 2.0.0.0
componentDisabledReason :: ComponentEnabledSpec -> Component
componentDisabledReason :: ComponentRequestedSpec -> Component
-> Maybe ComponentDisabledReason
componentDisabledReason enabled comp
= componentNameDisabledReason enabled (componentName comp)
| not (componentBuildable comp) = Just DisabledComponent
| otherwise = componentNameNotRequestedReason enabled (componentName comp)
-- | Is this component name disabled, and if so, why?
--
-- @since 2.0.0.0
componentNameDisabledReason :: ComponentEnabledSpec -> ComponentName
componentNameNotRequestedReason :: ComponentRequestedSpec -> ComponentName
-> Maybe ComponentDisabledReason
componentNameDisabledReason
ComponentEnabledSpec{ testsEnabled = False } (CTestName _)
componentNameNotRequestedReason
ComponentRequestedSpec{ testsRequested = False } (CTestName _)
= Just DisabledAllTests
componentNameDisabledReason
ComponentEnabledSpec{ benchmarksEnabled = False } (CBenchName _)
componentNameNotRequestedReason
ComponentRequestedSpec{ benchmarksRequested = False } (CBenchName _)
= Just DisabledAllBenchmarks
componentNameDisabledReason ComponentEnabledSpec{} _ = Nothing
componentNameDisabledReason (OneComponentEnabledSpec cname) c
componentNameNotRequestedReason ComponentRequestedSpec{} _ = Nothing
componentNameNotRequestedReason (OneComponentRequestedSpec cname) c
| c == cname = Nothing
| otherwise = Just (DisabledAllButOne (display cname))
......
......@@ -57,7 +57,7 @@ import Distribution.Compat.Prelude
import Distribution.Types.PackageDescription
import Distribution.Types.ComponentLocalBuildInfo
import Distribution.Types.ComponentEnabledSpec
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.TargetInfo
import Distribution.Simple.InstallDirs hiding (absoluteInstallDirs,
......@@ -84,7 +84,7 @@ data LocalBuildInfo = LocalBuildInfo {
-- Needed to re-run configuration when .cabal is out of date
flagAssignment :: FlagAssignment,
-- ^ The final set of flags which were picked for this package
componentEnabledSpec :: ComponentEnabledSpec,
componentEnabledSpec :: ComponentRequestedSpec,
-- ^ What components were enabled during configuration, and why.
extraConfigArgs :: [String],
-- ^ Extra args on the command line for the configuration step.
......
......@@ -58,7 +58,7 @@ import Distribution.Types.Benchmark
import Distribution.Types.Component
import Distribution.Types.ComponentName
import Distribution.Types.ComponentEnabledSpec
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.SetupBuildInfo
import Distribution.Types.BuildInfo
import Distribution.Types.BuildType
......@@ -222,7 +222,7 @@ allLibraries p = maybeToList (library p) ++ subLibraries p
-- 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.Types.ComponentEnabledSpec#buildable_vs_enabled_components"
-- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components"
-- for more information.
withLib :: PackageDescription -> (Library -> IO ()) -> IO ()
withLib pkg_descr f =
......@@ -238,7 +238,7 @@ hasExes p = any (buildable . buildInfo) (executables p)
-- | Perform the action on each buildable 'Executable' in the package
-- description. You probably want 'withExeLBI' if you have a
-- 'LocalBuildInfo', see the note in
-- "Distribution.Types.ComponentEnabledSpec#buildable_vs_enabled_components"
-- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components"
-- for more information.
withExe :: PackageDescription -> (Executable -> IO ()) -> IO ()
withExe pkg_descr f =
......@@ -253,7 +253,7 @@ hasTests = any (buildable . testBuildInfo) . 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.Types.ComponentEnabledSpec#buildable_vs_enabled_components"
-- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components"
-- for more information.
withTest :: PackageDescription -> (TestSuite -> IO ()) -> IO ()
......@@ -269,7 +269,7 @@ hasBenchmarks = any (buildable . benchmarkBuildInfo) . 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.Types.ComponentEnabledSpec#buildable_vs_enabled_components"
-- "Distribution.Types.ComponentRequestedSpec#buildable_vs_enabled_components"
-- for more information.
withBenchmark :: PackageDescription -> (Benchmark -> IO ()) -> IO ()
......@@ -298,6 +298,9 @@ allBuildInfo pkg_descr = [ bi | lib <- allLibraries pkg_descr
--FIXME: many of the places where this is used, we actually want to look at
-- unbuildable bits too, probably need separate functions
--enabledBuildInfos :: PackageDescription -> ComponentRequestedSpec -> [BuildInfo]
-- enabledBuildInfos pkg enabled = enabledComponents pkg enabled
-- ------------------------------------------------------------
-- * Utils
......@@ -352,7 +355,7 @@ pkgBuildableComponents = filter componentBuildable . pkgComponents
--
-- @since 2.0.0.0
--
enabledComponents :: PackageDescription -> ComponentEnabledSpec -> [Component]
enabledComponents :: PackageDescription -> ComponentRequestedSpec -> [Component]
enabledComponents pkg enabled = filter (componentEnabled enabled) $ pkgBuildableComponents pkg
lookupComponent :: PackageDescription -> ComponentName -> Maybe Component
......
......@@ -38,7 +38,7 @@
use 'withTestLBI' and 'withBenchLBI'.
'finalizePackageDescription' is deprecated:
its replacement 'finalizePD' now takes an extra argument
'ComponentEnabledSpec' which specifies what components
'ComponentRequestedSpec' which specifies what components
are to be enabled: use this instead of modifying the
'Component' in a 'GenericPackageDescription'. (As
it's not possible now, 'finalizePackageDescription'
......
name: BuildTargetErrors
version: 1.0
build-type: Simple
cabal-version: >= 1.9
library
executable not-buildable-exe
main-is: Main.hs
buildable: False
......@@ -577,6 +577,14 @@ tests config = do
cabal "register" ["--assume-deps-up-to-date", "RegisterAssumeDepsUpToDate", "--gen-pkg-config=" ++ main_reg]
ghcPkg "register" [pkg_dir </> main_reg]
-- Test error message we report when a non-buildable target is
-- requested to be built
-- TODO: We can give a better error message here, see #3858.
tcs "BuildTargetErrors" "non-buildable" $ do
cabal "configure" []
assertOutputContains "There is no component"
=<< shouldFail (cabal' "build" ["not-buildable-exe"])
where
ghc_pkg_guess bin_name = do
cwd <- packageDir
......
......@@ -33,8 +33,8 @@ import Distribution.PackageDescription.Configuration
( finalizePD )
import Distribution.PackageDescription.Parse
( readPackageDescription )
import Distribution.Simple.LocalBuildInfo
( defaultComponentEnabled )
import Distribution.Types.ComponentRequestedSpec
( defaultComponentRequestedSpec )
import Distribution.Simple.Compiler
( Compiler, PackageDBStack, compilerInfo )
import Distribution.Simple.Program
......@@ -111,7 +111,7 @@ genBounds verbosity packageDBs repoCtxt comp platform progdb mSandboxPkgInfo
gpd <- readPackageDescription verbosity path
-- NB: We don't enable tests or benchmarks, since often they
-- don't really have useful bounds.
let epd = finalizePD [] defaultComponentEnabled
let epd = finalizePD [] defaultComponentRequestedSpec
(const True) platform cinfo [] gpd
case epd of
Left _ -> putStrLn "finalizePD failed"
......
......@@ -49,7 +49,7 @@ import Distribution.Client.SolverInstallPlan
( SolverInstallPlan )
import Distribution.Client.DistDirLayout
import Distribution.Types.ComponentEnabledSpec
import Distribution.Types.ComponentRequestedSpec
import Distribution.Package
hiding (InstalledPackageId, installedPackageId)
import Distribution.System
......@@ -152,7 +152,7 @@ data ElaboratedConfiguredPackage
elabBuildStyle :: BuildStyle,
-- | Another way of phrasing 'pkgStanzasAvailable'.
elabEnabledSpec :: ComponentEnabledSpec,
elabEnabledSpec :: ComponentRequestedSpec,
-- | Which optional stanzas (ie testsuites, benchmarks) can be built.
-- This means the solver produced a plan that has them available.
......
......@@ -6,7 +6,8 @@ module Distribution.Solver.Types.OptionalStanza
import GHC.Generics (Generic)
import Distribution.Compat.Binary (Binary(..))
import Distribution.Simple.LocalBuildInfo (ComponentEnabledSpec(..), defaultComponentEnabled)
import Distribution.Types.ComponentRequestedSpec
(ComponentRequestedSpec(..), defaultComponentRequestedSpec)
import Data.List (foldl')
data OptionalStanza
......@@ -15,11 +16,11 @@ data OptionalStanza
deriving (Eq, Ord, Enum, Bounded, Show, Generic)
-- | Convert a list of 'OptionalStanza' into the corresponding
-- 'ComponentEnabledSpec' which records what components are enabled.
enableStanzas :: [OptionalStanza] -> ComponentEnabledSpec
enableStanzas = foldl' addStanza defaultComponentEnabled
-- 'ComponentRequestedSpec' which records what components are enabled.
enableStanzas :: [OptionalStanza] -> ComponentRequestedSpec
enableStanzas = foldl' addStanza defaultComponentRequestedSpec
where
addStanza enabled TestStanzas = enabled { testsEnabled = True }
addStanza enabled BenchStanzas = enabled { benchmarksEnabled = True }
addStanza enabled TestStanzas = enabled { testsRequested = True }
addStanza enabled BenchStanzas = enabled { benchmarksRequested = True }
instance Binary OptionalStanza
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment