From d6831f7392f08dc206b5f1c0fa5f391142762085 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Wed, 14 Feb 2018 22:40:25 +0000 Subject: [PATCH] Revert "Merge pull request #4383 from Ericson2314/no-legacy-build-depends" This reverts commit ea75854567ad41073cac039b244a55f4e4e0ff60, reversing changes made to 602dfdcda54476ef182a8acdc4673c7e840da92f. See #5119 for the reason for reverting this. --- Cabal/Distribution/PackageDescription.hs | 2 - .../Distribution/PackageDescription/Check.hs | 8 +- .../PackageDescription/Configuration.hs | 78 +++++++++++-------- .../PackageDescription/FieldGrammar.hs | 1 + Cabal/Distribution/Simple/Build.hs | 1 + Cabal/Distribution/Simple/Configure.hs | 15 +++- Cabal/Distribution/Types/BuildInfo.hs | 4 +- .../Distribution/Types/PackageDescription.hs | 27 ++++--- .../Types/PackageDescription/Lens.hs | 5 ++ Cabal/changelog | 4 - .../ParserTests/regressions/Octree-0.5.expr | 1 + .../tests/ParserTests/regressions/common.expr | 1 + .../ParserTests/regressions/common2.expr | 1 + Cabal/tests/ParserTests/regressions/elif.expr | 1 + .../tests/ParserTests/regressions/elif2.expr | 1 + .../ParserTests/regressions/encoding-0.8.expr | 1 + .../ParserTests/regressions/generics-sop.expr | 1 + .../haddock-api-2.18.1-check.check | 2 +- .../ParserTests/regressions/issue-5055.expr | 1 + .../ParserTests/regressions/issue-774.expr | 1 + .../regressions/leading-comma.expr | 1 + .../regressions/nothing-unicode.expr | 1 + .../tests/ParserTests/regressions/shake.expr | 1 + .../regressions/th-lift-instances.expr | 1 + .../regressions/wl-pprint-indef.expr | 1 + .../Distribution/Client/Dependency.hs | 16 ++-- .../Distribution/Client/GenBounds.hs | 4 +- cabal-install/Distribution/Client/List.hs | 2 +- cabal-install/Distribution/Client/Outdated.hs | 7 +- .../Distribution/Client/PackageUtils.hs | 8 +- .../Backpack/Includes2/cabal-internal.out | 2 - .../BuildTools/Internal/cabal.out | 1 - .../TestSuiteTests/ExeV10/cabal.out | 2 - 33 files changed, 116 insertions(+), 87 deletions(-) diff --git a/Cabal/Distribution/PackageDescription.hs b/Cabal/Distribution/PackageDescription.hs index bd3f8141f97..4085278e6c7 100644 --- a/Cabal/Distribution/PackageDescription.hs +++ b/Cabal/Distribution/PackageDescription.hs @@ -83,8 +83,6 @@ module Distribution.PackageDescription ( hcStaticOptions, -- ** Supplementary build information - allBuildDepends, - enabledBuildDepends, ComponentName(..), defaultLibName, HookedBuildInfo, diff --git a/Cabal/Distribution/PackageDescription/Check.hs b/Cabal/Distribution/PackageDescription/Check.hs index e3d27e4acef..25615b274aa 100644 --- a/Cabal/Distribution/PackageDescription/Check.hs +++ b/Cabal/Distribution/PackageDescription/Check.hs @@ -1363,7 +1363,7 @@ checkCabalVersion pkg = _ -> False versionRangeExpressions = - [ dep | dep@(Dependency _ vr) <- allBuildDepends pkg + [ dep | dep@(Dependency _ vr) <- buildDepends pkg , usesNewVersionRangeSyntax vr ] testedWithVersionRangeExpressions = @@ -1391,10 +1391,10 @@ checkCabalVersion pkg = alg (VersionRangeParensF _) = 3 alg _ = 1 :: Int - depsUsingWildcardSyntax = [ dep | dep@(Dependency _ vr) <- allBuildDepends pkg + depsUsingWildcardSyntax = [ dep | dep@(Dependency _ vr) <- buildDepends pkg , usesWildcardSyntax vr ] - depsUsingMajorBoundSyntax = [ dep | dep@(Dependency _ vr) <- allBuildDepends pkg + depsUsingMajorBoundSyntax = [ dep | dep@(Dependency _ vr) <- buildDepends pkg , usesMajorBoundSyntax vr ] usesBackpackIncludes = any (not . null . mixins) (allBuildInfo pkg) @@ -1541,7 +1541,7 @@ checkPackageVersions pkg = foldr intersectVersionRanges anyVersion baseDeps where baseDeps = - [ vr | Dependency pname vr <- allBuildDepends pkg' + [ vr | Dependency pname vr <- buildDepends pkg' , pname == mkPackageName "base" ] -- Just in case finalizePD fails for any reason, diff --git a/Cabal/Distribution/PackageDescription/Configuration.hs b/Cabal/Distribution/PackageDescription/Configuration.hs index e97d9dad04f..64771037612 100644 --- a/Cabal/Distribution/PackageDescription/Configuration.hs +++ b/Cabal/Distribution/PackageDescription/Configuration.hs @@ -44,10 +44,8 @@ import Distribution.Compiler import Distribution.System import Distribution.Simple.Utils import Distribution.Text -import Distribution.Compat.Lens import Distribution.Compat.ReadP as ReadP hiding ( char ) import qualified Distribution.Compat.ReadP as ReadP ( char ) -import qualified Distribution.Types.BuildInfo.Lens as L import Distribution.Types.ComponentRequestedSpec import Distribution.Types.ForeignLib import Distribution.Types.Component @@ -353,18 +351,18 @@ overallDependencies enabled (TargetSet targets) = mconcat depss -- | Collect up the targets in a TargetSet of tagged targets, storing the -- dependencies as we go. flattenTaggedTargets :: TargetSet PDTagged -> (Maybe Library, [(UnqualComponentName, Component)]) -flattenTaggedTargets (TargetSet targets) = foldr untag (Nothing, []) targets where - untag (depMap, pdTagged) accum = case (pdTagged, accum) of - (Lib _, (Just _, _)) -> userBug "Only one library expected" - (Lib l, (Nothing, comps)) -> (Just $ redoBD l, comps) - (SubComp n c, (mb_lib, comps)) - | any ((== n) . fst) comps -> - userBug $ "There exist several components with the same name: '" ++ display n ++ "'" - | otherwise -> (mb_lib, (n, redoBD c) : comps) - (PDNull, x) -> x -- actually this should not happen, but let's be liberal - where - redoBD :: L.HasBuildInfo a => a -> a - redoBD = set L.targetBuildDepends $ fromDepMap depMap +flattenTaggedTargets (TargetSet targets) = foldr untag (Nothing, []) targets + where + untag (_, Lib _) (Just _, _) = userBug "Only one library expected" + untag (_, Lib l) (Nothing, comps) = (Just l, comps) + untag (_, SubComp n c) (mb_lib, comps) + | any ((== n) . fst) comps = + userBug $ "There exist several components with the same name: '" ++ unUnqualComponentName n ++ "'" + + | otherwise = (mb_lib, (n, c) : comps) + + untag (_, PDNull) x = x -- actually this should not happen, but let's be liberal + ------------------------------------------------------------------------------ -- Convert GenericPackageDescription to PackageDescription @@ -449,6 +447,7 @@ finalizePD userflags enabled satisfyDep , executables = exes' , testSuites = tests' , benchmarks = bms' + , buildDepends = fromDepMap (overallDependencies enabled targetSet) } , flagVals ) where @@ -518,25 +517,38 @@ flattenPackageDescription , executables = reverse exes , testSuites = reverse tests , benchmarks = reverse bms + , buildDepends = ldeps + ++ reverse sub_ldeps + ++ reverse pldeps + ++ reverse edeps + ++ reverse tdeps + ++ reverse bdeps } where - mlib = f <$> mlib0 - where f lib = (libFillInDefaults . fst . ignoreConditions $ lib) { libName = Nothing } - sub_libs = flattenLib <$> sub_libs0 - flibs = flattenFLib <$> flibs0 - exes = flattenExe <$> exes0 - tests = flattenTst <$> tests0 - bms = flattenBm <$> bms0 - flattenLib (n, t) = libFillInDefaults $ (fst $ ignoreConditions t) - { libName = Just n, libExposed = False } - flattenFLib (n, t) = flibFillInDefaults $ (fst $ ignoreConditions t) - { foreignLibName = n } - flattenExe (n, t) = exeFillInDefaults $ (fst $ ignoreConditions t) - { exeName = n } - flattenTst (n, t) = testFillInDefaults $ (fst $ ignoreConditions t) - { testName = n } - flattenBm (n, t) = benchFillInDefaults $ (fst $ ignoreConditions t) - { benchmarkName = n } + (mlib, ldeps) = case mlib0 of + Just lib -> let (l,ds) = ignoreConditions lib in + (Just ((libFillInDefaults l) { libName = Nothing }), ds) + Nothing -> (Nothing, []) + (sub_libs, sub_ldeps) = foldr flattenLib ([],[]) sub_libs0 + (flibs, pldeps) = foldr flattenFLib ([],[]) flibs0 + (exes, edeps) = foldr flattenExe ([],[]) exes0 + (tests, tdeps) = foldr flattenTst ([],[]) tests0 + (bms, bdeps) = foldr flattenBm ([],[]) bms0 + flattenLib (n, t) (es, ds) = + let (e, ds') = ignoreConditions t in + ( (libFillInDefaults $ e { libName = Just n, libExposed = False }) : es, ds' ++ ds ) + flattenFLib (n, t) (es, ds) = + let (e, ds') = ignoreConditions t in + ( (flibFillInDefaults $ e { foreignLibName = n }) : es, ds' ++ ds ) + flattenExe (n, t) (es, ds) = + let (e, ds') = ignoreConditions t in + ( (exeFillInDefaults $ e { exeName = n }) : es, ds' ++ ds ) + flattenTst (n, t) (es, ds) = + let (e, ds') = ignoreConditions t in + ( (testFillInDefaults $ e { testName = n }) : es, ds' ++ ds ) + flattenBm (n, t) (es, ds) = + let (e, ds') = ignoreConditions t in + ( (benchFillInDefaults $ e { benchmarkName = n }) : es, ds' ++ ds ) -- This is in fact rather a hack. The original version just overrode the -- default values, however, when adding conditions we had to switch to a @@ -608,10 +620,12 @@ transformAllBuildDepends f gpd = gpd' where onBI bi = bi { targetBuildDepends = map f $ targetBuildDepends bi } onSBI stp = stp { setupDepends = map f $ setupDepends stp } + onPD pd = pd { buildDepends = map f $ buildDepends pd } + pd' = onPD $ packageDescription gpd gpd' = transformAllCondTrees id id id id (map f) . transformAllBuildInfos onBI onSBI - $ gpd + $ gpd { packageDescription = pd' } -- | Walk all 'CondTree's inside a 'GenericPackageDescription' and apply -- appropriate transformations to all nodes. Helper function used by diff --git a/Cabal/Distribution/PackageDescription/FieldGrammar.hs b/Cabal/Distribution/PackageDescription/FieldGrammar.hs index a6251a114ec..0032d59f1b5 100644 --- a/Cabal/Distribution/PackageDescription/FieldGrammar.hs +++ b/Cabal/Distribution/PackageDescription/FieldGrammar.hs @@ -87,6 +87,7 @@ packageDescriptionFieldGrammar = PackageDescription <*> optionalFieldDefAla "description" FreeText L.description "" <*> optionalFieldDefAla "category" FreeText L.category "" <*> prefixedFields "x-" L.customFieldsPD + <*> pure [] -- build-depends <*> optionalField "build-type" L.buildTypeRaw <*> pure Nothing -- custom-setup -- components diff --git a/Cabal/Distribution/Simple/Build.hs b/Cabal/Distribution/Simple/Build.hs index cbe766d315a..2521243551e 100644 --- a/Cabal/Distribution/Simple/Build.hs +++ b/Cabal/Distribution/Simple/Build.hs @@ -481,6 +481,7 @@ testSuiteLibV09AsLibAndExe pkg_descr } pkg = pkg_descr { package = (package pkg_descr) { pkgName = mkPackageName $ unMungedPackageName compat_name } + , buildDepends = targetBuildDepends $ testBuildInfo test , executables = [] , testSuites = [] , subLibraries = [lib] diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs index 69f8bacbfb4..285bcd5652f 100644 --- a/Cabal/Distribution/Simple/Configure.hs +++ b/Cabal/Distribution/Simple/Configure.hs @@ -474,6 +474,15 @@ configure (pkg_descr0, pbi) cfg = do debug verbosity $ "Finalized package description:\n" ++ showPackageDescription pkg_descr + -- NB: showPackageDescription does not display the AWFUL HACK GLOBAL + -- buildDepends, so we have to display it separately. See #2066 + -- Some day, we should eliminate this, so that + -- configureFinalizedPackage returns the set of overall dependencies + -- separately. Then 'configureDependencies' and + -- 'Distribution.PackageDescription.Check' need to be adjusted + -- accordingly. + debug verbosity $ "Finalized build-depends: " + ++ intercalate ", " (map display (buildDepends pkg_descr)) checkCompilerProblems verbosity comp pkg_descr enabled checkPackageProblems verbosity pkg_descr0 @@ -508,7 +517,6 @@ configure (pkg_descr0, pbi) cfg = do installedPackageSet requiredDepsMap pkg_descr - enabled -- Compute installation directory templates, based on user -- configuration. @@ -1014,15 +1022,14 @@ configureDependencies -> InstalledPackageIndex -- ^ installed packages -> Map PackageName InstalledPackageInfo -- ^ required deps -> PackageDescription - -> ComponentRequestedSpec -> IO [PreExistingComponent] configureDependencies verbosity use_external_internal_deps - internalPackageSet installedPackageSet requiredDepsMap pkg_descr enableSpec = do + internalPackageSet installedPackageSet requiredDepsMap pkg_descr = do let failedDeps :: [FailedDependency] allPkgDeps :: [ResolvedDependency] (failedDeps, allPkgDeps) = partitionEithers [ (\s -> (dep, s)) <$> status - | dep <- enabledBuildDepends pkg_descr enableSpec + | dep <- buildDepends pkg_descr , let status = selectDependency (package pkg_descr) internalPackageSet installedPackageSet requiredDepsMap use_external_internal_deps dep ] diff --git a/Cabal/Distribution/Types/BuildInfo.hs b/Cabal/Distribution/Types/BuildInfo.hs index 7685270d77f..92d2021f7cc 100644 --- a/Cabal/Distribution/Types/BuildInfo.hs +++ b/Cabal/Distribution/Types/BuildInfo.hs @@ -150,7 +150,7 @@ instance Monoid BuildInfo where staticOptions = [], customFieldsBI = [], targetBuildDepends = [], - mixins = [] + mixins = [] } mappend = (<>) @@ -196,7 +196,7 @@ instance Semigroup BuildInfo where staticOptions = combine staticOptions, customFieldsBI = combine customFieldsBI, targetBuildDepends = combineNub targetBuildDepends, - mixins = combine mixins + mixins = combine mixins } where combine field = field a `mappend` field b diff --git a/Cabal/Distribution/Types/PackageDescription.hs b/Cabal/Distribution/Types/PackageDescription.hs index 482093bfdba..b9dd51735c6 100644 --- a/Cabal/Distribution/Types/PackageDescription.hs +++ b/Cabal/Distribution/Types/PackageDescription.hs @@ -49,8 +49,6 @@ module Distribution.Types.PackageDescription ( withForeignLib, allBuildInfo, enabledBuildInfos, - allBuildDepends, - enabledBuildDepends, updatePackageDescription, pkgComponents, pkgBuildableComponents, @@ -62,8 +60,6 @@ module Distribution.Types.PackageDescription ( import Prelude () import Distribution.Compat.Prelude -import Control.Monad ((<=<)) - import Distribution.Types.Library import Distribution.Types.TestSuite import Distribution.Types.Executable @@ -128,6 +124,18 @@ data PackageDescription -- with x-, stored in a -- simple assoc-list. + -- | YOU PROBABLY DON'T WANT TO USE THIS FIELD. This field is + -- special! Depending on how far along processing the + -- 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 + -- '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 + -- 'BuildInfo' and this field. This is all horrible, and #2066 + -- tracks progress to get rid of this field. + buildDepends :: [Dependency], -- | The original @build-type@ value as parsed from the -- @.cabal@ file without defaulting. See also 'buildType'. -- @@ -239,6 +247,7 @@ emptyPackageDescription author = "", stability = "", testedWith = [], + buildDepends = [], homepage = "", pkgUrl = "", bugReports = "", @@ -383,16 +392,6 @@ enabledBuildInfos pkg enabled = -- * Utils -- ------------------------------------------------------------ --- | Get the combined build-depends entries of all components. -allBuildDepends :: PackageDescription -> [Dependency] -allBuildDepends = targetBuildDepends <=< allBuildInfo - --- | Get the combined build-depends entries of all enabled components, per the --- given request spec. -enabledBuildDepends :: PackageDescription -> ComponentRequestedSpec -> [Dependency] -enabledBuildDepends spec pd = targetBuildDepends =<< enabledBuildInfos spec pd - - updatePackageDescription :: HookedBuildInfo -> PackageDescription -> PackageDescription updatePackageDescription (mb_lib_bi, exe_bi) p = p{ executables = updateExecutables exe_bi (executables p) diff --git a/Cabal/Distribution/Types/PackageDescription/Lens.hs b/Cabal/Distribution/Types/PackageDescription/Lens.hs index e08dbc45848..6594b995337 100644 --- a/Cabal/Distribution/Types/PackageDescription/Lens.hs +++ b/Cabal/Distribution/Types/PackageDescription/Lens.hs @@ -11,6 +11,7 @@ import Distribution.Compiler (CompilerFlavor) import Distribution.License (License) import Distribution.Types.Benchmark (Benchmark) import Distribution.Types.BuildType (BuildType) +import Distribution.Types.Dependency (Dependency) import Distribution.Types.Executable (Executable) import Distribution.Types.ForeignLib (ForeignLib) import Distribution.Types.Library (Library) @@ -88,6 +89,10 @@ customFieldsPD :: Lens' PackageDescription [(String,String)] customFieldsPD f s = fmap (\x -> s { T.customFieldsPD = x }) (f (T.customFieldsPD s)) {-# INLINE customFieldsPD #-} +buildDepends :: Lens' PackageDescription [Dependency] +buildDepends f s = fmap (\x -> s { T.buildDepends = x }) (f (T.buildDepends s)) +{-# INLINE buildDepends #-} + specVersionRaw :: Lens' PackageDescription (Either Version VersionRange) specVersionRaw f s = fmap (\x -> s { T.specVersionRaw = x }) (f (T.specVersionRaw s)) {-# INLINE specVersionRaw #-} diff --git a/Cabal/changelog b/Cabal/changelog index e74bbab5f55..13a4916bbcf 100644 --- a/Cabal/changelog +++ b/Cabal/changelog @@ -52,10 +52,6 @@ * Pretty-printing of .cabal files is slightly different due to parser changes. For an example, see https://mail.haskell.org/pipermail/cabal-devel/2017-December/010414.html. - * `buildDepends` is removed from `PackageDescription`. It had long been - uselessly hanging about as top-level build-depends already got put - into per-component condition trees anyway. Now it's finally been put - out of its misery. * `--hyperlink-source` now uses Haddock's hyperlinker backend when Haddock is new enough, falling back to HsColour otherwise. * `D.S.defaultHookedPackageDesc` has been deprecated in favour of diff --git a/Cabal/tests/ParserTests/regressions/Octree-0.5.expr b/Cabal/tests/ParserTests/regressions/Octree-0.5.expr index 7c3b45ceb6d..1591c75da33 100644 --- a/Cabal/tests/ParserTests/regressions/Octree-0.5.expr +++ b/Cabal/tests/ParserTests/regressions/Octree-0.5.expr @@ -244,6 +244,7 @@ GenericPackageDescription {author = "Michal J. Gajda", benchmarks = [], bugReports = "mailto:mjgajda@googlemail.com", + buildDepends = [], buildTypeRaw = Just Simple, category = "Data", copyright = "Copyright by Michal J. Gajda '2012", diff --git a/Cabal/tests/ParserTests/regressions/common.expr b/Cabal/tests/ParserTests/regressions/common.expr index 01b7ad3662d..9341df23fd1 100644 --- a/Cabal/tests/ParserTests/regressions/common.expr +++ b/Cabal/tests/ParserTests/regressions/common.expr @@ -117,6 +117,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/common2.expr b/Cabal/tests/ParserTests/regressions/common2.expr index d8fe2546acd..bb88b428704 100644 --- a/Cabal/tests/ParserTests/regressions/common2.expr +++ b/Cabal/tests/ParserTests/regressions/common2.expr @@ -373,6 +373,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/elif.expr b/Cabal/tests/ParserTests/regressions/elif.expr index ae39c7d3e0d..09e8d6f7049 100644 --- a/Cabal/tests/ParserTests/regressions/elif.expr +++ b/Cabal/tests/ParserTests/regressions/elif.expr @@ -118,6 +118,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/elif2.expr b/Cabal/tests/ParserTests/regressions/elif2.expr index 19511897387..a76f5cf3d6b 100644 --- a/Cabal/tests/ParserTests/regressions/elif2.expr +++ b/Cabal/tests/ParserTests/regressions/elif2.expr @@ -277,6 +277,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/encoding-0.8.expr b/Cabal/tests/ParserTests/regressions/encoding-0.8.expr index 889650974a3..76fe659803a 100644 --- a/Cabal/tests/ParserTests/regressions/encoding-0.8.expr +++ b/Cabal/tests/ParserTests/regressions/encoding-0.8.expr @@ -79,6 +79,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Nothing, category = "", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/generics-sop.expr b/Cabal/tests/ParserTests/regressions/generics-sop.expr index f99eaedd497..a26d2bfbe5c 100644 --- a/Cabal/tests/ParserTests/regressions/generics-sop.expr +++ b/Cabal/tests/ParserTests/regressions/generics-sop.expr @@ -554,6 +554,7 @@ GenericPackageDescription {author = "Edsko de Vries , Andres L\246h ", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Custom, category = "Generics", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/haddock-api-2.18.1-check.check b/Cabal/tests/ParserTests/regressions/haddock-api-2.18.1-check.check index c95a5ebc74a..b9d2e11cbcb 100644 --- a/Cabal/tests/ParserTests/regressions/haddock-api-2.18.1-check.check +++ b/Cabal/tests/ParserTests/regressions/haddock-api-2.18.1-check.check @@ -1,2 +1,2 @@ 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit and not just imposing longer compile times on your users. -The package uses major bounded version syntax in the 'build-depends' field: base ^>=4.10.0, Cabal ^>=2.0.0, ghc ^>=8.2, ghc-paths ^>=0.1.0.9, xhtml ^>=3000.2.2, ghc ^>=8.2, hspec ^>=2.4.4, QuickCheck ^>=2.10. To use this new syntax the package need to specify at least 'cabal-version: >= 2.0'. Alternatively, if broader compatibility is important then use: base >=4.10.0 && <4.11, Cabal >=2.0.0 && <2.1, ghc >=8.2 && <8.3, ghc-paths >=0.1.0.9 && <0.2, xhtml >=3000.2.2 && <3000.3, ghc >=8.2 && <8.3, hspec >=2.4.4 && <2.5, QuickCheck >=2.10 && <2.11 +The package uses major bounded version syntax in the 'build-depends' field: base ^>=4.10.0, Cabal ^>=2.0.0, ghc ^>=8.2, ghc-paths ^>=0.1.0.9, xhtml ^>=3000.2.2, QuickCheck ^>=2.10, hspec ^>=2.4.4, ghc ^>=8.2. To use this new syntax the package need to specify at least 'cabal-version: >= 2.0'. Alternatively, if broader compatibility is important then use: base >=4.10.0 && <4.11, Cabal >=2.0.0 && <2.1, ghc >=8.2 && <8.3, ghc-paths >=0.1.0.9 && <0.2, xhtml >=3000.2.2 && <3000.3, QuickCheck >=2.10 && <2.11, hspec >=2.4.4 && <2.5, ghc >=8.2 && <8.3 diff --git a/Cabal/tests/ParserTests/regressions/issue-5055.expr b/Cabal/tests/ParserTests/regressions/issue-5055.expr index c7ce614e390..a1e234adc4e 100644 --- a/Cabal/tests/ParserTests/regressions/issue-5055.expr +++ b/Cabal/tests/ParserTests/regressions/issue-5055.expr @@ -183,6 +183,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "Test", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/issue-774.expr b/Cabal/tests/ParserTests/regressions/issue-774.expr index 5cda458c27c..29380faadb4 100644 --- a/Cabal/tests/ParserTests/regressions/issue-774.expr +++ b/Cabal/tests/ParserTests/regressions/issue-774.expr @@ -66,6 +66,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/leading-comma.expr b/Cabal/tests/ParserTests/regressions/leading-comma.expr index 4b9b892a420..71644e8cd67 100644 --- a/Cabal/tests/ParserTests/regressions/leading-comma.expr +++ b/Cabal/tests/ParserTests/regressions/leading-comma.expr @@ -83,6 +83,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/nothing-unicode.expr b/Cabal/tests/ParserTests/regressions/nothing-unicode.expr index 3fd9b4820df..6a544a5dcf8 100644 --- a/Cabal/tests/ParserTests/regressions/nothing-unicode.expr +++ b/Cabal/tests/ParserTests/regressions/nothing-unicode.expr @@ -118,6 +118,7 @@ GenericPackageDescription {author = "", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "", copyright = "", diff --git a/Cabal/tests/ParserTests/regressions/shake.expr b/Cabal/tests/ParserTests/regressions/shake.expr index a3efa683b6e..b0927b70025 100644 --- a/Cabal/tests/ParserTests/regressions/shake.expr +++ b/Cabal/tests/ParserTests/regressions/shake.expr @@ -1630,6 +1630,7 @@ GenericPackageDescription {author = "Neil Mitchell ", benchmarks = [], bugReports = "https://github.com/ndmitchell/shake/issues", + buildDepends = [], buildTypeRaw = Just Simple, category = "Development, Shake", copyright = "Neil Mitchell 2011-2017", diff --git a/Cabal/tests/ParserTests/regressions/th-lift-instances.expr b/Cabal/tests/ParserTests/regressions/th-lift-instances.expr index 0621e9c3ef0..273ad24bea8 100644 --- a/Cabal/tests/ParserTests/regressions/th-lift-instances.expr +++ b/Cabal/tests/ParserTests/regressions/th-lift-instances.expr @@ -386,6 +386,7 @@ GenericPackageDescription {author = "Benno F\252nfst\252ck", benchmarks = [], bugReports = "http://github.com/bennofs/th-lift-instances/issues", + buildDepends = [], buildTypeRaw = Just Custom, category = "Template Haskell", copyright = "Copyright (C) 2013-2014 Benno F\252nfst\252ck", diff --git a/Cabal/tests/ParserTests/regressions/wl-pprint-indef.expr b/Cabal/tests/ParserTests/regressions/wl-pprint-indef.expr index 021191dcc38..37199283959 100644 --- a/Cabal/tests/ParserTests/regressions/wl-pprint-indef.expr +++ b/Cabal/tests/ParserTests/regressions/wl-pprint-indef.expr @@ -140,6 +140,7 @@ GenericPackageDescription {author = "Daan Leijen", benchmarks = [], bugReports = "", + buildDepends = [], buildTypeRaw = Just Simple, category = "Text", copyright = "", diff --git a/cabal-install/Distribution/Client/Dependency.hs b/cabal-install/Distribution/Client/Dependency.hs index f13777ab0b5..e3eff395779 100644 --- a/cabal-install/Distribution/Client/Dependency.hs +++ b/cabal-install/Distribution/Client/Dependency.hs @@ -930,24 +930,24 @@ configuredPackageProblems platform cinfo (sortNubOn dependencyName required) (sortNubOn packageName specified) - compSpec = enableStanzas stanzas -- TODO: It would be nicer to use ComponentDeps here so we can be more - -- precise in our checks. In fact, this no longer relies on buildDepends and - -- thus should be easier to fix. As long as we _do_ use a flat list here, we - -- have to allow for duplicates when we fold specifiedDeps; once we have - -- proper ComponentDeps here we should get rid of the `nubOn` in - -- `mergeDeps`. + -- precise in our checks. That's a bit tricky though, as this currently + -- relies on the 'buildDepends' field of 'PackageDescription'. (OTOH, that + -- field is deprecated and should be removed anyway.) As long as we _do_ + -- use a flat list here, we have to allow for duplicates when we fold + -- specifiedDeps; once we have proper ComponentDeps here we should get rid + -- of the `nubOn` in `mergeDeps`. requiredDeps :: [Dependency] requiredDeps = --TODO: use something lower level than finalizePD case finalizePD specifiedFlags - compSpec + (enableStanzas stanzas) (const True) platform cinfo [] (packageDescription pkg) of Right (resolvedPkg, _) -> - externalBuildDepends resolvedPkg compSpec + externalBuildDepends resolvedPkg ++ maybe [] PD.setupDepends (PD.setupBuildInfo resolvedPkg) Left _ -> error "configuredPackageInvalidDeps internal error" diff --git a/cabal-install/Distribution/Client/GenBounds.hs b/cabal-install/Distribution/Client/GenBounds.hs index 0f2727ad2fc..139e05b9dae 100644 --- a/cabal-install/Distribution/Client/GenBounds.hs +++ b/cabal-install/Distribution/Client/GenBounds.hs @@ -29,7 +29,7 @@ import Distribution.Client.Setup import Distribution.Package ( Package(..), unPackageName, packageName, packageVersion ) import Distribution.PackageDescription - ( enabledBuildDepends ) + ( buildDepends ) import Distribution.PackageDescription.Configuration ( finalizePD ) import Distribution.PackageDescription.Parsec @@ -122,7 +122,7 @@ genBounds verbosity packageDBs repoCtxt comp platform progdb mSandboxPkgInfo Left _ -> putStrLn "finalizePD failed" Right (pd,_) -> do let needBounds = filter (not . hasUpperBound . depVersion) $ - enabledBuildDepends pd defaultComponentRequestedSpec + buildDepends pd if (null needBounds) then putStrLn diff --git a/cabal-install/Distribution/Client/List.hs b/cabal-install/Distribution/Client/List.hs index 5a72ce7a709..65d43b6522c 100644 --- a/cabal-install/Distribution/Client/List.hs +++ b/cabal-install/Distribution/Client/List.hs @@ -470,7 +470,7 @@ mergePackageInfo versionPref installedPkgs sourcePkgs selectedPkg showVer = source, dependencies = combine (map (SourceDependency . simplifyDependency) - . Source.allBuildDepends) source + . Source.buildDepends) source (map InstalledDependency . Installed.depends) installed, haddockHtml = fromMaybe "" . join . fmap (listToMaybe . Installed.haddockHTMLs) diff --git a/cabal-install/Distribution/Client/Outdated.hs b/cabal-install/Distribution/Client/Outdated.hs index 8ec0d63bea9..9f0bcc0f2ff 100644 --- a/cabal-install/Distribution/Client/Outdated.hs +++ b/cabal-install/Distribution/Client/Outdated.hs @@ -27,8 +27,9 @@ import Distribution.Solver.Types.PackageConstraint import Distribution.Solver.Types.PackageIndex import Distribution.Client.Sandbox.PackageEnvironment -import Distribution.Package (PackageName, packageVersion) -import Distribution.PackageDescription (allBuildDepends) +import Distribution.Package (PackageName + ,packageVersion) +import Distribution.PackageDescription (buildDepends) import Distribution.PackageDescription.Configuration (finalizePD) import Distribution.Simple.Compiler (Compiler, compilerInfo) import Distribution.Simple.Setup (fromFlagOrDefault) @@ -151,7 +152,7 @@ depsFromPkgDesc verbosity comp platform = do case epd of Left _ -> die' verbosity "finalizePD failed" Right (pd, _) -> do - let bd = allBuildDepends pd + let bd = buildDepends pd debug verbosity "Reading the list of dependencies from the package description" return bd diff --git a/cabal-install/Distribution/Client/PackageUtils.hs b/cabal-install/Distribution/Client/PackageUtils.hs index b1236fb38b1..4f460997386 100644 --- a/cabal-install/Distribution/Client/PackageUtils.hs +++ b/cabal-install/Distribution/Client/PackageUtils.hs @@ -16,20 +16,18 @@ module Distribution.Client.PackageUtils ( import Distribution.Package ( packageVersion, packageName ) -import Distribution.Types.ComponentRequestedSpec - ( ComponentRequestedSpec ) import Distribution.Types.Dependency import Distribution.Types.UnqualComponentName import Distribution.PackageDescription - ( PackageDescription(..), libName, enabledBuildDepends ) + ( PackageDescription(..), libName ) import Distribution.Version ( withinRange, isAnyVersion ) -- | The list of dependencies that refer to external packages -- rather than internal package components. -- -externalBuildDepends :: PackageDescription -> ComponentRequestedSpec -> [Dependency] -externalBuildDepends pkg spec = filter (not . internal) (enabledBuildDepends pkg spec) +externalBuildDepends :: PackageDescription -> [Dependency] +externalBuildDepends pkg = filter (not . internal) (buildDepends pkg) where -- True if this dependency is an internal one (depends on a library -- defined in the same package). diff --git a/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out b/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out index 36f513582b2..412950ed677 100644 --- a/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out +++ b/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.out @@ -34,11 +34,9 @@ Building library 'mylib' instantiated with Database = Includes2-0.1.0.0-inplace-postgresql:Database.PostgreSQL for Includes2-0.1.0.0.. Configuring library for Includes2-0.1.0.0.. -Warning: The package has an extraneous version range for a dependency on an internal library: Includes2 -any && ==0.1.0.0 && ==0.1.0.0 && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used. Preprocessing library for Includes2-0.1.0.0.. Building library for Includes2-0.1.0.0.. Configuring executable 'exe' for Includes2-0.1.0.0.. -Warning: The package has an extraneous version range for a dependency on an internal library: Includes2 -any && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used. Preprocessing executable 'exe' for Includes2-0.1.0.0.. Building executable 'exe' for Includes2-0.1.0.0.. # Includes2 exe diff --git a/cabal-testsuite/PackageTests/BuildTools/Internal/cabal.out b/cabal-testsuite/PackageTests/BuildTools/Internal/cabal.out index 90464eb31d8..4486c7aab9b 100644 --- a/cabal-testsuite/PackageTests/BuildTools/Internal/cabal.out +++ b/cabal-testsuite/PackageTests/BuildTools/Internal/cabal.out @@ -12,6 +12,5 @@ Configuring library for foo-0.1.0.0.. Preprocessing library for foo-0.1.0.0.. Building library for foo-0.1.0.0.. Configuring executable 'hello-world' for foo-0.1.0.0.. -Warning: The package has an extraneous version range for a dependency on an internal library: foo -any && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used. Preprocessing executable 'hello-world' for foo-0.1.0.0.. Building executable 'hello-world' for foo-0.1.0.0.. diff --git a/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal.out b/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal.out index b1ccd8f66fc..a8318f25d53 100644 --- a/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal.out +++ b/cabal-testsuite/PackageTests/TestSuiteTests/ExeV10/cabal.out @@ -9,7 +9,6 @@ Configuring library for my-0.1.. Preprocessing library for my-0.1.. Building library for my-0.1.. Configuring test suite 'test-Short' for my-0.1.. -Warning: The package has an extraneous version range for a dependency on an internal library: my -any && ==0.1, my -any && ==0.1. This version range includes the current package but isn't needed as the current package's library will always be used. Preprocessing test suite 'test-Short' for my-0.1.. Building test suite 'test-Short' for my-0.1.. Running 1 test suites... @@ -18,7 +17,6 @@ Test suite test-Short: PASS Test suite logged to: /cabal.dist/work/./dist/build//ghc-/my-0.1/t/test-Short/test/my-0.1-test-Short.log 1 of 1 test suites (1 of 1 test cases) passed. Configuring test suite 'test-Foo' for my-0.1.. -Warning: The package has an extraneous version range for a dependency on an internal library: my -any && ==0.1, my -any && ==0.1. This version range includes the current package but isn't needed as the current package's library will always be used. Preprocessing test suite 'test-Foo' for my-0.1.. Building test suite 'test-Foo' for my-0.1.. Running 1 test suites...