From 7e5be401339f503483cac08da613cdb89e9ce20a Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Wed, 26 Jun 2024 17:13:18 +0200 Subject: [PATCH 1/7] Extend GPD with default-package-bounds --- Cabal-syntax/Cabal-syntax.cabal | 2 + Cabal-syntax/src/Distribution/Package.hs | 2 + .../src/Distribution/PackageDescription.hs | 2 + .../PackageDescription/FieldGrammar.hs | 21 +++++++ .../Distribution/PackageDescription/Parsec.hs | 8 ++- .../PackageDescription/PrettyPrint.hs | 1 + .../src/Distribution/Types/DefaultBounds.hs | 61 +++++++++++++++++++ .../Distribution/Types/DefaultBounds/Lens.hs | 26 ++++++++ .../src/Distribution/Types/ExeDependency.hs | 12 ++++ .../Types/GenericPackageDescription.hs | 6 +- .../Types/GenericPackageDescription/Lens.hs | 8 ++- Cabal-syntax/src/Distribution/Types/Lens.hs | 2 + 12 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 Cabal-syntax/src/Distribution/Types/DefaultBounds.hs create mode 100644 Cabal-syntax/src/Distribution/Types/DefaultBounds/Lens.hs diff --git a/Cabal-syntax/Cabal-syntax.cabal b/Cabal-syntax/Cabal-syntax.cabal index a1873228428..a34dc3b3342 100644 --- a/Cabal-syntax/Cabal-syntax.cabal +++ b/Cabal-syntax/Cabal-syntax.cabal @@ -134,6 +134,8 @@ library Distribution.Types.CondTree Distribution.Types.Condition Distribution.Types.ConfVar + Distribution.Types.DefaultBounds + Distribution.Types.DefaultBounds.Lens Distribution.Types.Dependency Distribution.Types.DependencyMap Distribution.Types.ExeDependency diff --git a/Cabal-syntax/src/Distribution/Package.hs b/Cabal-syntax/src/Distribution/Package.hs index c4f20349391..22088b81f43 100644 --- a/Cabal-syntax/src/Distribution/Package.hs +++ b/Cabal-syntax/src/Distribution/Package.hs @@ -25,6 +25,7 @@ module Distribution.Package , module Distribution.Types.PackageName , module Distribution.Types.PkgconfigName , module Distribution.Types.Dependency + , module Distribution.Types.DefaultBounds , Package (..) , packageName , packageVersion @@ -44,6 +45,7 @@ import Distribution.Version import Distribution.Types.AbiHash import Distribution.Types.ComponentId +import Distribution.Types.DefaultBounds import Distribution.Types.Dependency import Distribution.Types.Module import Distribution.Types.MungedPackageId diff --git a/Cabal-syntax/src/Distribution/PackageDescription.hs b/Cabal-syntax/src/Distribution/PackageDescription.hs index 47d46673e5f..0e972932d4f 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription.hs @@ -62,6 +62,7 @@ module Distribution.PackageDescription , module Distribution.Types.PkgconfigVersionRange -- * Dependencies + , module Distribution.Types.DefaultBounds , module Distribution.Types.Dependency , module Distribution.Types.ExeDependency , module Distribution.Types.LegacyExeDependency @@ -95,6 +96,7 @@ import Distribution.Types.ComponentName import Distribution.Types.CondTree import Distribution.Types.Condition import Distribution.Types.ConfVar +import Distribution.Types.DefaultBounds import Distribution.Types.Dependency import Distribution.Types.ExeDependency import Distribution.Types.Executable diff --git a/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs b/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs index 4d9ada935af..fd860283cb2 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs @@ -65,6 +65,9 @@ module Distribution.PackageDescription.FieldGrammar -- * Component build info , buildInfoFieldGrammar + + -- * default-package-bounds + , defaultPackageBoundsFieldGrammar ) where import Distribution.Compat.Lens @@ -807,6 +810,24 @@ setupBInfoFieldGrammar def = {-# SPECIALIZE setupBInfoFieldGrammar :: Bool -> ParsecFieldGrammar' SetupBuildInfo #-} {-# SPECIALIZE setupBInfoFieldGrammar :: Bool -> PrettyFieldGrammar' SetupBuildInfo #-} +------------------------------------------------------------------------------- +-- default-package-bounds +------------------------------------------------------------------------------- + +defaultPackageBoundsFieldGrammar + :: ( FieldGrammar c g + , Applicative (g DefaultBounds) + , c (List CommaVCat (Identity Dependency) Dependency) + , c (List CommaFSep (Identity ExeDependency) ExeDependency) + ) + => g DefaultBounds DefaultBounds +defaultPackageBoundsFieldGrammar = + DefaultBounds + <$> (monoidalFieldAla "build-depends" formatDependencyList L.defaultTargetBuildDepends) + <*> (monoidalFieldAla "build-tool-depends" (alaList CommaFSep) L.defaultBuildToolDepends) +{-# SPECIALIZE defaultPackageBoundsFieldGrammar :: ParsecFieldGrammar' DefaultBounds #-} +{-# SPECIALIZE defaultPackageBoundsFieldGrammar :: PrettyFieldGrammar' DefaultBounds #-} + ------------------------------------------------------------------------------- -- Define how field values should be formatted for 'pretty'. ------------------------------------------------------------------------------- diff --git a/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs b/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs index ae4c0cfec6b..692274dbf48 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs @@ -247,7 +247,7 @@ goSections specVer = traverse_ process process (Field (Name pos name) _) = lift $ parseWarning pos PWTTrailingFields $ - "Ignoring trailing fields after sections: " ++ show name + "Ignoring trailing fields after sections: " ++ show name ++ ". Consider moving these fields before any stanzas in your cabal file." process (Section name args secFields) = parseSection name args secFields @@ -395,6 +395,12 @@ goSections specVer = traverse_ process flag <- lift $ parseFields specVer fields (flagFieldGrammar name'') -- Check default flag stateGpd . L.genPackageFlags %= snoc flag + | name == "default-package-bounds" = + if specVer >= CabalSpecV3_14 + then do + sbi <- lift $ parseFields specVer fields defaultPackageBoundsFieldGrammar + stateGpd . L.genDefaultPackageBounds .= Just sbi + else lift $ parseWarning pos PWTUnknownSection $ "Ignoring section: default-package-bounds. You should set cabal-version: 3.14 or larger to use default-package-bounds." | name == "custom-setup" && null args = do sbi <- lift $ parseFields specVer fields (setupBInfoFieldGrammar False) stateGpd . L.packageDescription . L.setupBuildInfo ?= sbi diff --git a/Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs b/Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs index b03b1b99ada..7579886d0c9 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs @@ -231,6 +231,7 @@ pdToGpd pd = { packageDescription = pd , gpdScannedVersion = Nothing , genPackageFlags = [] + , genDefaultPackageBounds = Nothing , condLibrary = mkCondTree <$> library pd , condSubLibraries = mkCondTreeL <$> subLibraries pd , condForeignLibs = mkCondTree' foreignLibName <$> foreignLibs pd diff --git a/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs b/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs new file mode 100644 index 00000000000..d9e95d70727 --- /dev/null +++ b/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs @@ -0,0 +1,61 @@ +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE DeriveGeneric #-} + +module Distribution.Types.DefaultBounds + ( DefaultBounds (..) + , applyDefaultBoundsToBuildInfo + , applyDefaultBoundsToDependencies + , applyDefaultBoundsToExeDependencies + , applyDefaultBoundsToCondTree + ) where + +import Distribution.Compat.Lens +import Distribution.Compat.Prelude + +import qualified Distribution.Types.BuildInfo.Lens as L +import Distribution.Types.CondTree +import Distribution.Types.Dependency +import Distribution.Types.ExeDependency +import Distribution.Types.VersionRange + +data DefaultBounds = DefaultBounds + { defaultTargetBuildDepends :: [Dependency] + , defaultBuildToolDepends :: [ExeDependency] + } + deriving (Generic, Read, Show, Eq, Data, Typeable) + +instance Binary DefaultBounds +instance Structured DefaultBounds +instance NFData DefaultBounds where rnf = genericRnf + +applyDefaultBoundsToCondTree + :: L.HasBuildInfo a + => DefaultBounds + -> CondTree cv [Dependency] a + -> CondTree cv [Dependency] a +applyDefaultBoundsToCondTree db = + mapTreeData (applyDefaultBoundsToBuildInfo db) . mapTreeConstrs (applyDefaultBoundsToDependencies db) + +applyDefaultBoundsToBuildInfo :: L.HasBuildInfo a => DefaultBounds -> a -> a +applyDefaultBoundsToBuildInfo db bi = + bi + & L.targetBuildDepends %~ applyDefaultBoundsToDependencies db + & L.buildToolDepends %~ applyDefaultBoundsToExeDependencies db + +applyDefaultBoundsToDependencies :: DefaultBounds -> [Dependency] -> [Dependency] +applyDefaultBoundsToDependencies (DefaultBounds bd _) = + map + ( \dep@(Dependency pkg vorig l) -> + if isAnyVersion vorig + then maybe dep (\v -> Dependency pkg (depVerRange v) l) $ find ((pkg ==) . depPkgName) bd + else dep + ) + +applyDefaultBoundsToExeDependencies :: DefaultBounds -> [ExeDependency] -> [ExeDependency] +applyDefaultBoundsToExeDependencies (DefaultBounds _ btd) = + map + ( \dep@(ExeDependency pkg comp vorig) -> + if isAnyVersion vorig + then maybe dep (ExeDependency pkg comp . exeDepVerRange) $ find (\(ExeDependency pkg' comp' _) -> pkg == pkg' && comp == comp') btd + else dep + ) diff --git a/Cabal-syntax/src/Distribution/Types/DefaultBounds/Lens.hs b/Cabal-syntax/src/Distribution/Types/DefaultBounds/Lens.hs new file mode 100644 index 00000000000..5cfeaf2aa94 --- /dev/null +++ b/Cabal-syntax/src/Distribution/Types/DefaultBounds/Lens.hs @@ -0,0 +1,26 @@ +module Distribution.Types.DefaultBounds.Lens + ( DefaultBounds + , module Distribution.Types.DefaultBounds.Lens + ) where + +import Distribution.Compat.Lens +import Distribution.Compat.Prelude +import Prelude () + +import qualified Distribution.Types.DefaultBounds as T + +import Distribution.Types.DefaultBounds (DefaultBounds) +import Distribution.Types.Dependency (Dependency) +import Distribution.Types.ExeDependency (ExeDependency) + +------------------------------------------------------------------------------- +-- GenericPackageDescription +------------------------------------------------------------------------------- + +defaultTargetBuildDepends :: Lens' DefaultBounds [Dependency] +defaultTargetBuildDepends f s = fmap (\x -> s{T.defaultTargetBuildDepends = x}) (f (T.defaultTargetBuildDepends s)) +{-# INLINE defaultTargetBuildDepends #-} + +defaultBuildToolDepends :: Lens' DefaultBounds [ExeDependency] +defaultBuildToolDepends f s = fmap (\x -> s{T.defaultBuildToolDepends = x}) (f (T.defaultBuildToolDepends s)) +{-# INLINE defaultBuildToolDepends #-} diff --git a/Cabal-syntax/src/Distribution/Types/ExeDependency.hs b/Cabal-syntax/src/Distribution/Types/ExeDependency.hs index 17a79703fcc..778f5b30ab8 100644 --- a/Cabal-syntax/src/Distribution/Types/ExeDependency.hs +++ b/Cabal-syntax/src/Distribution/Types/ExeDependency.hs @@ -4,6 +4,9 @@ module Distribution.Types.ExeDependency ( ExeDependency (..) , qualifiedExeName + , exeDepPkgName + , exeDepUnqualComp + , exeDepVerRange ) where import Distribution.Compat.Prelude @@ -31,6 +34,15 @@ instance Binary ExeDependency instance Structured ExeDependency instance NFData ExeDependency where rnf = genericRnf +exeDepPkgName :: ExeDependency -> PackageName +exeDepPkgName (ExeDependency pn _ _) = pn + +exeDepUnqualComp :: ExeDependency -> UnqualComponentName +exeDepUnqualComp (ExeDependency _ uc _) = uc + +exeDepVerRange :: ExeDependency -> VersionRange +exeDepVerRange (ExeDependency _ _ vr) = vr + instance Pretty ExeDependency where pretty (ExeDependency name exe ver) = pretty name <<>> PP.colon <<>> pretty exe PP.<+> pver diff --git a/Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs b/Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs index 55ec8652304..2b5ed006da7 100644 --- a/Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs +++ b/Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs @@ -44,6 +44,7 @@ data GenericPackageDescription = GenericPackageDescription -- Perfectly, PackageIndex should have sum type, so we don't need to -- have dummy GPDs. , genPackageFlags :: [PackageFlag] + , genDefaultPackageBounds :: Maybe DefaultBounds , condLibrary :: Maybe (CondTree ConfVar [Dependency] Library) , condSubLibraries :: [ ( UnqualComponentName @@ -81,17 +82,18 @@ instance Structured GenericPackageDescription instance NFData GenericPackageDescription where rnf = genericRnf emptyGenericPackageDescription :: GenericPackageDescription -emptyGenericPackageDescription = GenericPackageDescription emptyPackageDescription Nothing [] Nothing [] [] [] [] [] +emptyGenericPackageDescription = GenericPackageDescription emptyPackageDescription Nothing [] Nothing Nothing [] [] [] [] [] -- ----------------------------------------------------------------------------- -- Traversal Instances instance L.HasBuildInfos GenericPackageDescription where - traverseBuildInfos f (GenericPackageDescription p v a1 x1 x2 x3 x4 x5 x6) = + traverseBuildInfos f (GenericPackageDescription p v a1 bs x1 x2 x3 x4 x5 x6) = GenericPackageDescription <$> L.traverseBuildInfos f p <*> pure v <*> pure a1 + <*> pure bs <*> (traverse . traverseCondTreeBuildInfo) f x1 <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x2 <*> (traverse . L._2 . traverseCondTreeBuildInfo) f x3 diff --git a/Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs b/Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs index 213c97128f9..539e5950064 100644 --- a/Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs +++ b/Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs @@ -22,6 +22,7 @@ import Distribution.System (Arch, OS) import Distribution.Types.Benchmark (Benchmark) import Distribution.Types.CondTree (CondTree) import Distribution.Types.ConfVar (ConfVar (..)) +import Distribution.Types.DefaultBounds (DefaultBounds) import Distribution.Types.Dependency (Dependency) import Distribution.Types.Executable (Executable) import Distribution.Types.Flag (FlagName, PackageFlag (MkPackageFlag)) @@ -49,6 +50,10 @@ genPackageFlags :: Lens' GenericPackageDescription [PackageFlag] genPackageFlags f s = fmap (\x -> s{T.genPackageFlags = x}) (f (T.genPackageFlags s)) {-# INLINE genPackageFlags #-} +genDefaultPackageBounds :: Lens' GenericPackageDescription (Maybe DefaultBounds) +genDefaultPackageBounds f s = fmap (\x -> s{T.genDefaultPackageBounds = x}) (f (T.genDefaultPackageBounds s)) +{-# INLINE genDefaultPackageBounds #-} + condLibrary :: Lens' GenericPackageDescription (Maybe (CondTree ConfVar [Dependency] Library)) condLibrary f s = fmap (\x -> s{T.condLibrary = x}) (f (T.condLibrary s)) {-# INLINE condLibrary #-} @@ -81,11 +86,12 @@ allCondTrees ) -> GenericPackageDescription -> f GenericPackageDescription -allCondTrees f (GenericPackageDescription p v a1 x1 x2 x3 x4 x5 x6) = +allCondTrees f (GenericPackageDescription p v a1 bs x1 x2 x3 x4 x5 x6) = GenericPackageDescription <$> pure p <*> pure v <*> pure a1 + <*> pure bs <*> traverse f x1 <*> (traverse . _2) f x2 <*> (traverse . _2) f x3 diff --git a/Cabal-syntax/src/Distribution/Types/Lens.hs b/Cabal-syntax/src/Distribution/Types/Lens.hs index 2934d722fbd..ac199b51d59 100644 --- a/Cabal-syntax/src/Distribution/Types/Lens.hs +++ b/Cabal-syntax/src/Distribution/Types/Lens.hs @@ -1,6 +1,7 @@ module Distribution.Types.Lens ( module Distribution.Types.Benchmark.Lens , module Distribution.Types.BuildInfo.Lens + , module Distribution.Types.DefaultBounds.Lens , module Distribution.Types.Executable.Lens , module Distribution.Types.ForeignLib.Lens , module Distribution.Types.GenericPackageDescription.Lens @@ -14,6 +15,7 @@ module Distribution.Types.Lens import Distribution.Types.Benchmark.Lens import Distribution.Types.BuildInfo.Lens +import Distribution.Types.DefaultBounds.Lens import Distribution.Types.Executable.Lens import Distribution.Types.ForeignLib.Lens import Distribution.Types.GenericPackageDescription.Lens From de419433c4c1482f4b082a25d8e10532fc083ea5 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Wed, 26 Jun 2024 17:13:50 +0200 Subject: [PATCH 2/7] Use default-package-bounds in solver and in finalizePD --- .../PackageDescription/Configuration.hs | 37 +++++++++++++++---- .../Solver/Modular/IndexConversion.hs | 19 ++++++---- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs b/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs index e811c361221..de2c7b07d1b 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs @@ -32,6 +32,7 @@ module Distribution.PackageDescription.Configuration , transformAllBuildInfos , transformAllBuildDepends , transformAllBuildDependsN + , transformDefaultBuildDepends , simplifyWithSysParams ) where @@ -40,6 +41,7 @@ import Prelude () -- lens import qualified Distribution.Types.BuildInfo.Lens as L +import qualified Distribution.Types.DefaultBounds.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 @@ -476,7 +478,7 @@ finalizePD (Platform arch os) impl constraints - (GenericPackageDescription pkg _ver flags mb_lib0 sub_libs0 flibs0 exes0 tests0 bms0) = do + (GenericPackageDescription pkg _ver flags defBounds mb_lib0 sub_libs0 flibs0 exes0 tests0 bms0) = do (targetSet, flagVals) <- resolveWithFlags flagChoices enabled os arch impl constraints condTrees check let @@ -509,14 +511,25 @@ finalizePD , flagVals ) where + appBounds :: L.HasBuildInfo a => a -> a + appBounds = maybe id applyDefaultBoundsToBuildInfo defBounds + + appBoundsConstrs + :: [CondTree v [Dependency] a] + -> [CondTree v [Dependency] a] + appBoundsConstrs = case defBounds of + Nothing -> id + Just db -> map (mapTreeConstrs (applyDefaultBoundsToDependencies db)) + -- Combine lib, exes, and tests into one list of @CondTree@s with tagged data condTrees = - maybeToList (fmap (mapTreeData Lib) mb_lib0) - ++ map (\(name, tree) -> mapTreeData (SubComp name . CLib) tree) sub_libs0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CFLib) tree) flibs0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CExe) tree) exes0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CTest) tree) tests0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CBench) tree) bms0 + appBoundsConstrs $ + maybeToList (fmap (mapTreeData (Lib . appBounds)) mb_lib0) + ++ map (\(name, tree) -> mapTreeData (SubComp name . CLib . appBounds) tree) sub_libs0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CFLib . appBounds) tree) flibs0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CExe . appBounds) tree) exes0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CTest . appBounds) tree) tests0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CBench . appBounds) tree) bms0 flagChoices = map (\(MkPackageFlag n _ d manual) -> (n, d2c manual n d)) flags d2c manual n b = case lookupFlagAssignment n userflags of @@ -556,7 +569,7 @@ resolveWithFlags [] Distribution.System.Linux Distribution.System.I386 (Distribu -- function. flattenPackageDescription :: GenericPackageDescription -> PackageDescription flattenPackageDescription - (GenericPackageDescription pkg _ _ mlib0 sub_libs0 flibs0 exes0 tests0 bms0) = + (GenericPackageDescription pkg _ _ _ mlib0 sub_libs0 flibs0 exes0 tests0 bms0) = pkg { library = mlib , subLibraries = reverse sub_libs @@ -668,3 +681,11 @@ transformAllBuildDependsN f = . over (L.packageDescription . L.setupBuildInfo . traverse . L.setupDepends) f -- cannot be point-free as normal because of higher rank . over (\f' -> L.allCondTrees $ traverseCondTreeC f') f + +-- | Apply @f@ to the default bounds in the 'PackageDescription'. +transformDefaultBuildDepends + :: (Dependency -> Dependency) + -> GenericPackageDescription + -> GenericPackageDescription +transformDefaultBuildDepends f = + over (L.genDefaultPackageBounds . traverse . L.defaultTargetBuildDepends . traverse) f diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs b/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs index 72d0b8193e3..5060d1cc552 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs @@ -14,6 +14,7 @@ import qualified Distribution.InstalledPackageInfo as IPI import Distribution.Compiler import Distribution.Package -- from Cabal import Distribution.Simple.BuildToolDepends -- from Cabal +import Distribution.Types.BuildInfo.Lens (HasBuildInfo) import Distribution.Types.ExeDependency -- from Cabal import Distribution.Types.PkgconfigDependency -- from Cabal import Distribution.Types.ComponentName -- from Cabal @@ -176,10 +177,13 @@ convGPD :: OS -> Arch -> CompilerInfo -> [LabeledPackageConstraint] -> StrongFlags -> SolveExecutables -> PN -> GenericPackageDescription -> PInfo convGPD os arch cinfo constraints strfl solveExes pn - (GenericPackageDescription pkg scannedVersion flags mlib sub_libs flibs exes tests benchs) = + (GenericPackageDescription pkg scannedVersion flags defBounds mlib sub_libs flibs exes tests benchs) = let fds = flagInfo strfl flags + appBounds :: HasBuildInfo a => CondTree cv [Dependency] a + -> CondTree cv [Dependency] a + appBounds = maybe id applyDefaultBoundsToCondTree defBounds conv :: Monoid a => Component -> (a -> BuildInfo) -> DependencyReason PN -> CondTree ConfVar [Dependency] a -> FlaggedDeps PN @@ -190,15 +194,15 @@ convGPD os arch cinfo constraints strfl solveExes pn initDR = DependencyReason pn M.empty S.empty flagged_deps - = concatMap (\ds -> conv ComponentLib libBuildInfo initDR ds) (maybeToList mlib) - ++ concatMap (\(nm, ds) -> conv (ComponentSubLib nm) libBuildInfo initDR ds) sub_libs - ++ concatMap (\(nm, ds) -> conv (ComponentFLib nm) foreignLibBuildInfo initDR ds) flibs - ++ concatMap (\(nm, ds) -> conv (ComponentExe nm) buildInfo initDR ds) exes + = concatMap (\ds -> conv ComponentLib libBuildInfo initDR (appBounds ds)) (maybeToList mlib) + ++ concatMap (\(nm, ds) -> conv (ComponentSubLib nm) libBuildInfo initDR (appBounds ds)) sub_libs + ++ concatMap (\(nm, ds) -> conv (ComponentFLib nm) foreignLibBuildInfo initDR (appBounds ds)) flibs + ++ concatMap (\(nm, ds) -> conv (ComponentExe nm) buildInfo initDR (appBounds ds)) exes ++ prefix (Stanza (SN pn TestStanzas)) - (L.map (\(nm, ds) -> conv (ComponentTest nm) testBuildInfo (addStanza TestStanzas initDR) ds) + (L.map (\(nm, ds) -> conv (ComponentTest nm) testBuildInfo (addStanza TestStanzas initDR) (appBounds ds)) tests) ++ prefix (Stanza (SN pn BenchStanzas)) - (L.map (\(nm, ds) -> conv (ComponentBench nm) benchmarkBuildInfo (addStanza BenchStanzas initDR) ds) + (L.map (\(nm, ds) -> conv (ComponentBench nm) benchmarkBuildInfo (addStanza BenchStanzas initDR) (appBounds ds)) benchs) ++ maybe [] (convSetupBuildInfo pn) (setupBuildInfo pkg) @@ -340,7 +344,6 @@ convCondTree flags dr pkg os arch cinfo pn fds comp getInfo solveExes@(SolveExec [ D.Simple singleDep comp | dep <- ds , singleDep <- convLibDeps dr dep ] -- unconditional package dependencies - ++ L.map (\e -> D.Simple (LDep dr (Ext e)) comp) (allExtensions bi) -- unconditional extension dependencies ++ L.map (\l -> D.Simple (LDep dr (Lang l)) comp) (allLanguages bi) -- unconditional language dependencies ++ L.map (\(PkgconfigDependency pkn vr) -> D.Simple (LDep dr (Pkg pkn vr)) comp) (pkgconfigDepends bi) -- unconditional pkg-config dependencies From c2aaf71658567dc1c67e3a0012303f5b20e46df5 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Wed, 26 Jun 2024 17:14:31 +0200 Subject: [PATCH 3/7] Use default-package-bounds in check and cabal-install --- .../Distribution/PackageDescription/Check.hs | 27 ++++++++++++++++++- .../PackageDescription/Check/Common.hs | 17 ++++++++---- .../PackageDescription/Check/Target.hs | 5 ++++ .../PackageDescription/Check/Warning.hs | 13 +++++++++ .../src/Distribution/Client/Dependency.hs | 5 ++-- .../src/Distribution/Client/IndexUtils.hs | 1 + cabal-install/tests/IntegrationTests2.hs | 1 + .../Distribution/Solver/Modular/DSL.hs | 1 + 8 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index ef97b0d23be..c6aeceed141 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -226,6 +226,7 @@ checkGenericPackageDescription packageDescription_ _gpdScannedVersion_ genPackageFlags_ + genDefaultPackageBounds_ condLibrary_ condSubLibraries_ condForeignLibs_ @@ -272,6 +273,8 @@ checkGenericPackageDescription checkPackageDescription packageDescription_ -- Flag names. mapM_ checkFlagName genPackageFlags_ + -- default package bounds + mapM_ checkDefaultBounds genDefaultPackageBounds_ -- § Feature checks. checkSpecVer @@ -294,9 +297,11 @@ checkGenericPackageDescription . pnPackageId . ccNames ) + let ads = maybe [] ((: []) . extractAssocDeps pName) condLibrary_ ++ map (uncurry extractAssocDeps) condSubLibraries_ + ++ maybe [] ((: []) . Left . defaultTargetBuildDepends) genDefaultPackageBounds_ case condLibrary_ of Just cl -> @@ -362,6 +367,26 @@ checkGenericPackageDescription (invalidFlagName fn) (PackageDistInexcusable $ SuspiciousFlagName [fn]) + checkDefaultBounds :: Monad m => DefaultBounds -> CheckM m () + checkDefaultBounds (DefaultBounds db dbt) = + let noBound = isAnyVersion . depVerRange + noExeBound = isAnyVersion . exeDepVerRange + in do + mapM_ + ( \b -> + checkP + (noBound b) + (PackageDistInexcusable $ DefaultBoundsNoBound [unPackageName $ depPkgName b]) + ) + db + mapM_ + ( \b -> + checkP + (noExeBound b) + (PackageDistInexcusable $ DefaultBoundsNoBound [unPackageName $ exeDepPkgName b]) + ) + dbt + decFlags :: Set.Set FlagName decFlags = toSetOf (L.genPackageFlags . traverse . L.flagName) gpd @@ -916,7 +941,7 @@ extractAssocDeps n ct = in -- Merging is fine here, remember the specific -- library dependencies will be checked branch -- by branch. - (n, snd a) + Right (n, snd a) -- | August 2022: this function is an oddity due to the historical -- GenericPackageDescription/PackageDescription split (check diff --git a/Cabal/src/Distribution/PackageDescription/Check/Common.hs b/Cabal/src/Distribution/PackageDescription/Check/Common.hs index 4c528831430..bbe0b24c961 100644 --- a/Cabal/src/Distribution/PackageDescription/Check/Common.hs +++ b/Cabal/src/Distribution/PackageDescription/Check/Common.hs @@ -54,7 +54,7 @@ checkCustomField (n, _) = -- A library name / dependencies association list. Ultimately to be -- fed to PVP check. -type AssocDep = (UnqualComponentName, [Dependency]) +type AssocDep = Either [Dependency] (UnqualComponentName, [Dependency]) -- Convenience function to partition important dependencies by name. To -- be used together with checkPVP. Important: usually “base” or “Cabal”, @@ -67,7 +67,7 @@ type AssocDep = (UnqualComponentName, [Dependency]) partitionDeps :: Monad m => [AssocDep] -- Possibly inherited dependencies, i.e. - -- dependencies from internal/main libs. + -- dependencies from internal/main libs -> [UnqualComponentName] -- List of package names ("base", "Cabal"…) -> [Dependency] -- Dependencies to check. -> CheckM m ([Dependency], [Dependency]) @@ -77,11 +77,17 @@ partitionDeps ads ns ds = do -- names of our dependencies dqs = map unqualName ds -- shared targets that match - fads = filter (flip elem dqs . fst) ads + fads = + filter + ( \ad -> case ad of + Left{} -> True + Right (x, _) -> elem x dqs + ) + ads -- the names of such targets - inNam = nub $ map fst fads :: [UnqualComponentName] + inNam = nub $ mapMaybe (either (const Nothing) (Just . fst)) fads :: [UnqualComponentName] -- the dependencies of such targets - inDep = concatMap snd fads :: [Dependency] + inDep = concatMap (either id snd) fads :: [Dependency] -- We exclude from checks: -- 1. dependencies which are shared with main library / a @@ -89,6 +95,7 @@ partitionDeps ads ns ds = do -- 2. the names of main library / sub libraries themselves. -- -- So in myPackage.cabal + -- -- library -- build-depends: text < 5 -- ⁝ diff --git a/Cabal/src/Distribution/PackageDescription/Check/Target.hs b/Cabal/src/Distribution/PackageDescription/Check/Target.hs index c40fc0ef09a..2ac4b9c30ca 100644 --- a/Cabal/src/Distribution/PackageDescription/Check/Target.hs +++ b/Cabal/src/Distribution/PackageDescription/Check/Target.hs @@ -13,6 +13,8 @@ module Distribution.PackageDescription.Check.Target , checkExecutable , checkTestSuite , checkBenchmark + -- Utils + , mergeDependencies ) where import Distribution.Compat.Prelude @@ -336,6 +338,7 @@ checkBuildInfo cet ams ads bi = do ads [mkUnqualComponentName "base"] (mergeDependencies $ targetBuildDepends bi) + let ick = const (PackageDistInexcusable BaseNoUpperBounds) rck = PackageDistSuspiciousWarn . MissingUpperBounds cet checkPVP ick ids @@ -760,6 +763,7 @@ isInternalTarget (CETExecutable{}) = False isInternalTarget (CETTest{}) = True isInternalTarget (CETBenchmark{}) = True isInternalTarget (CETSetup{}) = False +isInternalTarget (CETDefaultPackageBounds{}) = True -- ------------------------------------------------------------ -- Options @@ -776,6 +780,7 @@ cet2bit (CETExecutable{}) = BITOther cet2bit (CETTest{}) = BITTestBench cet2bit (CETBenchmark{}) = BITTestBench cet2bit CETSetup = BITOther +cet2bit CETDefaultPackageBounds = BITOther -- General check on all options (ghc, C, C++, …) for common inaccuracies. checkBuildInfoOptions :: Monad m => BITarget -> BuildInfo -> CheckM m () diff --git a/Cabal/src/Distribution/PackageDescription/Check/Warning.hs b/Cabal/src/Distribution/PackageDescription/Check/Warning.hs index 859b3f12c50..c609bee7faf 100644 --- a/Cabal/src/Distribution/PackageDescription/Check/Warning.hs +++ b/Cabal/src/Distribution/PackageDescription/Check/Warning.hs @@ -255,6 +255,7 @@ data CheckExplanation | UnknownCompiler [String] | BaseNoUpperBounds | MissingUpperBounds CEType [String] + | DefaultBoundsNoBound [String] | SuspiciousFlagName [String] | DeclaredUsedFlags (Set.Set FlagName) (Set.Set FlagName) | NonASCIICustomField [String] @@ -417,6 +418,7 @@ data CheckExplanationID | CIUnknownCompiler | CIBaseNoUpperBounds | CIMissingUpperBounds + | CIDefaultBoundsNoBound | CISuspiciousFlagName | CIDeclaredUsedFlags | CINonASCIICustomField @@ -558,6 +560,7 @@ checkExplanationId (UnknownArch{}) = CIUnknownArch checkExplanationId (UnknownCompiler{}) = CIUnknownCompiler checkExplanationId (BaseNoUpperBounds{}) = CIBaseNoUpperBounds checkExplanationId (MissingUpperBounds{}) = CIMissingUpperBounds +checkExplanationId (DefaultBoundsNoBound{}) = CIDefaultBoundsNoBound checkExplanationId (SuspiciousFlagName{}) = CISuspiciousFlagName checkExplanationId (DeclaredUsedFlags{}) = CIDeclaredUsedFlags checkExplanationId (NonASCIICustomField{}) = CINonASCIICustomField @@ -704,6 +707,7 @@ ppCheckExplanationId CIUnknownArch = "unknown-arch" ppCheckExplanationId CIUnknownCompiler = "unknown-compiler" ppCheckExplanationId CIBaseNoUpperBounds = "missing-bounds-important" ppCheckExplanationId CIMissingUpperBounds = "missing-upper-bounds" +ppCheckExplanationId CIDefaultBoundsNoBound = "default-bounds-no-bound" ppCheckExplanationId CISuspiciousFlagName = "suspicious-flag" ppCheckExplanationId CIDeclaredUsedFlags = "unused-flag" ppCheckExplanationId CINonASCIICustomField = "non-ascii" @@ -746,6 +750,7 @@ data CEType | CETTest UnqualComponentName | CETBenchmark UnqualComponentName | CETSetup + | CETDefaultPackageBounds deriving (Eq, Ord, Show) -- | Pretty printing `CEType`. @@ -757,6 +762,7 @@ ppCET cet = case cet of CETTest n -> "test suite" ++ qn n CETBenchmark n -> "benchmark" ++ qn n CETSetup -> "custom-setup" + CETDefaultPackageBounds -> "default package bounds" where qn :: UnqualComponentName -> String qn wn = (" " ++) . quote . prettyShow $ wn @@ -1302,6 +1308,13 @@ ppExplanation (MissingUpperBounds ct names) = ++ List.intercalate separator names ++ "\n" ++ "Please add them. There is more information at https://pvp.haskell.org/" +ppExplanation (DefaultBoundsNoBound names) = + let separator = "\n - " + in "These default-package-bounds declarations are missing bounds:" + ++ separator + ++ List.intercalate separator names + ++ "\n" + ++ "It doesn't make sense to have empty bounds on default-package-bounds. Please add them." ppExplanation (SuspiciousFlagName invalidFlagNames) = "Suspicious flag names: " ++ unwords invalidFlagNames diff --git a/cabal-install/src/Distribution/Client/Dependency.hs b/cabal-install/src/Distribution/Client/Dependency.hs index 2949b4d21d1..2812b8f82cb 100644 --- a/cabal-install/src/Distribution/Client/Dependency.hs +++ b/cabal-install/src/Distribution/Client/Dependency.hs @@ -554,13 +554,14 @@ relaxPackageDeps -> PD.GenericPackageDescription -> PD.GenericPackageDescription relaxPackageDeps _ rd gpd | not (isRelaxDeps rd) = gpd -- subsumed by no-op case in 'removeBounds' -relaxPackageDeps relKind RelaxDepsAll gpd = PD.transformAllBuildDepends relaxAll gpd +relaxPackageDeps relKind RelaxDepsAll gpd = + PD.transformDefaultBuildDepends relaxAll $ PD.transformAllBuildDepends relaxAll gpd where relaxAll :: Dependency -> Dependency relaxAll (Dependency pkgName verRange cs) = Dependency pkgName (removeBound relKind RelaxDepModNone verRange) cs relaxPackageDeps relKind (RelaxDepsSome depsToRelax0) gpd = - PD.transformAllBuildDepends relaxSome gpd + PD.transformDefaultBuildDepends relaxSome $ PD.transformAllBuildDepends relaxSome gpd where thisPkgName = packageName gpd thisPkgId = packageId gpd diff --git a/cabal-install/src/Distribution/Client/IndexUtils.hs b/cabal-install/src/Distribution/Client/IndexUtils.hs index 5958deca553..646deb96687 100644 --- a/cabal-install/src/Distribution/Client/IndexUtils.hs +++ b/cabal-install/src/Distribution/Client/IndexUtils.hs @@ -1075,6 +1075,7 @@ packageListFromCache verbosity mkPkg hnd Cache{..} = accum mempty [] mempty cach } , gpdScannedVersion = Just specVer -- tells index scanner to skip this file. , genPackageFlags = [] + , genDefaultPackageBounds = Nothing , condLibrary = Nothing , condSubLibraries = [] , condForeignLibs = [] diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index b5b49053b6d..81c49d0aceb 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -467,6 +467,7 @@ testTargetSelectorAmbiguous reportSubCase = do packageDescription = emptyPackageDescription { package = pkgid }, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = Nothing, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs index 991c5cafa0e..914ce6f2b55 100644 --- a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs +++ b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs @@ -455,6 +455,7 @@ exAvSrcPkg ex = } , C.gpdScannedVersion = Nothing , C.genPackageFlags = flags + , C.genDefaultPackageBounds = Nothing , C.condLibrary = let mkLib v bi = mempty{C.libVisibility = v, C.libBuildInfo = bi} -- Avoid using the Monoid instance for [a] when getting From b2e828f69183610c689c59cd80617060e7a384ae Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Wed, 26 Jun 2024 17:15:49 +0200 Subject: [PATCH 4/7] Document default-package-bounds --- changelog.d/default-package-bounds | 12 ++++ doc/cabal-package-description-file.rst | 99 ++++++++++++++++++++++++-- doc/file-format-changelog.rst | 8 ++- 3 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 changelog.d/default-package-bounds diff --git a/changelog.d/default-package-bounds b/changelog.d/default-package-bounds new file mode 100644 index 00000000000..c6477a13c98 --- /dev/null +++ b/changelog.d/default-package-bounds @@ -0,0 +1,12 @@ +synopsis: Implement `default-package-bounds` field +packages: Cabal-syntax +prs: #9462 + +description: { + +The new `default-package-bounds` stanza can be used to default versions that are +ommitted in the build-depends fields. This could be done previously by means of +common stanzas, but it was too verbose and obscure (dependencies came sometimes +from stanzas). + +} diff --git a/doc/cabal-package-description-file.rst b/doc/cabal-package-description-file.rst index d560b69e05d..cce1a01a4dc 100644 --- a/doc/cabal-package-description-file.rst +++ b/doc/cabal-package-description-file.rst @@ -1528,12 +1528,12 @@ system-dependent values for these fields. common because it is recommended practice for package versions to correspond to API versions (see PVP_). - Since Cabal 1.6, there is a special wildcard syntax to help with + Since **Cabal 1.6**, there is a special wildcard syntax to help with such ranges :: - build-depends: foo ==1.2.* + build-depends: foo ==1.2.*** It is only syntactic sugar. It is exactly equivalent to ``foo >= 1.2 && < 1.3``. @@ -1546,7 +1546,7 @@ system-dependent values for these fields. than ``1.0``. This is not an issue with the caret-operator ``^>=`` described below. - Starting with Cabal 2.0, there's a new version operator to express + Starting with **Cabal 2.0**, there's a new version operator to express PVP_-style major upper bounds conveniently, and is inspired by similar syntactic sugar found in other language ecosystems where it's often called the "Caret" operator: @@ -1637,8 +1637,8 @@ system-dependent values for these fields. renaming in ``build-depends``; however, this support has since been removed and should not be used. - Starting with Cabal 3.0, a set notation for the ``==`` and ``^>=`` operator - is available. For instance, + Starting with **Cabal 3.0**, a set notation for the ``==`` and ``^>=`` + operator is available. For instance, :: @@ -1655,7 +1655,6 @@ system-dependent values for these fields. build-depends: network ^>= { 2.6.3.6, 2.7.0.2, 2.8.0.0, 3.0.1.0 } - .. pkg-field:: other-modules: identifier list A list of modules used by the component but not exposed to users. @@ -2687,6 +2686,94 @@ Starting with Cabal-2.2 it's possible to use common build info stanzas. TBW +.. _default-package-bounds: + +Default package bounds +^^^^^^^^^^^^^^^^^^^^^^ + +.. pkg-section:: default-package-bounds + :since: 3.14 + +Starting with **Cabal 3.14**, a new section ``default-package-bounds`` can be +declared on the package description to provide version bounds that will be used +when there is no explicit bound on an entry on: + +- :pkg-field:`build-depends` +- :pkg-field:`build-tool-depends` + +So the package description: + +:: + + default-package-bounds + build-depends: + , awesome-package ^>= 5 + build-tool-depends: + , markdown-unlit:markdown-unlit < 100 + + custom-setup + setup-depends: + awesome-package + + library a + build-depends: + , awesome-package + build-tool-depends: + , markdown-unlit:markdown-unlit + + library b + build-depends: + , awesome-package >5.5 + build-tool-depends: + , markdown-unlit:markdown-unlit >1 + + library c + build-depends: y + +will be equivalent to: + +:: + + custom-setup + setup-depends: + awesome-package + + library a + build-depends: + , awesome-package ^>= 5 + build-tool-depends: + , markdown-unlit:markdown-unlit < 100 + + library b + build-depends: + , awesome-package >5.5 + build-tool-depends: + , markdown-unlit:markdown-unlit >1 + + library c + build-depends: y + +Notice only ``library a`` had its bounds modified. This process is only applied +as a syntactic desugaring, only to avoid duplication and verbosity on the cabal +file. More concretely, + +- it will **not** apply version bounds on transitive dependencies that are not explicitly listed as a dependency, +- it will **not** add the listed dependencies to any component in which they were not already listed, +- it will **not** modify bounds on :pkg-field:`pkgconfig-depends` entries. +- it will **not** modify bounds on :pkg-field:`custom-setup:setup-depends` entries. + +Using ``--allow-newer`` or ``--allow-older`` will relax the ``default-package-bounds`` constraints +in the same way as is done for normal :pkg-field:`build-depends` dependencies. + +.. pkg-field:: build-depends: library list + + The bounds declared here will be applied to entries without explicit bounds in every + :pkg-field:`build-depends`. + +.. pkg-field:: build-tool-depends: package:executable list + + The bounds declared here will be applied to entries without explicit bounds in every + :pkg-field:`build-tool-depends`. .. _pkg-author-source: diff --git a/doc/file-format-changelog.rst b/doc/file-format-changelog.rst index 854f949b301..e0a3e08e302 100644 --- a/doc/file-format-changelog.rst +++ b/doc/file-format-changelog.rst @@ -19,13 +19,19 @@ relative to the respective preceding *published* version. versions of the ``Cabal`` library denote unreleased development branches which have no stability guarantee. +``cabal-version: 3.14`` +----------------------- + +* Added :pkg-section:`default-package-bounds` stanza. This allows to declare + constraints that will be used for the dependencies that have no specified + constraints associated in ``build-depends`` lists. + ``cabal-version: 3.12`` ----------------------- * License fields use identifiers from SPDX License List version ``3.23 2024-02-08``. - ``cabal-version: 3.8`` ---------------------- From 0f17eff2cd4eb1b450637d98d74e78cf389b1226 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Wed, 26 Jun 2024 21:17:53 +0200 Subject: [PATCH 5/7] Fix tests for default-package-bounds --- Cabal-tests/tests/NoThunks.hs | 1 + .../ParserTests/regressions/Octree-0.5.expr | 2 + .../ParserTests/regressions/anynone.expr | 2 + .../ParserTests/regressions/big-version.expr | 2 + .../regressions/common-conditional.expr | 2 + .../tests/ParserTests/regressions/common.expr | 2 + .../ParserTests/regressions/common2.expr | 2 + .../ParserTests/regressions/common3.expr | 2 + .../tests/ParserTests/regressions/elif.expr | 2 + .../tests/ParserTests/regressions/elif2.expr | 2 + .../ParserTests/regressions/encoding-0.8.expr | 2 + .../ParserTests/regressions/generics-sop.expr | 2 + .../ParserTests/regressions/hasktorch.expr | 2 + .../regressions/hidden-main-lib.expr | 2 + .../ParserTests/regressions/indentation.expr | 2 + .../ParserTests/regressions/indentation2.expr | 2 + .../ParserTests/regressions/indentation3.expr | 2 + .../ParserTests/regressions/issue-5055.expr | 2 + .../ParserTests/regressions/issue-5846.expr | 2 + .../ParserTests/regressions/issue-6083-a.expr | 2 + .../ParserTests/regressions/issue-6083-b.expr | 2 + .../ParserTests/regressions/issue-6083-c.expr | 2 + .../regressions/issue-6083-pkg-pkg.expr | 2 + .../ParserTests/regressions/issue-774.expr | 2 + .../regressions/jaeger-flamegraph.expr | 2 + .../regressions/leading-comma-2.expr | 2 + .../regressions/leading-comma.expr | 2 + .../tests/ParserTests/regressions/libpq1.expr | 2 + .../tests/ParserTests/regressions/libpq2.expr | 2 + .../ParserTests/regressions/mixin-1.expr | 2 + .../ParserTests/regressions/mixin-2.expr | 2 + .../ParserTests/regressions/mixin-3.expr | 2 + .../ParserTests/regressions/monad-param.expr | 2 + .../regressions/multiple-libs-2.expr | 2 + .../ParserTests/regressions/noVersion.expr | 2 + .../regressions/nothing-unicode.expr | 2 + .../tests/ParserTests/regressions/shake.expr | 2 + .../tests/ParserTests/regressions/spdx-1.expr | 2 + .../tests/ParserTests/regressions/spdx-2.expr | 2 + .../tests/ParserTests/regressions/spdx-3.expr | 2 + .../regressions/th-lift-instances.expr | 2 + .../ParserTests/regressions/version-sets.expr | 2 + .../regressions/wl-pprint-indef.expr | 2 + .../Distribution/PackageDescription/Check.hs | 3 +- .../Distribution/Utils/Structured.hs | 4 +- .../src/Data/TreeDiff/Instances/Cabal.hs | 1 + .../DefaultPackageBounds/bar/Main.hs | 5 +++ .../DefaultPackageBounds/bar/bar.cabal | 7 ++++ .../DefaultPackageBounds/cabal.out | 37 +++++++++++++++++++ .../DefaultPackageBounds/cabal.project | 1 + .../DefaultPackageBounds/cabal.test.hs | 7 ++++ .../DefaultPackageBounds/foo.cabal | 33 +++++++++++++++++ .../PackageTests/Regression/T9640/cabal.out | 2 +- 53 files changed, 180 insertions(+), 5 deletions(-) create mode 100644 cabal-testsuite/PackageTests/DefaultPackageBounds/bar/Main.hs create mode 100644 cabal-testsuite/PackageTests/DefaultPackageBounds/bar/bar.cabal create mode 100644 cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.out create mode 100644 cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.project create mode 100644 cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.test.hs create mode 100644 cabal-testsuite/PackageTests/DefaultPackageBounds/foo.cabal diff --git a/Cabal-tests/tests/NoThunks.hs b/Cabal-tests/tests/NoThunks.hs index 6a81475dc03..3783ef3a977 100644 --- a/Cabal-tests/tests/NoThunks.hs +++ b/Cabal-tests/tests/NoThunks.hs @@ -69,6 +69,7 @@ instance NoThunks BuildType instance NoThunks CabalSpecVersion instance NoThunks CompilerFlavor instance NoThunks ConfVar +instance NoThunks DefaultBounds instance NoThunks Dependency instance NoThunks Executable instance NoThunks ExecutableScope diff --git a/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr b/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr index b3494104aed..77a263aaad3 100644 --- a/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr +++ b/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr @@ -69,6 +69,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/anynone.expr b/Cabal-tests/tests/ParserTests/regressions/anynone.expr index 8c9c8879ab4..555b5fd6c66 100644 --- a/Cabal-tests/tests/ParserTests/regressions/anynone.expr +++ b/Cabal-tests/tests/ParserTests/regressions/anynone.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/big-version.expr b/Cabal-tests/tests/ParserTests/regressions/big-version.expr index d4ef82adf52..d7aa02f7f07 100644 --- a/Cabal-tests/tests/ParserTests/regressions/big-version.expr +++ b/Cabal-tests/tests/ParserTests/regressions/big-version.expr @@ -37,6 +37,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr b/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr index 9cacba2b770..45daaff5348 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr @@ -52,6 +52,8 @@ GenericPackageDescription { flagDescription = "", flagDefault = True, flagManual = True}], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/common.expr b/Cabal-tests/tests/ParserTests/regressions/common.expr index 25abadef9e7..9fcc46d63b1 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common.expr @@ -50,6 +50,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/common2.expr b/Cabal-tests/tests/ParserTests/regressions/common2.expr index cd501d11cf2..8607bde5f3a 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common2.expr @@ -46,6 +46,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/common3.expr b/Cabal-tests/tests/ParserTests/regressions/common3.expr index fc1fc155c09..f79fc0b4a0f 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common3.expr @@ -50,6 +50,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/elif.expr b/Cabal-tests/tests/ParserTests/regressions/elif.expr index f17c1e17b88..60071a7c48b 100644 --- a/Cabal-tests/tests/ParserTests/regressions/elif.expr +++ b/Cabal-tests/tests/ParserTests/regressions/elif.expr @@ -45,6 +45,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/elif2.expr b/Cabal-tests/tests/ParserTests/regressions/elif2.expr index ec01a92a79d..c7b68fb69b7 100644 --- a/Cabal-tests/tests/ParserTests/regressions/elif2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/elif2.expr @@ -45,6 +45,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr b/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr index 0d248029a31..9222eaff9aa 100644 --- a/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr +++ b/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr @@ -50,6 +50,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr b/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr index 25786cdfad5..ac2c0ea4d6e 100644 --- a/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr +++ b/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr @@ -126,6 +126,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr b/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr index c68fac467e1..2a70a60f71e 100644 --- a/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr +++ b/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr @@ -69,6 +69,8 @@ GenericPackageDescription { "only build with Double and Long support", flagDefault = False, flagManual = False}], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr b/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr index b51b4adacb2..8d400ac671f 100644 --- a/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr +++ b/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr @@ -37,6 +37,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation.expr b/Cabal-tests/tests/ParserTests/regressions/indentation.expr index c97630ddb00..cc303c75b75 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation.expr @@ -47,6 +47,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation2.expr b/Cabal-tests/tests/ParserTests/regressions/indentation2.expr index 605cba525d1..d0c46a34eab 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation2.expr @@ -40,6 +40,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation3.expr b/Cabal-tests/tests/ParserTests/regressions/indentation3.expr index 55d0533c3fe..0ba1404c095 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation3.expr @@ -42,6 +42,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr b/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr index 3b5092639e4..f84e6506f38 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr @@ -37,6 +37,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr b/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr index 61a7b7d2ca1..58da04c977b 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr index c9c57785ac6..d3d213d58ab 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr index b0ed19062fc..c8cca40546e 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr index c901eebc8ce..08d463693a5 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr index 62ed5fd2fb9..39f2efc4598 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-774.expr b/Cabal-tests/tests/ParserTests/regressions/issue-774.expr index 2f58de4eb00..1c392d38e8a 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-774.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-774.expr @@ -44,6 +44,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr b/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr index 9994c9b72c1..84a24f82a7c 100644 --- a/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr +++ b/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr @@ -76,6 +76,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr b/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr index 99f7cddf881..ffe1cfccd7a 100644 --- a/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr @@ -37,6 +37,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr b/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr index 441fe75261d..1f67c72f846 100644 --- a/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr +++ b/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr @@ -37,6 +37,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/libpq1.expr b/Cabal-tests/tests/ParserTests/regressions/libpq1.expr index 2e0bc309f9f..47287fbc8eb 100644 --- a/Cabal-tests/tests/ParserTests/regressions/libpq1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/libpq1.expr @@ -120,6 +120,8 @@ GenericPackageDescription { flagDescription = "", flagDefault = False, flagManual = True}], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/libpq2.expr b/Cabal-tests/tests/ParserTests/regressions/libpq2.expr index b74143af0b9..636a25c7741 100644 --- a/Cabal-tests/tests/ParserTests/regressions/libpq2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/libpq2.expr @@ -124,6 +124,8 @@ GenericPackageDescription { flagDescription = "", flagDefault = False, flagManual = True}], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr index 77821302ddf..4d37fd39187 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr index d8b58ff5a0b..0da2ce70a39 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr index c0cbfe921ad..03965350e71 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr @@ -35,6 +35,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/monad-param.expr b/Cabal-tests/tests/ParserTests/regressions/monad-param.expr index e450672e868..17e2c63e6c0 100644 --- a/Cabal-tests/tests/ParserTests/regressions/monad-param.expr +++ b/Cabal-tests/tests/ParserTests/regressions/monad-param.expr @@ -45,6 +45,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr b/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr index aa7d6954637..284e62e180c 100644 --- a/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr @@ -37,6 +37,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/noVersion.expr b/Cabal-tests/tests/ParserTests/regressions/noVersion.expr index dfe79d768fb..f55c7d357bb 100644 --- a/Cabal-tests/tests/ParserTests/regressions/noVersion.expr +++ b/Cabal-tests/tests/ParserTests/regressions/noVersion.expr @@ -37,6 +37,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr b/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr index 2ed17f6d557..0bc096e13f3 100644 --- a/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr +++ b/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr @@ -52,6 +52,8 @@ GenericPackageDescription { flagDescription = "\28961", flagDefault = True, flagManual = False}], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/shake.expr b/Cabal-tests/tests/ParserTests/regressions/shake.expr index 4dd37e84de0..44f7e65c866 100644 --- a/Cabal-tests/tests/ParserTests/regressions/shake.expr +++ b/Cabal-tests/tests/ParserTests/regressions/shake.expr @@ -158,6 +158,8 @@ GenericPackageDescription { "Obtain FileTime using portable functions", flagDefault = False, flagManual = True}], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr index ddeaf37cbe4..333848da482 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr @@ -36,6 +36,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr index b865b1f31db..5d418bb5508 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr @@ -40,6 +40,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr index dc8f3f922b9..0986d96f7c4 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr @@ -40,6 +40,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr b/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr index 5e781597f30..b963a3a8346 100644 --- a/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr +++ b/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr @@ -64,6 +64,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/version-sets.expr b/Cabal-tests/tests/ParserTests/regressions/version-sets.expr index 3244bc1cc45..4191afac338 100644 --- a/Cabal-tests/tests/ParserTests/regressions/version-sets.expr +++ b/Cabal-tests/tests/ParserTests/regressions/version-sets.expr @@ -62,6 +62,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr b/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr index 6e718e3e685..27188d028fb 100644 --- a/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr +++ b/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr @@ -54,6 +54,8 @@ GenericPackageDescription { extraDocFiles = []}, gpdScannedVersion = Nothing, genPackageFlags = [], + genDefaultPackageBounds = + Nothing, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/UnitTests/Distribution/PackageDescription/Check.hs b/Cabal-tests/tests/UnitTests/Distribution/PackageDescription/Check.hs index 662a0684cda..1c3da5281e0 100644 --- a/Cabal-tests/tests/UnitTests/Distribution/PackageDescription/Check.hs +++ b/Cabal-tests/tests/UnitTests/Distribution/PackageDescription/Check.hs @@ -32,6 +32,5 @@ tests = longerThan = filter ((>25). length) allExplanationIdStrings usingTooManyDashes :: [CheckExplanationIDString] - usingTooManyDashes = filter ((>2) . length . filter (=='-')) + usingTooManyDashes = filter ((>3) . length . filter (=='-')) allExplanationIdStrings - diff --git a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs index d600a51fa05..70370de76c0 100644 --- a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs +++ b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs @@ -33,9 +33,9 @@ md5Check proxy md5Int = structureHash proxy @?= md5FromInteger md5Int md5CheckGenericPackageDescription :: Proxy GenericPackageDescription -> Assertion md5CheckGenericPackageDescription proxy = md5Check proxy #if MIN_VERSION_base(4,19,0) - 0xe28f08e7ac644f836d8b3fe7f9428dcf + 0xbcb29fedd00cda89586faf963028e31d #else - 0x3442058190aa48c2f795b83ee995f702 + 0xbb48247a1d86d5b514ffc4d6df853c74 #endif md5CheckLocalBuildInfo :: Proxy LocalBuildInfo -> Assertion diff --git a/Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs b/Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs index 15fae62649e..f3c61814e7e 100644 --- a/Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs +++ b/Cabal-tree-diff/src/Data/TreeDiff/Instances/Cabal.hs @@ -72,6 +72,7 @@ instance ToExpr CompilerFlavor instance ToExpr CompilerId instance ToExpr ComponentId instance ToExpr DebugInfoLevel +instance ToExpr DefaultBounds instance ToExpr DefUnitId instance ToExpr DumpBuildInfo instance ToExpr ExeDependency diff --git a/cabal-testsuite/PackageTests/DefaultPackageBounds/bar/Main.hs b/cabal-testsuite/PackageTests/DefaultPackageBounds/bar/Main.hs new file mode 100644 index 00000000000..f77c6bfe548 --- /dev/null +++ b/cabal-testsuite/PackageTests/DefaultPackageBounds/bar/Main.hs @@ -0,0 +1,5 @@ +-- | + +module Main where + +main = pure () diff --git a/cabal-testsuite/PackageTests/DefaultPackageBounds/bar/bar.cabal b/cabal-testsuite/PackageTests/DefaultPackageBounds/bar/bar.cabal new file mode 100644 index 00000000000..ce082d386f2 --- /dev/null +++ b/cabal-testsuite/PackageTests/DefaultPackageBounds/bar/bar.cabal @@ -0,0 +1,7 @@ +cabal-version: 3.14 +name: bar +version: 0.1.0.0 + +executable bar + default-language: Haskell2010 + main-is: Main.hs diff --git a/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.out b/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.out new file mode 100644 index 00000000000..75f7582b538 --- /dev/null +++ b/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.out @@ -0,0 +1,37 @@ +# cabal build +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following would be built: + - bar-0.1.0.0 (exe:bar) (first run) + - foo-0.1.0.0 (lib) (first run) +# cabal build +Resolving dependencies... +Error: [Cabal-7107] +Could not resolve dependencies: +[__0] trying: foo-0.1.0.0 (user goal) +[__1] rejecting: foo:-build-depends-conflict (constraint from config file, command line flag, or user target requires opposite flag selection) +[__1] trying: foo:+build-depends-conflict +[__2] next goal: time (dependency of foo +/-build-depends-conflict) +[__2] rejecting: time-/installed- (conflict: foo +build-depends-conflict => time<0.1) +[__2] fail (backjumping, conflict set: foo, time, foo:build-depends-conflict) +After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: foo (4), foo:build-depends-conflict (3), time (2) +# cabal build +Resolving dependencies... +Error: [Cabal-7107] +Could not resolve dependencies: +[__0] trying: bar-0.1.0.0 (user goal) +[__1] trying: foo-0.1.0.0 (user goal) +[__2] rejecting: foo:-build-tool-conflict (constraint from config file, command line flag, or user target requires opposite flag selection) +[__2] trying: foo:+build-tool-conflict +[__3] next goal: foo:bar:exe.bar (dependency of foo +/-build-tool-conflict) +[__3] rejecting: foo:bar:exe.bar~>bar-0.1.0.0 (conflict: foo +build-tool-conflict => foo:bar:exe.bar (exe bar)<0.1) +[__3] rejecting: foo:bar:exe.bar-0.1.0.0 (multiple instances) +[__3] fail (backjumping, conflict set: bar, foo, foo:bar:exe.bar, foo:build-tool-conflict) +After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: foo (4), foo:bar:exe.bar (3), foo:build-tool-conflict (3), bar (2) +Try running with --minimize-conflict-set to improve the error message. +# cabal build +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following would be built: + - bar-0.1.0.0 (exe:bar) (first run) + - foo-0.1.0.0 (lib) (first run) diff --git a/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.project b/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.project new file mode 100644 index 00000000000..01850a34e25 --- /dev/null +++ b/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.project @@ -0,0 +1 @@ +packages: . bar diff --git a/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.test.hs b/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.test.hs new file mode 100644 index 00000000000..c5c6e6eba18 --- /dev/null +++ b/cabal-testsuite/PackageTests/DefaultPackageBounds/cabal.test.hs @@ -0,0 +1,7 @@ +import Test.Cabal.Prelude + +main = cabalTest $ withProjectFile "cabal.project" $ do + cabal "build" ["foo", "--dry-run"] + fails $ cabal "build" ["foo", "--dry-run", "-fbuild-depends-conflict"] + fails $ cabal "build" ["foo", "--dry-run", "-fbuild-tool-conflict"] + cabal "build" ["foo", "--dry-run", "-fbuild-depends-conflict", "--allow-newer=time"] diff --git a/cabal-testsuite/PackageTests/DefaultPackageBounds/foo.cabal b/cabal-testsuite/PackageTests/DefaultPackageBounds/foo.cabal new file mode 100644 index 00000000000..6f88a55e5bf --- /dev/null +++ b/cabal-testsuite/PackageTests/DefaultPackageBounds/foo.cabal @@ -0,0 +1,33 @@ +cabal-version: 3.14 +name: foo +version: 0.1.0.0 + +default-package-bounds + build-depends: + , time <0.1 + build-tool-depends: + , bar:bar <0.1 + +flag build-depends-conflict + manual: True + default: False + description: cause conflict + +flag build-tool-conflict + manual: True + default: False + description: cause conflict + +library + if flag(build-depends-conflict) + build-depends: + time + else + build-depends: + time >0 + default-language: Haskell2010 + + if flag(build-tool-conflict) + build-tool-depends: bar:bar + else + build-tool-depends: bar:bar >0 diff --git a/cabal-testsuite/PackageTests/Regression/T9640/cabal.out b/cabal-testsuite/PackageTests/Regression/T9640/cabal.out index 4c0f119823f..907c05a57be 100644 --- a/cabal-testsuite/PackageTests/Regression/T9640/cabal.out +++ b/cabal-testsuite/PackageTests/Regression/T9640/cabal.out @@ -10,7 +10,7 @@ Configuring one-custom-0.1.0.0... Preprocessing library for one-custom-0.1.0.0... Building library for one-custom-0.1.0.0... Installing library in -Warning: depend-on-custom-with-exe.cabal:16:1: Ignoring trailing fields after sections: "ghc-options" +Warning: depend-on-custom-with-exe.cabal:16:1: Ignoring trailing fields after sections: "ghc-options". Consider moving these fields before any stanzas in your cabal file. Configuring library for depend-on-custom-with-exe-0.1.0.0... Preprocessing library for depend-on-custom-with-exe-0.1.0.0... Building library for depend-on-custom-with-exe-0.1.0.0... From cef49cd1c2227c0f2dbe0fab531990503e5fea6e Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Fri, 5 Jul 2024 15:24:45 +0200 Subject: [PATCH 6/7] Apply review suggestions Co-authored-by: Kristen Kozak --- .../PackageDescription/Configuration.hs | 29 ++++++++----------- .../Distribution/PackageDescription/Parsec.hs | 4 +-- .../PackageDescription/PrettyPrint.hs | 2 +- .../src/Distribution/Types/DefaultBounds.hs | 14 +++++---- .../Types/GenericPackageDescription.hs | 4 +-- .../Types/GenericPackageDescription/Lens.hs | 2 +- .../Distribution/PackageDescription/Check.hs | 4 +-- .../Solver/Modular/IndexConversion.hs | 2 +- .../src/Distribution/Client/IndexUtils.hs | 3 +- cabal-install/tests/IntegrationTests2.hs | 2 +- .../Distribution/Solver/Modular/DSL.hs | 2 +- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs b/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs index de2c7b07d1b..988039ee187 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs @@ -511,25 +511,20 @@ finalizePD , flagVals ) where - appBounds :: L.HasBuildInfo a => a -> a - appBounds = maybe id applyDefaultBoundsToBuildInfo defBounds - - appBoundsConstrs - :: [CondTree v [Dependency] a] - -> [CondTree v [Dependency] a] - appBoundsConstrs = case defBounds of - Nothing -> id - Just db -> map (mapTreeConstrs (applyDefaultBoundsToDependencies db)) + appBounds + :: L.HasBuildInfo a + => CondTree v [Dependency] a + -> CondTree v [Dependency] a + appBounds = applyDefaultBoundsToCondTree defBounds -- Combine lib, exes, and tests into one list of @CondTree@s with tagged data condTrees = - appBoundsConstrs $ - maybeToList (fmap (mapTreeData (Lib . appBounds)) mb_lib0) - ++ map (\(name, tree) -> mapTreeData (SubComp name . CLib . appBounds) tree) sub_libs0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CFLib . appBounds) tree) flibs0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CExe . appBounds) tree) exes0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CTest . appBounds) tree) tests0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CBench . appBounds) tree) bms0 + maybeToList (fmap (mapTreeData Lib . appBounds) mb_lib0) + ++ map (\(name, tree) -> mapTreeData (SubComp name . CLib) $ appBounds tree) sub_libs0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CFLib) $ appBounds tree) flibs0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CExe) $ appBounds tree) exes0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CTest) $ appBounds tree) tests0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CBench) $ appBounds tree) bms0 flagChoices = map (\(MkPackageFlag n _ d manual) -> (n, d2c manual n d)) flags d2c manual n b = case lookupFlagAssignment n userflags of @@ -688,4 +683,4 @@ transformDefaultBuildDepends -> GenericPackageDescription -> GenericPackageDescription transformDefaultBuildDepends f = - over (L.genDefaultPackageBounds . traverse . L.defaultTargetBuildDepends . traverse) f + over (L.genDefaultPackageBounds . L.defaultTargetBuildDepends . traverse) f diff --git a/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs b/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs index 692274dbf48..2959aba17fd 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/Parsec.hs @@ -398,8 +398,8 @@ goSections specVer = traverse_ process | name == "default-package-bounds" = if specVer >= CabalSpecV3_14 then do - sbi <- lift $ parseFields specVer fields defaultPackageBoundsFieldGrammar - stateGpd . L.genDefaultPackageBounds .= Just sbi + dpb <- lift $ parseFields specVer fields defaultPackageBoundsFieldGrammar + stateGpd . L.genDefaultPackageBounds .= dpb else lift $ parseWarning pos PWTUnknownSection $ "Ignoring section: default-package-bounds. You should set cabal-version: 3.14 or larger to use default-package-bounds." | name == "custom-setup" && null args = do sbi <- lift $ parseFields specVer fields (setupBInfoFieldGrammar False) diff --git a/Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs b/Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs index 7579886d0c9..cf57578fb6b 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/PrettyPrint.hs @@ -231,7 +231,7 @@ pdToGpd pd = { packageDescription = pd , gpdScannedVersion = Nothing , genPackageFlags = [] - , genDefaultPackageBounds = Nothing + , genDefaultPackageBounds = emptyDefaultBounds , condLibrary = mkCondTree <$> library pd , condSubLibraries = mkCondTreeL <$> subLibraries pd , condForeignLibs = mkCondTree' foreignLibName <$> foreignLibs pd diff --git a/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs b/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs index d9e95d70727..b21da2e87a7 100644 --- a/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs +++ b/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs @@ -3,10 +3,8 @@ module Distribution.Types.DefaultBounds ( DefaultBounds (..) - , applyDefaultBoundsToBuildInfo - , applyDefaultBoundsToDependencies - , applyDefaultBoundsToExeDependencies , applyDefaultBoundsToCondTree + , emptyDefaultBounds ) where import Distribution.Compat.Lens @@ -28,21 +26,26 @@ instance Binary DefaultBounds instance Structured DefaultBounds instance NFData DefaultBounds where rnf = genericRnf +emptyDefaultBounds :: DefaultBounds +emptyDefaultBounds = DefaultBounds [] [] + applyDefaultBoundsToCondTree :: L.HasBuildInfo a => DefaultBounds -> CondTree cv [Dependency] a -> CondTree cv [Dependency] a applyDefaultBoundsToCondTree db = - mapTreeData (applyDefaultBoundsToBuildInfo db) . mapTreeConstrs (applyDefaultBoundsToDependencies db) + mapTreeData (applyDefaultBoundsToBuildInfo db) + . mapTreeConstrs (applyDefaultBoundsToDependencies db) applyDefaultBoundsToBuildInfo :: L.HasBuildInfo a => DefaultBounds -> a -> a applyDefaultBoundsToBuildInfo db bi = bi & L.targetBuildDepends %~ applyDefaultBoundsToDependencies db - & L.buildToolDepends %~ applyDefaultBoundsToExeDependencies db + & L.buildToolDepends %~ applyDefaultBoundsToExeDependencies db applyDefaultBoundsToDependencies :: DefaultBounds -> [Dependency] -> [Dependency] +applyDefaultBoundsToDependencies (DefaultBounds [] _) = id applyDefaultBoundsToDependencies (DefaultBounds bd _) = map ( \dep@(Dependency pkg vorig l) -> @@ -52,6 +55,7 @@ applyDefaultBoundsToDependencies (DefaultBounds bd _) = ) applyDefaultBoundsToExeDependencies :: DefaultBounds -> [ExeDependency] -> [ExeDependency] +applyDefaultBoundsToExeDependencies (DefaultBounds _ []) = id applyDefaultBoundsToExeDependencies (DefaultBounds _ btd) = map ( \dep@(ExeDependency pkg comp vorig) -> diff --git a/Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs b/Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs index 2b5ed006da7..ef1ef69bc39 100644 --- a/Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs +++ b/Cabal-syntax/src/Distribution/Types/GenericPackageDescription.hs @@ -44,7 +44,7 @@ data GenericPackageDescription = GenericPackageDescription -- Perfectly, PackageIndex should have sum type, so we don't need to -- have dummy GPDs. , genPackageFlags :: [PackageFlag] - , genDefaultPackageBounds :: Maybe DefaultBounds + , genDefaultPackageBounds :: DefaultBounds , condLibrary :: Maybe (CondTree ConfVar [Dependency] Library) , condSubLibraries :: [ ( UnqualComponentName @@ -82,7 +82,7 @@ instance Structured GenericPackageDescription instance NFData GenericPackageDescription where rnf = genericRnf emptyGenericPackageDescription :: GenericPackageDescription -emptyGenericPackageDescription = GenericPackageDescription emptyPackageDescription Nothing [] Nothing Nothing [] [] [] [] [] +emptyGenericPackageDescription = GenericPackageDescription emptyPackageDescription Nothing [] emptyDefaultBounds Nothing [] [] [] [] [] -- ----------------------------------------------------------------------------- -- Traversal Instances diff --git a/Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs b/Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs index 539e5950064..21105f7d9e9 100644 --- a/Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs +++ b/Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs @@ -50,7 +50,7 @@ genPackageFlags :: Lens' GenericPackageDescription [PackageFlag] genPackageFlags f s = fmap (\x -> s{T.genPackageFlags = x}) (f (T.genPackageFlags s)) {-# INLINE genPackageFlags #-} -genDefaultPackageBounds :: Lens' GenericPackageDescription (Maybe DefaultBounds) +genDefaultPackageBounds :: Lens' GenericPackageDescription DefaultBounds genDefaultPackageBounds f s = fmap (\x -> s{T.genDefaultPackageBounds = x}) (f (T.genDefaultPackageBounds s)) {-# INLINE genDefaultPackageBounds #-} diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index c6aeceed141..66efe7977ce 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -274,7 +274,7 @@ checkGenericPackageDescription -- Flag names. mapM_ checkFlagName genPackageFlags_ -- default package bounds - mapM_ checkDefaultBounds genDefaultPackageBounds_ + checkDefaultBounds genDefaultPackageBounds_ -- § Feature checks. checkSpecVer @@ -301,7 +301,7 @@ checkGenericPackageDescription let ads = maybe [] ((: []) . extractAssocDeps pName) condLibrary_ ++ map (uncurry extractAssocDeps) condSubLibraries_ - ++ maybe [] ((: []) . Left . defaultTargetBuildDepends) genDefaultPackageBounds_ + ++ ((: []) . Left . defaultTargetBuildDepends) genDefaultPackageBounds_ case condLibrary_ of Just cl -> diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs b/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs index 5060d1cc552..2621e639ef6 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs @@ -183,7 +183,7 @@ convGPD os arch cinfo constraints strfl solveExes pn appBounds :: HasBuildInfo a => CondTree cv [Dependency] a -> CondTree cv [Dependency] a - appBounds = maybe id applyDefaultBoundsToCondTree defBounds + appBounds = applyDefaultBoundsToCondTree defBounds conv :: Monoid a => Component -> (a -> BuildInfo) -> DependencyReason PN -> CondTree ConfVar [Dependency] a -> FlaggedDeps PN diff --git a/cabal-install/src/Distribution/Client/IndexUtils.hs b/cabal-install/src/Distribution/Client/IndexUtils.hs index 646deb96687..fb8681864a9 100644 --- a/cabal-install/src/Distribution/Client/IndexUtils.hs +++ b/cabal-install/src/Distribution/Client/IndexUtils.hs @@ -79,6 +79,7 @@ import Distribution.Package import Distribution.PackageDescription ( GenericPackageDescription (..) , PackageDescription (..) + , emptyDefaultBounds , emptyPackageDescription ) import Distribution.Simple.Compiler @@ -1075,7 +1076,7 @@ packageListFromCache verbosity mkPkg hnd Cache{..} = accum mempty [] mempty cach } , gpdScannedVersion = Just specVer -- tells index scanner to skip this file. , genPackageFlags = [] - , genDefaultPackageBounds = Nothing + , genDefaultPackageBounds = emptyDefaultBounds , condLibrary = Nothing , condSubLibraries = [] , condForeignLibs = [] diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index 81c49d0aceb..e5415a7d766 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -467,7 +467,7 @@ testTargetSelectorAmbiguous reportSubCase = do packageDescription = emptyPackageDescription { package = pkgid }, gpdScannedVersion = Nothing, genPackageFlags = [], - genDefaultPackageBounds = Nothing, + genDefaultPackageBounds = emptyDefaultBounds, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs index 914ce6f2b55..3c9d9a0e43b 100644 --- a/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs +++ b/cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs @@ -455,7 +455,7 @@ exAvSrcPkg ex = } , C.gpdScannedVersion = Nothing , C.genPackageFlags = flags - , C.genDefaultPackageBounds = Nothing + , C.genDefaultPackageBounds = C.emptyDefaultBounds , C.condLibrary = let mkLib v bi = mempty{C.libVisibility = v, C.libBuildInfo = bi} -- Avoid using the Monoid instance for [a] when getting From d1d698a4c0ffce0fe617c619aef79f683a6f3c75 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Fri, 5 Jul 2024 15:27:29 +0200 Subject: [PATCH 7/7] Fix tests --- .../Distribution/PackageDescription/Configuration.hs | 10 +++++----- Cabal-syntax/src/Distribution/Types/DefaultBounds.hs | 6 +++--- .../tests/ParserTests/regressions/Octree-0.5.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/anynone.expr | 4 +++- .../tests/ParserTests/regressions/big-version.expr | 4 +++- .../ParserTests/regressions/common-conditional.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/common.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/common2.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/common3.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/elif.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/elif2.expr | 4 +++- .../tests/ParserTests/regressions/encoding-0.8.expr | 4 +++- .../tests/ParserTests/regressions/generics-sop.expr | 4 +++- .../tests/ParserTests/regressions/hasktorch.expr | 4 +++- .../tests/ParserTests/regressions/hidden-main-lib.expr | 4 +++- .../tests/ParserTests/regressions/indentation.expr | 4 +++- .../tests/ParserTests/regressions/indentation2.expr | 4 +++- .../tests/ParserTests/regressions/indentation3.expr | 4 +++- .../tests/ParserTests/regressions/issue-5055.expr | 4 +++- .../tests/ParserTests/regressions/issue-5846.expr | 4 +++- .../tests/ParserTests/regressions/issue-6083-a.expr | 4 +++- .../tests/ParserTests/regressions/issue-6083-b.expr | 4 +++- .../tests/ParserTests/regressions/issue-6083-c.expr | 4 +++- .../ParserTests/regressions/issue-6083-pkg-pkg.expr | 4 +++- .../tests/ParserTests/regressions/issue-774.expr | 4 +++- .../ParserTests/regressions/jaeger-flamegraph.expr | 4 +++- .../tests/ParserTests/regressions/leading-comma-2.expr | 4 +++- .../tests/ParserTests/regressions/leading-comma.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/libpq1.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/libpq2.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/mixin-1.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/mixin-2.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/mixin-3.expr | 4 +++- .../tests/ParserTests/regressions/monad-param.expr | 4 +++- .../tests/ParserTests/regressions/multiple-libs-2.expr | 4 +++- .../tests/ParserTests/regressions/noVersion.expr | 4 +++- .../tests/ParserTests/regressions/nothing-unicode.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/shake.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/spdx-1.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/spdx-2.expr | 4 +++- Cabal-tests/tests/ParserTests/regressions/spdx-3.expr | 4 +++- .../ParserTests/regressions/th-lift-instances.expr | 4 +++- .../tests/ParserTests/regressions/version-sets.expr | 4 +++- .../tests/ParserTests/regressions/wl-pprint-indef.expr | 4 +++- .../tests/UnitTests/Distribution/Utils/Structured.hs | 4 ++-- 45 files changed, 136 insertions(+), 52 deletions(-) diff --git a/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs b/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs index 988039ee187..6c10796b4a7 100644 --- a/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs +++ b/Cabal-syntax/src/Distribution/PackageDescription/Configuration.hs @@ -520,11 +520,11 @@ finalizePD -- Combine lib, exes, and tests into one list of @CondTree@s with tagged data condTrees = maybeToList (fmap (mapTreeData Lib . appBounds) mb_lib0) - ++ map (\(name, tree) -> mapTreeData (SubComp name . CLib) $ appBounds tree) sub_libs0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CFLib) $ appBounds tree) flibs0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CExe) $ appBounds tree) exes0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CTest) $ appBounds tree) tests0 - ++ map (\(name, tree) -> mapTreeData (SubComp name . CBench) $ appBounds tree) bms0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CLib) $ appBounds tree) sub_libs0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CFLib) $ appBounds tree) flibs0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CExe) $ appBounds tree) exes0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CTest) $ appBounds tree) tests0 + ++ map (\(name, tree) -> mapTreeData (SubComp name . CBench) $ appBounds tree) bms0 flagChoices = map (\(MkPackageFlag n _ d manual) -> (n, d2c manual n d)) flags d2c manual n b = case lookupFlagAssignment n userflags of diff --git a/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs b/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs index b21da2e87a7..e25081d3b79 100644 --- a/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs +++ b/Cabal-syntax/src/Distribution/Types/DefaultBounds.hs @@ -35,14 +35,14 @@ applyDefaultBoundsToCondTree -> CondTree cv [Dependency] a -> CondTree cv [Dependency] a applyDefaultBoundsToCondTree db = - mapTreeData (applyDefaultBoundsToBuildInfo db) - . mapTreeConstrs (applyDefaultBoundsToDependencies db) + mapTreeData (applyDefaultBoundsToBuildInfo db) + . mapTreeConstrs (applyDefaultBoundsToDependencies db) applyDefaultBoundsToBuildInfo :: L.HasBuildInfo a => DefaultBounds -> a -> a applyDefaultBoundsToBuildInfo db bi = bi & L.targetBuildDepends %~ applyDefaultBoundsToDependencies db - & L.buildToolDepends %~ applyDefaultBoundsToExeDependencies db + & L.buildToolDepends %~ applyDefaultBoundsToExeDependencies db applyDefaultBoundsToDependencies :: DefaultBounds -> [Dependency] -> [Dependency] applyDefaultBoundsToDependencies (DefaultBounds [] _) = id diff --git a/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr b/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr index 77a263aaad3..b4a49ccc2d7 100644 --- a/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr +++ b/Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr @@ -70,7 +70,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/anynone.expr b/Cabal-tests/tests/ParserTests/regressions/anynone.expr index 555b5fd6c66..f1067157c45 100644 --- a/Cabal-tests/tests/ParserTests/regressions/anynone.expr +++ b/Cabal-tests/tests/ParserTests/regressions/anynone.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/big-version.expr b/Cabal-tests/tests/ParserTests/regressions/big-version.expr index d7aa02f7f07..cbd5943833e 100644 --- a/Cabal-tests/tests/ParserTests/regressions/big-version.expr +++ b/Cabal-tests/tests/ParserTests/regressions/big-version.expr @@ -38,7 +38,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr b/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr index 45daaff5348..436e22a0f2d 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common-conditional.expr @@ -53,7 +53,9 @@ GenericPackageDescription { flagDefault = True, flagManual = True}], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/common.expr b/Cabal-tests/tests/ParserTests/regressions/common.expr index 9fcc46d63b1..e65978caced 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common.expr @@ -51,7 +51,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/common2.expr b/Cabal-tests/tests/ParserTests/regressions/common2.expr index 8607bde5f3a..d6f2d6d135a 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common2.expr @@ -47,7 +47,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/common3.expr b/Cabal-tests/tests/ParserTests/regressions/common3.expr index f79fc0b4a0f..3d53b2b0f0b 100644 --- a/Cabal-tests/tests/ParserTests/regressions/common3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/common3.expr @@ -51,7 +51,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/elif.expr b/Cabal-tests/tests/ParserTests/regressions/elif.expr index 60071a7c48b..9f7e8482ece 100644 --- a/Cabal-tests/tests/ParserTests/regressions/elif.expr +++ b/Cabal-tests/tests/ParserTests/regressions/elif.expr @@ -46,7 +46,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/elif2.expr b/Cabal-tests/tests/ParserTests/regressions/elif2.expr index c7b68fb69b7..4668688e663 100644 --- a/Cabal-tests/tests/ParserTests/regressions/elif2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/elif2.expr @@ -46,7 +46,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr b/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr index 9222eaff9aa..59d63060ef4 100644 --- a/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr +++ b/Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr @@ -51,7 +51,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr b/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr index ac2c0ea4d6e..55277874d94 100644 --- a/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr +++ b/Cabal-tests/tests/ParserTests/regressions/generics-sop.expr @@ -127,7 +127,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr b/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr index 2a70a60f71e..cf7fe6eedfc 100644 --- a/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr +++ b/Cabal-tests/tests/ParserTests/regressions/hasktorch.expr @@ -70,7 +70,9 @@ GenericPackageDescription { flagDefault = False, flagManual = False}], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr b/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr index 8d400ac671f..ecb716c2ee9 100644 --- a/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr +++ b/Cabal-tests/tests/ParserTests/regressions/hidden-main-lib.expr @@ -38,7 +38,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation.expr b/Cabal-tests/tests/ParserTests/regressions/indentation.expr index cc303c75b75..d742213c3c6 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation.expr @@ -48,7 +48,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation2.expr b/Cabal-tests/tests/ParserTests/regressions/indentation2.expr index d0c46a34eab..3f3dde4a3e9 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation2.expr @@ -41,7 +41,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/indentation3.expr b/Cabal-tests/tests/ParserTests/regressions/indentation3.expr index 0ba1404c095..675f94b22ca 100644 --- a/Cabal-tests/tests/ParserTests/regressions/indentation3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/indentation3.expr @@ -43,7 +43,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr b/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr index f84e6506f38..2fca3955892 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-5055.expr @@ -38,7 +38,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr b/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr index 58da04c977b..652d4688641 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-5846.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr index d3d213d58ab..c4ba4522650 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-a.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr index c8cca40546e..c3d6b143bc5 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-b.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr index 08d463693a5..2f4c59e9e5b 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-c.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr b/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr index 39f2efc4598..857b8166ece 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-6083-pkg-pkg.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/issue-774.expr b/Cabal-tests/tests/ParserTests/regressions/issue-774.expr index 1c392d38e8a..dff32630a91 100644 --- a/Cabal-tests/tests/ParserTests/regressions/issue-774.expr +++ b/Cabal-tests/tests/ParserTests/regressions/issue-774.expr @@ -45,7 +45,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr b/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr index 84a24f82a7c..a0c3d508b71 100644 --- a/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr +++ b/Cabal-tests/tests/ParserTests/regressions/jaeger-flamegraph.expr @@ -77,7 +77,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr b/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr index ffe1cfccd7a..c6389e7b6f6 100644 --- a/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/leading-comma-2.expr @@ -38,7 +38,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr b/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr index 1f67c72f846..f02f80e4f7e 100644 --- a/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr +++ b/Cabal-tests/tests/ParserTests/regressions/leading-comma.expr @@ -38,7 +38,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/libpq1.expr b/Cabal-tests/tests/ParserTests/regressions/libpq1.expr index 47287fbc8eb..d6d35d761f3 100644 --- a/Cabal-tests/tests/ParserTests/regressions/libpq1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/libpq1.expr @@ -121,7 +121,9 @@ GenericPackageDescription { flagDefault = False, flagManual = True}], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/libpq2.expr b/Cabal-tests/tests/ParserTests/regressions/libpq2.expr index 636a25c7741..c197379499b 100644 --- a/Cabal-tests/tests/ParserTests/regressions/libpq2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/libpq2.expr @@ -125,7 +125,9 @@ GenericPackageDescription { flagDefault = False, flagManual = True}], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr index 4d37fd39187..b9da1e71899 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-1.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr index 0da2ce70a39..d8bc0720674 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-2.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr b/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr index 03965350e71..f7587968bcb 100644 --- a/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/mixin-3.expr @@ -36,7 +36,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Nothing, condSubLibraries = [], condForeignLibs = [], diff --git a/Cabal-tests/tests/ParserTests/regressions/monad-param.expr b/Cabal-tests/tests/ParserTests/regressions/monad-param.expr index 17e2c63e6c0..f52da60c53a 100644 --- a/Cabal-tests/tests/ParserTests/regressions/monad-param.expr +++ b/Cabal-tests/tests/ParserTests/regressions/monad-param.expr @@ -46,7 +46,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr b/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr index 284e62e180c..bca8eaa8a7b 100644 --- a/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/multiple-libs-2.expr @@ -38,7 +38,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/noVersion.expr b/Cabal-tests/tests/ParserTests/regressions/noVersion.expr index f55c7d357bb..bf2cf7f7a7c 100644 --- a/Cabal-tests/tests/ParserTests/regressions/noVersion.expr +++ b/Cabal-tests/tests/ParserTests/regressions/noVersion.expr @@ -38,7 +38,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr b/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr index 0bc096e13f3..edecfc7f43b 100644 --- a/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr +++ b/Cabal-tests/tests/ParserTests/regressions/nothing-unicode.expr @@ -53,7 +53,9 @@ GenericPackageDescription { flagDefault = True, flagManual = False}], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/shake.expr b/Cabal-tests/tests/ParserTests/regressions/shake.expr index 44f7e65c866..7bfd4b9139f 100644 --- a/Cabal-tests/tests/ParserTests/regressions/shake.expr +++ b/Cabal-tests/tests/ParserTests/regressions/shake.expr @@ -159,7 +159,9 @@ GenericPackageDescription { flagDefault = False, flagManual = True}], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr index 333848da482..04b3807e7b7 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-1.expr @@ -37,7 +37,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr index 5d418bb5508..96b906c5b8a 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-2.expr @@ -41,7 +41,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr b/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr index 0986d96f7c4..91373c8d049 100644 --- a/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr +++ b/Cabal-tests/tests/ParserTests/regressions/spdx-3.expr @@ -41,7 +41,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr b/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr index b963a3a8346..3a4efbe7c82 100644 --- a/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr +++ b/Cabal-tests/tests/ParserTests/regressions/th-lift-instances.expr @@ -65,7 +65,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/version-sets.expr b/Cabal-tests/tests/ParserTests/regressions/version-sets.expr index 4191afac338..e7f924f2fed 100644 --- a/Cabal-tests/tests/ParserTests/regressions/version-sets.expr +++ b/Cabal-tests/tests/ParserTests/regressions/version-sets.expr @@ -63,7 +63,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr b/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr index 27188d028fb..247d6898316 100644 --- a/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr +++ b/Cabal-tests/tests/ParserTests/regressions/wl-pprint-indef.expr @@ -55,7 +55,9 @@ GenericPackageDescription { gpdScannedVersion = Nothing, genPackageFlags = [], genDefaultPackageBounds = - Nothing, + DefaultBounds { + defaultTargetBuildDepends = [], + defaultBuildToolDepends = []}, condLibrary = Just CondNode { condTreeData = Library { diff --git a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs index 70370de76c0..bbc85e7606e 100644 --- a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs +++ b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs @@ -33,9 +33,9 @@ md5Check proxy md5Int = structureHash proxy @?= md5FromInteger md5Int md5CheckGenericPackageDescription :: Proxy GenericPackageDescription -> Assertion md5CheckGenericPackageDescription proxy = md5Check proxy #if MIN_VERSION_base(4,19,0) - 0xbcb29fedd00cda89586faf963028e31d + 0x84a6403bd4a83748acebe9d676b8e1cb #else - 0xbb48247a1d86d5b514ffc4d6df853c74 + 0xb853c69731d382446f1ae86485f953ac #endif md5CheckLocalBuildInfo :: Proxy LocalBuildInfo -> Assertion