Commit a4cc1fd3 authored by Oleg Grenrus's avatar Oleg Grenrus

Refactor D.PackageDescription

Now it re-exports a collection of modules,
not individual symbols.
parent af651abb
......@@ -20,7 +20,6 @@ import Distribution.CabalSpecVersion (CabalSpecVersion)
import Distribution.Compiler (CompilerFlavor, CompilerId, PerCompilerFlavor)
import Distribution.InstalledPackageInfo (AbiDependency, ExposedModule, InstalledPackageInfo)
import Distribution.ModuleName (ModuleName)
import Distribution.Package (PackageIdentifier, PackageName)
import Distribution.PackageDescription
import Distribution.Simple.Compiler (DebugInfoLevel, OptimisationLevel, ProfDetailLevel)
import Distribution.Simple.Flag (Flag)
......@@ -30,24 +29,15 @@ import Distribution.Simple.Setup (HaddockTarget, TestShowDetai
import Distribution.System
import Distribution.Types.AbiHash (AbiHash)
import Distribution.Types.ComponentId (ComponentId)
import Distribution.Types.CondTree
import Distribution.Types.Dependency (Dependency (..), mainLibSet)
import Distribution.Types.ExecutableScope
import Distribution.Types.ExeDependency
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibOption
import Distribution.Types.ForeignLibType
import Distribution.Types.IncludeRenaming (IncludeRenaming)
import Distribution.Types.LegacyExeDependency
import Distribution.Types.LibraryVisibility (LibraryVisibility)
import Distribution.Types.Mixin
import Distribution.Types.ModuleReexport
import Distribution.Types.ModuleRenaming
import Distribution.Types.PackageVersionConstraint
import Distribution.Types.PkgconfigDependency (PkgconfigDependency)
import Distribution.Types.PkgconfigName (PkgconfigName)
import Distribution.Types.PkgconfigVersion (PkgconfigVersion)
import Distribution.Types.PkgconfigVersionRange (PkgconfigVersionRange)
import Distribution.Types.UnitId (DefUnitId, UnitId)
import Distribution.Types.UnqualComponentName
import Distribution.Utils.NubList (NubList)
import Distribution.Utils.ShortText (ShortText, fromShortText)
import Distribution.Verbosity
......
......@@ -16,7 +16,6 @@ import Distribution.PackageDescription
import Distribution.Simple.BuildToolDepends
import Distribution.Simple.LocalBuildInfo
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.UnqualComponentName
import Distribution.Compat.Graph (Graph, Node(..))
import qualified Distribution.Compat.Graph as Graph
import Distribution.Utils.Generic
......
......@@ -17,7 +17,6 @@ import Distribution.Simple.Setup as Setup
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Simple.LocalBuildInfo
import Distribution.Types.ComponentId
import Distribution.Types.PackageId
import Distribution.Types.UnitId
import Distribution.Types.MungedPackageName
import Distribution.Utils.Base62
......
......@@ -29,6 +29,7 @@ import Distribution.Utils.MapAccum
import Distribution.Types.AnnotatedId
import Distribution.Types.ComponentName
import Distribution.Types.ModuleReexport
import Distribution.Types.ModuleRenaming
import Distribution.Types.IncludeRenaming
import Distribution.Types.ComponentInclude
......
......@@ -60,7 +60,7 @@ import Distribution.Pretty
import Distribution.Types.IncludeRenaming
import Distribution.Types.ComponentInclude
import Distribution.Types.AnnotatedId
import Distribution.Types.ComponentName
import Distribution.Types.ModuleRenaming
import Distribution.Verbosity
import Data.STRef
......
......@@ -7,135 +7,91 @@
-- Maintainer : cabal-devel@haskell.org
-- Portability : portable
--
-- Backwards compatibility reexport of everything you need to know
-- Backwards compatibility reexport of most things you need to know
-- about @.cabal@ files.
module Distribution.PackageDescription (
-- * Package descriptions
PackageDescription(..),
emptyPackageDescription,
buildType,
license,
BuildType(..),
knownBuildTypes,
allLibraries,
-- ** Renaming (syntactic)
ModuleRenaming(..),
defaultRenaming,
-- ** Libraries
Library(..),
ModuleReexport(..),
emptyLibrary,
withLib,
hasPublicLib,
hasLibs,
explicitLibModules,
libModulesAutogen,
-- ** Executables
Executable(..),
emptyExecutable,
withExe,
hasExes,
exeModules,
exeModulesAutogen,
-- * Tests
TestSuite(..),
TestSuiteInterface(..),
TestType(..),
testType,
knownTestTypes,
emptyTestSuite,
hasTests,
withTest,
testModules,
testModulesAutogen,
-- * Benchmarks
Benchmark(..),
BenchmarkInterface(..),
BenchmarkType(..),
benchmarkType,
knownBenchmarkTypes,
emptyBenchmark,
hasBenchmarks,
withBenchmark,
benchmarkModules,
benchmarkModulesAutogen,
-- * Build information
BuildInfo(..),
emptyBuildInfo,
allBuildInfo,
allLanguages,
allExtensions,
usedExtensions,
usesTemplateHaskellOrQQ,
hcOptions,
hcProfOptions,
hcSharedOptions,
hcStaticOptions,
-- ** Supplementary build information
allBuildDepends,
enabledBuildDepends,
ComponentName(..),
LibraryName(..),
defaultLibName,
HookedBuildInfo,
emptyHookedBuildInfo,
updatePackageDescription,
-- * package configuration
GenericPackageDescription(..),
PackageFlag(..), emptyFlag,
FlagName, mkFlagName, unFlagName,
FlagAssignment, mkFlagAssignment, unFlagAssignment,
nullFlagAssignment, showFlagValue,
diffFlagAssignment, lookupFlagAssignment, insertFlagAssignment,
dispFlagAssignment, parsecFlagAssignment,
findDuplicateFlagAssignments,
CondTree(..), ConfVar(..), Condition(..),
cNot, cAnd, cOr,
-- * Source repositories
SourceRepo(..),
RepoKind(..),
RepoType(..),
KnownRepoType (..),
knownRepoTypes,
emptySourceRepo,
-- * Custom setup build information
SetupBuildInfo(..),
-- * PD and GPD
module Distribution.Types.PackageDescription,
module Distribution.Types.GenericPackageDescription,
-- * Components
module Distribution.Types.ComponentName,
-- ** Library
module Distribution.Types.Library,
module Distribution.Types.LibraryName,
module Distribution.Types.LibraryVisibility,
-- ** Executable
module Distribution.Types.Executable,
module Distribution.Types.ExecutableScope,
-- ** TestSuite
module Distribution.Types.TestSuite,
module Distribution.Types.TestType,
module Distribution.Types.TestSuiteInterface,
-- ** Benchmark
module Distribution.Types.Benchmark,
module Distribution.Types.BenchmarkType,
module Distribution.Types.BenchmarkInterface,
-- ** Foreign library
module Distribution.Types.ForeignLib,
module Distribution.Types.ForeignLibType,
module Distribution.Types.ForeignLibOption,
-- * BuildInfo
module Distribution.Types.BuildType,
module Distribution.Types.BuildInfo,
module Distribution.Types.HookedBuildInfo,
module Distribution.Types.SetupBuildInfo,
-- * Flags
module Distribution.Types.Flag,
-- * Identifiers
module Distribution.Types.PackageId,
module Distribution.Types.PackageName,
module Distribution.Types.UnqualComponentName,
-- * Dependencies
module Distribution.Types.Dependency,
module Distribution.Types.ExeDependency,
module Distribution.Types.LegacyExeDependency,
module Distribution.Types.PkgconfigDependency,
-- * Condition trees
module Distribution.Types.CondTree,
module Distribution.Types.Condition,
module Distribution.Types.ConfVar,
-- * Source repository
module Distribution.Types.SourceRepo,
) where
import Prelude ()
--import Distribution.Compat.Prelude
import Distribution.Types.Library
import Distribution.Types.TestSuite
import Distribution.Types.Executable
import Distribution.Types.Benchmark
import Distribution.Types.TestType
import Distribution.Types.TestSuiteInterface
import Distribution.Types.BenchmarkType
import Distribution.Types.BenchmarkInterface
import Distribution.Types.ModuleRenaming
import Distribution.Types.ModuleReexport
import Distribution.Types.BenchmarkType
import Distribution.Types.BuildInfo
import Distribution.Types.SetupBuildInfo
import Distribution.Types.BuildType
import Distribution.Types.GenericPackageDescription
import Distribution.Types.CondTree
import Distribution.Types.Condition
import Distribution.Types.PackageDescription
import Distribution.Types.ComponentName
import Distribution.Types.LibraryName
import Distribution.Types.Condition
import Distribution.Types.CondTree
import Distribution.Types.ConfVar
import Distribution.Types.Dependency
import Distribution.Types.Executable
import Distribution.Types.ExecutableScope
import Distribution.Types.ExeDependency
import Distribution.Types.Flag
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibOption
import Distribution.Types.ForeignLibType
import Distribution.Types.GenericPackageDescription
import Distribution.Types.HookedBuildInfo
import Distribution.Types.LegacyExeDependency
import Distribution.Types.Library
import Distribution.Types.LibraryName
import Distribution.Types.LibraryVisibility
import Distribution.Types.PackageDescription
import Distribution.Types.PackageId
import Distribution.Types.PackageName
import Distribution.Types.PkgconfigDependency
import Distribution.Types.SetupBuildInfo
import Distribution.Types.SourceRepo
import Distribution.Types.Flag
import Distribution.Types.ConfVar
import Distribution.Types.TestSuite
import Distribution.Types.TestSuiteInterface
import Distribution.Types.TestType
import Distribution.Types.UnqualComponentName
......@@ -52,10 +52,7 @@ import Distribution.Simple.Glob
import Distribution.Simple.Utils hiding (findPackageDesc, notice)
import Distribution.System
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.CondTree
import Distribution.Types.ExeDependency
import Distribution.Types.LibraryName
import Distribution.Types.UnqualComponentName
import Distribution.Types.ModuleReexport
import Distribution.Utils.Generic (isAscii)
import Distribution.Verbosity
import Distribution.Version
......
......@@ -33,39 +33,33 @@ module Distribution.PackageDescription.Configuration (
transformAllBuildDepends,
) where
import Prelude ()
import Distribution.Compat.Prelude
import Prelude ()
-- lens
import qualified Distribution.Types.BuildInfo.Lens as L
import qualified Distribution.Types.BuildInfo.Lens as L
import qualified Distribution.Types.GenericPackageDescription.Lens as L
import qualified Distribution.Types.PackageDescription.Lens as L
import qualified Distribution.Types.SetupBuildInfo.Lens as L
import Distribution.PackageDescription
import Distribution.PackageDescription.Utils
import Distribution.Version
import Distribution.Compiler
import Distribution.System
import Distribution.Parsec
import Distribution.Pretty
import Distribution.Compat.CharParsing hiding (char)
import qualified Distribution.Compat.CharParsing as P
import Distribution.Simple.Utils
import Distribution.Compat.Lens
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.ForeignLib
import Distribution.Types.Component
import Distribution.Types.Dependency
import Distribution.Types.PackageName
import Distribution.Types.PackageVersionConstraint
import Distribution.Types.UnqualComponentName
import Distribution.Types.CondTree
import Distribution.Types.Condition
import Distribution.Types.DependencyMap
import qualified Data.Map.Lazy as Map
import Data.Tree ( Tree(Node) )
import qualified Distribution.Types.PackageDescription.Lens as L
import qualified Distribution.Types.SetupBuildInfo.Lens as L
import Distribution.Compat.CharParsing hiding (char)
import qualified Distribution.Compat.CharParsing as P
import Distribution.Compat.Lens
import Distribution.Compiler
import Distribution.PackageDescription
import Distribution.PackageDescription.Utils
import Distribution.Parsec
import Distribution.Pretty
import Distribution.Simple.Utils
import Distribution.System
import Distribution.Types.Component
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.DependencyMap
import Distribution.Types.PackageVersionConstraint
import Distribution.Version
import qualified Data.Map.Lazy as Map
import Data.Tree (Tree (Node))
------------------------------------------------------------------------------
......@@ -127,7 +121,7 @@ parseCondition = condOr
flagIdent = fmap (PackageFlag . mkFlagName . lowercase) (munch1 isIdentChar)
isIdentChar c = isAlphaNum c || c == '_' || c == '-'
oper s = sp >> string s >> sp
sp = spaces
sp = spaces
implIdent = do i <- parsec
vr <- sp >> option anyVersion parsec
return $ Impl i vr
......
......@@ -63,16 +63,8 @@ import Distribution.Package
import Distribution.PackageDescription
import Distribution.Parsec
import Distribution.Pretty (prettyShow)
import Distribution.Types.ExecutableScope
import Distribution.Types.ExeDependency (ExeDependency)
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibOption (ForeignLibOption)
import Distribution.Types.ForeignLibType
import Distribution.Types.LegacyExeDependency (LegacyExeDependency)
import Distribution.Types.LibraryVisibility (LibraryVisibility (..))
import Distribution.Types.ModuleReexport
import Distribution.Types.Mixin (Mixin)
import Distribution.Types.PkgconfigDependency (PkgconfigDependency)
import Distribution.Types.UnqualComponentName
import Distribution.Version (Version, VersionRange)
import qualified Distribution.SPDX as SPDX
......
......@@ -56,13 +56,6 @@ import Distribution.Parsec.Position (Position (..), zeroPos)
import Distribution.Parsec.Warning (PWarnType (..))
import Distribution.Pretty (prettyShow)
import Distribution.Simple.Utils (fromUTF8BS, toUTF8BS)
import Distribution.Types.CondTree
import Distribution.Types.Dependency (Dependency)
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibType (knownForeignLibTypes)
import Distribution.Types.GenericPackageDescription (emptyGenericPackageDescription)
import Distribution.Types.LibraryVisibility (LibraryVisibility (..))
import Distribution.Types.UnqualComponentName (UnqualComponentName, mkUnqualComponentName)
import Distribution.Utils.Generic (breakMaybe, unfoldrM, validateUTF8)
import Distribution.Verbosity (Verbosity)
import Distribution.Version (Version, mkVersion, versionNumbers)
......
......@@ -31,12 +31,6 @@ module Distribution.PackageDescription.PrettyPrint (
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Types.CondTree
import Distribution.Types.Dependency
import Distribution.Types.ForeignLib (ForeignLib (foreignLibName))
import Distribution.Types.LibraryName
import Distribution.Types.UnqualComponentName
import Distribution.CabalSpecVersion
import Distribution.Fields.Pretty
import Distribution.PackageDescription
......@@ -45,9 +39,8 @@ import Distribution.Simple.Utils
import Distribution.FieldGrammar (PrettyFieldGrammar', prettyFieldGrammar)
import Distribution.PackageDescription.FieldGrammar
(benchmarkFieldGrammar, buildInfoFieldGrammar, executableFieldGrammar, flagFieldGrammar,
foreignLibFieldGrammar, libraryFieldGrammar, packageDescriptionFieldGrammar,
setupBInfoFieldGrammar, sourceRepoFieldGrammar, testSuiteFieldGrammar)
(benchmarkFieldGrammar, buildInfoFieldGrammar, executableFieldGrammar, flagFieldGrammar, foreignLibFieldGrammar, libraryFieldGrammar,
packageDescriptionFieldGrammar, setupBInfoFieldGrammar, sourceRepoFieldGrammar, testSuiteFieldGrammar)
import qualified Distribution.PackageDescription.FieldGrammar as FG
......
......@@ -41,8 +41,8 @@ import Distribution.Types.LibraryVisibility
import Distribution.Types.LocalBuildInfo
import Distribution.Types.MungedPackageId
import Distribution.Types.MungedPackageName
import Distribution.Types.ModuleRenaming
import Distribution.Types.TargetInfo
import Distribution.Types.UnqualComponentName
import Distribution.Package
import Distribution.Backpack
......
......@@ -34,8 +34,6 @@ import Distribution.Simple.Program.Db
import Distribution.Simple.Program.Types
import Distribution.Types.MungedPackageId
import Distribution.Types.MungedPackageName
import Distribution.Types.PackageId
import Distribution.Types.PackageName (unPackageName)
import Distribution.Pretty
import qualified Distribution.Simple.Build.Macros.Z as Z
......
......@@ -43,8 +43,6 @@ module Distribution.Simple.BuildPaths (
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Types.ForeignLib
import Distribution.Types.UnqualComponentName (unUnqualComponentName)
import Distribution.Package
import Distribution.ModuleName as ModuleName
import Distribution.Compiler
......
......@@ -12,9 +12,6 @@ import qualified Data.Map as Map
import Distribution.Package
import Distribution.PackageDescription
import Distribution.Types.ExeDependency
import Distribution.Types.LegacyExeDependency
import Distribution.Types.UnqualComponentName
-- | Desugar a "build-tools" entry into proper a executable dependency if
-- possible.
......
......@@ -68,7 +68,6 @@ import Distribution.InstalledPackageInfo (InstalledPackageInfo)
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.PackageIndex (InstalledPackageIndex)
import Distribution.PackageDescription
import Distribution.Types.PackageDescription
import Distribution.PackageDescription.PrettyPrint
import Distribution.PackageDescription.Configuration
import Distribution.PackageDescription.Check hiding (doesFileExist)
......@@ -77,22 +76,13 @@ import Distribution.Simple.Program
import Distribution.Simple.Setup as Setup
import Distribution.Simple.BuildTarget
import Distribution.Simple.LocalBuildInfo
import Distribution.Types.ExeDependency
import Distribution.Types.LegacyExeDependency
import Distribution.Types.PackageVersionConstraint
import Distribution.Types.PkgconfigVersion
import Distribution.Types.PkgconfigDependency
import Distribution.Types.PkgconfigVersionRange
import Distribution.Types.LocalBuildInfo
import Distribution.Types.LibraryName
import Distribution.Types.LibraryVisibility
import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibType
import Distribution.Types.ForeignLibOption
import Distribution.Types.GivenComponent
import Distribution.Types.Mixin
import Distribution.Types.UnqualComponentName
import Distribution.Simple.Utils
import Distribution.System
import Distribution.Version
......
......@@ -104,10 +104,6 @@ import Distribution.Version
import Distribution.System
import Distribution.Verbosity
import Distribution.Pretty
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibType
import Distribution.Types.ForeignLibOption
import Distribution.Types.UnqualComponentName
import Distribution.Utils.NubList
import Language.Haskell.Extension
......
......@@ -63,6 +63,7 @@ import Distribution.Simple.LocalBuildInfo
import Distribution.Types.UnitId
import Distribution.Types.LocalBuildInfo
import Distribution.Types.TargetInfo
import Distribution.Types.ModuleRenaming
import Distribution.Simple.Utils
import Distribution.Simple.BuildPaths
import Distribution.System
......
......@@ -69,10 +69,6 @@ import Distribution.Version
import Distribution.System
import Distribution.Verbosity
import Distribution.Pretty
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibType
import Distribution.Types.ForeignLibOption
import Distribution.Types.UnqualComponentName
import Distribution.Utils.NubList
import Control.Monad (msum)
......
......@@ -53,9 +53,6 @@ import Distribution.System
import Distribution.Pretty
import Distribution.Version
import Distribution.Verbosity
import Distribution.Types.ForeignLib
import Distribution.Types.LibraryName
import Distribution.Types.UnqualComponentName
import System.Directory (doesFileExist)
import System.Info (os, arch)
......
......@@ -36,6 +36,7 @@ import Distribution.Simple.Program.Run
import Distribution.System
import Distribution.Pretty
import Distribution.Types.ComponentId
import Distribution.Types.ModuleRenaming
import Distribution.Verbosity
import Distribution.Version
import Distribution.Utils.NubList
......
......@@ -99,12 +99,9 @@ import Distribution.Simple.InstallDirs
import Distribution.Verbosity
import Distribution.Utils.NubList
import Distribution.Types.ComponentId
import Distribution.Types.Flag
import Distribution.Types.GivenComponent
import Distribution.Types.Module
import Distribution.Types.PackageName
import Distribution.Types.PackageVersionConstraint
import Distribution.Types.UnqualComponentName (unUnqualComponentName)
import Distribution.Compat.Stack
import Distribution.Compat.Semigroup (Last' (..), Option' (..))
......
......@@ -61,7 +61,6 @@ import Distribution.Simple.PreProcess
import Distribution.Simple.BuildPaths
import Distribution.Simple.Program
import Distribution.Pretty
import Distribution.Types.ForeignLib
import Distribution.Verbosity
import qualified Data.Map as Map
......
......@@ -19,8 +19,8 @@ import Distribution.Types.MungedPackageId
import Distribution.Types.UnitId
import Distribution.Types.ComponentName
import Distribution.Types.MungedPackageName
import Distribution.Types.ModuleRenaming
import Distribution.PackageDescription
import qualified Distribution.InstalledPackageInfo as Installed
-- | The first five fields are common across all algebraic variants.
......
......@@ -26,6 +26,7 @@ import Distribution.ModuleName (ModuleName)
import Distribution.License (License)
import qualified Distribution.InstalledPackageInfo as Installed
import qualified Distribution.PackageDescription as Source
import qualified Distribution.Types.ModuleReexport as Source
import Distribution.PackageDescription
( PackageFlag(..), unFlagName )
import Distribution.PackageDescription.Configuration
......
......@@ -41,7 +41,8 @@ import Distribution.Package
import Distribution.PackageDescription
( GenericPackageDescription(packageDescription)
, PackageDescription(..), specVersion, buildType
, BuildType(..), defaultRenaming )
, BuildType(..) )
import Distribution.Types.ModuleRenaming (defaultRenaming)
import Distribution.PackageDescription.Parsec
( readGenericPackageDescription )
import Distribution.Simple.Configure
......
......@@ -25,8 +25,6 @@ import Distribution.PackageDescription -- from Cabal
import Distribution.PackageDescription.Configuration
import qualified Distribution.Simple.PackageIndex as SI
import Distribution.System
import Distribution.Types.ForeignLib
import Distribution.Types.LibraryVisibility
import Distribution.Solver.Types.ComponentDeps
( Component(..), componentNameToComponent )
......@@ -265,7 +263,7 @@ testConditionForComponent :: OS
-> CondTree ConfVar [Dependency] a
-> Maybe Bool
testConditionForComponent os arch cinfo constraints p tree =
case simplifyCondition $ extractCondition p tree of
case go $ extractCondition p tree of
Lit True -> Just True
Lit False -> Just False
_ -> Nothing
......@@ -279,10 +277,10 @@ testConditionForComponent os arch cinfo constraints p tree =
-- Simplify the condition, using the current environment. Most of this
-- function was copied from convBranch and
-- Distribution.Types.Condition.simplifyCondition.
simplifyCondition :: Condition ConfVar -> Condition ConfVar
simplifyCondition (Var (OS os')) = Lit (os == os')
simplifyCondition (Var (Arch arch')) = Lit (arch == arch')
simplifyCondition (Var (Impl cf cvr))
go :: Condition ConfVar -> Condition ConfVar
go (Var (OS os')) = Lit (os == os')