Unverified Commit 613a2a25 authored by Oleg Grenrus's avatar Oleg Grenrus Committed by GitHub
Browse files

Merge pull request #6653 from phadej/spec-field-cabalspecversion

Change specVersion to have CabalSpecVersion type
parents 26b2defe 68ca5e06
......@@ -35,18 +35,25 @@ RUN cabal v2-install -w ghc-7.6.3 --lib \
edit-distance \
haskell-lexer \
HTTP \
nats \
network \
optparse-applicative \
parsec \
pretty-show \
regex-compat-tdfa \
regex-tdfa \
rere \
semigroups \
statistics \
tar \
tasty \
tasty-golden \
tasty-hunit \
tasty-quickcheck \
text \
tree-diff \
unordered-containers \
void \
zlib \
--constraint="bytestring installed" \
--constraint="binary installed" \
......
......@@ -37,16 +37,21 @@ RUN cabal v2-install -w ghc-7.8.4 --lib \
HTTP \
network \
optparse-applicative \
parsec \
pretty-show \
regex-compat-tdfa \
regex-tdfa \
rere \
semigroups \
statistics \
tar \
tasty \
tasty-golden \
tasty-hunit \
tasty-quickcheck \
text \
tree-diff \
unordered-containers \
zlib \
--constraint="bytestring installed" \
--constraint="binary installed" \
......
......@@ -42,6 +42,7 @@ RUN cabal v2-install -w ghc-8.8.1 --lib \
pretty-show \
regex-compat-tdfa \
regex-tdfa \
rere \
resolv \
statistics \
tar \
......@@ -50,6 +51,7 @@ RUN cabal v2-install -w ghc-8.8.1 --lib \
tasty-hunit \
tasty-quickcheck \
tree-diff \
unordered-containers \
zlib \
&& rm -rf $HOME/.ghc
......
......@@ -8,6 +8,7 @@ import Data.List (intercalate)
import Distribution.Utils.Generic (lowercase)
import Test.QuickCheck
import Distribution.CabalSpecVersion
import Distribution.Simple.Flag (Flag (..))
import Distribution.SPDX
import Distribution.System
......@@ -21,11 +22,22 @@ import Distribution.ModuleName
import Distribution.Types.VersionRange.Internal
import Distribution.Verbosity
import Distribution.Version
import Distribution.Parsec.Newtypes
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative (pure, (<$>), (<*>))
#endif
-------------------------------------------------------------------------------
-- CabalSpecVersion
-------------------------------------------------------------------------------
instance Arbitrary CabalSpecVersion where
arbitrary = arbitraryBoundedEnum
instance Arbitrary SpecVersion where
arbitrary = fmap SpecVersion arbitrary
-------------------------------------------------------------------------------
-- PackageName
-------------------------------------------------------------------------------
......
......@@ -251,6 +251,9 @@ extra-source-files:
tests/ParserTests/warnings/newsyntax.cabal
tests/ParserTests/warnings/oldsyntax.cabal
tests/ParserTests/warnings/operator.cabal
tests/ParserTests/warnings/specversion-a.cabal
tests/ParserTests/warnings/specversion-b.cabal
tests/ParserTests/warnings/specversion-c.cabal
tests/ParserTests/warnings/subsection.cabal
tests/ParserTests/warnings/tab.cabal
tests/ParserTests/warnings/trailingfield.cabal
......@@ -623,6 +626,7 @@ test-suite unit-tests
other-modules:
Test.Laws
Test.QuickCheck.Utils
UnitTests.Distribution.CabalSpecVersion
UnitTests.Distribution.Compat.CreatePipe
UnitTests.Distribution.Compat.Graph
UnitTests.Distribution.Compat.Time
......
......@@ -21,6 +21,7 @@ import Distribution.Compat.Prelude hiding ((<>))
import Distribution.Backpack.Id
import Distribution.CabalSpecVersion
import Distribution.Types.AnnotatedId
import Distribution.Types.Dependency
import Distribution.Types.ExeDependency
......@@ -38,7 +39,6 @@ import Distribution.PackageDescription as PD hiding (Flag)
import Distribution.Simple.BuildToolDepends
import Distribution.Simple.Setup as Setup
import Distribution.Simple.LocalBuildInfo
import Distribution.Version
import Distribution.Utils.LogProgress
import Distribution.Utils.MapAccum
import Distribution.Utils.Generic
......@@ -292,8 +292,8 @@ toConfiguredComponents
m component
return (extendConfiguredComponentMap cc m, cc)
newPackageDepsBehaviourMinVersion :: Version
newPackageDepsBehaviourMinVersion = mkVersion [1,7,1]
newPackageDepsBehaviourMinVersion :: CabalSpecVersion
newPackageDepsBehaviourMinVersion = CabalSpecV1_8
-- In older cabal versions, there was only one set of package dependencies for
......
......@@ -26,8 +26,17 @@ data CabalSpecVersion
| CabalSpecV2_2
| CabalSpecV2_4
| CabalSpecV3_0
-- ^ we need this value for solver
-- to represent GPDs which it should skip
--
-- We could filter the files already in package reading phase,
-- but then files would be silently omitted.
deriving (Eq, Ord, Show, Read, Enum, Bounded, Typeable, Data, Generic)
instance Binary CabalSpecVersion
instance Structured CabalSpecVersion
instance NFData CabalSpecVersion where rnf = genericRnf
-- | Show cabal spec version, but not the way in the .cabal files
--
-- @since 3.0.0.0
......@@ -51,23 +60,65 @@ showCabalSpecVersion CabalSpecV1_0 = "1.0"
cabalSpecLatest :: CabalSpecVersion
cabalSpecLatest = CabalSpecV3_0
cabalSpecFromVersionDigits :: [Int] -> CabalSpecVersion
-- | Parse 'CabalSpecVersion' from version digits.
--
-- It may fail if for recent versions the version is not exact.
--
cabalSpecFromVersionDigits :: [Int] -> Maybe CabalSpecVersion
cabalSpecFromVersionDigits v
| v >= [2,5] = CabalSpecV3_0
| v >= [2,3] = CabalSpecV2_4
| v >= [2,1] = CabalSpecV2_2
| v >= [1,25] = CabalSpecV2_0
| v >= [1,23] = CabalSpecV1_24
| v >= [1,21] = CabalSpecV1_22
| v >= [1,19] = CabalSpecV1_20
| v >= [1,17] = CabalSpecV1_18
| v >= [1,11] = CabalSpecV1_12
| v >= [1,9] = CabalSpecV1_10
| v >= [1,7] = CabalSpecV1_8
| v >= [1,5] = CabalSpecV1_6
| v >= [1,3] = CabalSpecV1_4
| v >= [1,1] = CabalSpecV1_2
| otherwise = CabalSpecV1_0
| v == [3,0] = Just CabalSpecV3_0
| v >= [3] = Nothing
| v >= [2,3] = Just CabalSpecV2_4
| v >= [2,1] = Just CabalSpecV2_2
| v >= [1,25] = Just CabalSpecV2_0
| v >= [1,23] = Just CabalSpecV1_24
| v >= [1,21] = Just CabalSpecV1_22
| v >= [1,19] = Just CabalSpecV1_20
| v >= [1,17] = Just CabalSpecV1_18
| v >= [1,11] = Just CabalSpecV1_12
| v >= [1,9] = Just CabalSpecV1_10
| v >= [1,7] = Just CabalSpecV1_8
| v >= [1,5] = Just CabalSpecV1_6
| v >= [1,3] = Just CabalSpecV1_4
| v >= [1,1] = Just CabalSpecV1_2
| otherwise = Just CabalSpecV1_0
-- | @since 3.4.0.0
cabalSpecToVersionDigits :: CabalSpecVersion -> [Int]
cabalSpecToVersionDigits CabalSpecV3_0 = [3,0]
cabalSpecToVersionDigits CabalSpecV2_4 = [2,4]
cabalSpecToVersionDigits CabalSpecV2_2 = [2,2]
cabalSpecToVersionDigits CabalSpecV2_0 = [2,0]
cabalSpecToVersionDigits CabalSpecV1_24 = [1,24]
cabalSpecToVersionDigits CabalSpecV1_22 = [1,22]
cabalSpecToVersionDigits CabalSpecV1_20 = [1,20]
cabalSpecToVersionDigits CabalSpecV1_18 = [1,18]
cabalSpecToVersionDigits CabalSpecV1_12 = [1,12]
cabalSpecToVersionDigits CabalSpecV1_10 = [1,10]
cabalSpecToVersionDigits CabalSpecV1_8 = [1,8]
cabalSpecToVersionDigits CabalSpecV1_6 = [1,6]
cabalSpecToVersionDigits CabalSpecV1_4 = [1,4]
cabalSpecToVersionDigits CabalSpecV1_2 = [1,2]
cabalSpecToVersionDigits CabalSpecV1_0 = [1,0]
-- | What is the minimum Cabal library version which knows how handle
-- this spec version.
--
-- /Note:/ this is a point where we could decouple cabal-spec and Cabal
-- versions, if we ever want that.
--
-- >>> cabalSpecMinimumLibraryVersion CabalSpecV3_0
-- [2,5]
--
-- >>> cabalSpecMinimumLibraryVersion CabalSpecV2_4
-- [2,3]
--
-- @since 3.4.0.0
cabalSpecMinimumLibraryVersion :: CabalSpecVersion -> [Int]
cabalSpecMinimumLibraryVersion CabalSpecV1_0 = [1,0]
cabalSpecMinimumLibraryVersion csv = case cabalSpecToVersionDigits (pred csv) of
[x,y] -> [x, y+1]
xs -> xs
specHasCommonStanzas :: CabalSpecVersion -> HasCommonStanzas
specHasCommonStanzas v =
......
......@@ -15,7 +15,8 @@ module Distribution.Fields.ParseResult (
getCabalSpecVersion,
setCabalSpecVersion,
readAndParseFile,
parseString
parseString,
withoutWarnings,
) where
import qualified Data.ByteString.Char8 as BS
......@@ -42,11 +43,21 @@ newtype ParseResult a = PR
-> r
}
-- Note: we have version here, as we could get any version.
data PRState = PRState ![PWarning] ![PError] !(Maybe Version)
emptyPRState :: PRState
emptyPRState = PRState [] [] Nothing
-- | Forget 'ParseResult's warnings.
--
-- @since 3.4.0.0
withoutWarnings :: ParseResult a -> ParseResult a
withoutWarnings m = PR $ \s failure success ->
unPR m s failure $ \ !s1 -> success (s1 `withWarningsOf` s)
where
withWarningsOf (PRState _ e v) (PRState w _ _) = PRState w e v
-- | Destruct a 'ParseResult' into the emitted warnings and either
-- a successful value or
-- list of errors and possibly recovered a spec-version declaration.
......
......@@ -14,7 +14,6 @@ module Distribution.PackageDescription (
-- * Package descriptions
PackageDescription(..),
emptyPackageDescription,
specVersion,
buildType,
license,
BuildType(..),
......
......@@ -38,6 +38,7 @@ import Prelude ()
import Control.Monad (mapM)
import Data.List (group)
import Distribution.CabalSpecVersion
import Distribution.Compat.Lens
import Distribution.Compiler
import Distribution.License
......@@ -122,11 +123,11 @@ check :: Bool -> PackageCheck -> Maybe PackageCheck
check False _ = Nothing
check True pc = Just pc
checkSpecVersion :: PackageDescription -> [Int] -> Bool -> PackageCheck
checkSpecVersion :: PackageDescription -> CabalSpecVersion -> Bool -> PackageCheck
-> Maybe PackageCheck
checkSpecVersion pkg specver cond pc
| specVersion pkg >= mkVersion specver = Nothing
| otherwise = check cond pc
| specVersion pkg >= specver = Nothing
| otherwise = check cond pc
-- ------------------------------------------------------------
-- * Standard checks
......@@ -226,14 +227,6 @@ checkSanity pkg =
++ concatMap (checkTestSuite pkg) (testSuites pkg)
++ concatMap (checkBenchmark pkg) (benchmarks pkg)
++ catMaybes [
check (specVersion pkg > cabalVersion) $
PackageBuildImpossible $
"This package description follows version "
++ prettyShow (specVersion pkg) ++ " of the Cabal specification. This "
++ "tool only supports up to version " ++ prettyShow cabalVersion ++ "."
]
where
-- The public 'library' gets special dispensation, because it
-- is common practice to export a library and name the executable
......@@ -259,7 +252,7 @@ checkLibrary pkg lib =
showLibraryName (libName lib) ++ " does not expose any modules"
-- check use of signatures sections
, checkVersion [1,25] (not (null (signatures lib))) $
, checkVersion CabalSpecV2_0 (not (null (signatures lib))) $
PackageDistInexcusable $
"To use the 'signatures' field the package needs to specify "
++ "at least 'cabal-version: 2.0'."
......@@ -280,10 +273,10 @@ checkLibrary pkg lib =
]
where
checkVersion :: [Int] -> Bool -> PackageCheck -> Maybe PackageCheck
checkVersion :: CabalSpecVersion -> Bool -> PackageCheck -> Maybe PackageCheck
checkVersion ver cond pc
| specVersion pkg >= mkVersion ver = Nothing
| otherwise = check cond pc
| specVersion pkg >= ver = Nothing
| otherwise = check cond pc
-- TODO: not sure if this check is always right in Backpack
moduleDuplicates = dups (explicitLibModules lib ++
......@@ -307,7 +300,7 @@ checkExecutable pkg exe =
++ "(even if it is generated by a preprocessor), "
++ "or it may specify a C/C++/obj-C source file."
, checkSpecVersion pkg [1,17]
, checkSpecVersion pkg CabalSpecV1_18
(fileExtensionSupportedLanguage (modulePath exe)
&& takeExtension (modulePath exe) `notElem` [".hs", ".lhs"]) $
PackageDistInexcusable $
......@@ -363,7 +356,7 @@ checkTestSuite pkg test =
++ "(even if it is generated by a preprocessor), "
++ "or it may specify a C/C++/obj-C source file."
, checkSpecVersion pkg [1,17] (mainIsNotHsExt && not mainIsWrongExt) $
, checkSpecVersion pkg CabalSpecV1_18 (mainIsNotHsExt && not mainIsWrongExt) $
PackageDistInexcusable $
"The package uses a C/C++/obj-C source file for the 'main-is' field. "
++ "To use this feature you must specify 'cabal-version: >= 1.18'."
......@@ -458,7 +451,7 @@ checkFields pkg =
"Package names with the prefix 'z-' are reserved by Cabal and "
++ "cannot be used."
, check (isNothing (buildTypeRaw pkg) && specVersion pkg < mkVersion [2,1]) $
, check (isNothing (buildTypeRaw pkg) && specVersion pkg < CabalSpecV2_2) $
PackageBuildWarning $
"No 'build-type' specified. If you do not need a custom Setup.hs or "
++ "./configure script then use 'build-type: Simple'."
......@@ -680,7 +673,7 @@ checkOldLicense pkg lic = catMaybes
PackageDistSuspicious
"The 'license' is AllRightsReserved. Is that really what you want?"
, checkVersion [1,4] (lic `notElem` compatLicenses) $
, checkVersion CabalSpecV1_4 (lic `notElem` compatLicenses) $
PackageDistInexcusable $
"Unfortunately the license " ++ quote (prettyShow (license pkg))
++ " messes up the parser in earlier Cabal versions so you need to "
......@@ -733,10 +726,10 @@ checkOldLicense pkg lic = catMaybes
where knownVersions = [ v' | Apache (Just v') <- knownLicenses ]
unknownLicenseVersion _ = Nothing
checkVersion :: [Int] -> Bool -> PackageCheck -> Maybe PackageCheck
checkVersion :: CabalSpecVersion -> Bool -> PackageCheck -> Maybe PackageCheck
checkVersion ver cond pc
| specVersion pkg >= mkVersion ver = Nothing
| otherwise = check cond pc
| specVersion pkg >= ver = Nothing
| otherwise = check cond pc
compatLicenses = [ GPL Nothing, LGPL Nothing, AGPL Nothing, BSD3, BSD4
, PublicDomain, AllRightsReserved
......@@ -1146,41 +1139,8 @@ checkCabalVersion :: PackageDescription -> [PackageCheck]
checkCabalVersion pkg =
catMaybes [
-- check syntax of cabal-version field
check (specVersion pkg >= mkVersion [1,10]
&& not simpleSpecVersionRangeSyntax) $
PackageBuildWarning $
"Packages relying on Cabal 1.10 or later must only specify a "
++ "version range of the form 'cabal-version: >= x.y'. Use "
++ "'cabal-version: >= " ++ prettyShow (specVersion pkg) ++ "'."
-- check syntax of cabal-version field
, check (specVersion pkg < mkVersion [1,9]
&& not simpleSpecVersionRangeSyntax) $
PackageDistSuspicious $
"It is recommended that the 'cabal-version' field only specify a "
++ "version range of the form '>= x.y'. Use "
++ "'cabal-version: >= " ++ prettyShow (specVersion pkg) ++ "'. "
++ "Tools based on Cabal 1.10 and later will ignore upper bounds."
-- check syntax of cabal-version field
, checkVersion [1,12] simpleSpecVersionSyntax $
PackageBuildWarning $
"With Cabal 1.10 or earlier, the 'cabal-version' field must use "
++ "range syntax rather than a simple version number. Use "
++ "'cabal-version: >= " ++ prettyShow (specVersion pkg) ++ "'."
-- check syntax of cabal-version field
, check (specVersion pkg >= mkVersion [1,12]
&& not simpleSpecVersionSyntax) $
(if specVersion pkg >= mkVersion [2,0] then PackageDistSuspicious else PackageDistSuspiciousWarn) $
"Packages relying on Cabal 1.12 or later should specify a "
++ "specific version of the Cabal spec of the form "
++ "'cabal-version: x.y'. "
++ "Use 'cabal-version: " ++ prettyShow (specVersion pkg) ++ "'."
-- check use of test suite sections
, checkVersion [1,8] (not (null $ testSuites pkg)) $
checkVersion CabalSpecV1_8 (not (null $ testSuites pkg)) $
PackageDistInexcusable $
"The 'test-suite' section is new in Cabal 1.10. "
++ "Unfortunately it messes up the parser in older Cabal versions "
......@@ -1190,12 +1150,12 @@ checkCabalVersion pkg =
-- check use of default-language field
-- note that we do not need to do an equivalent check for the
-- other-language field since that one does not change behaviour
, checkVersion [1,10] (any isJust (buildInfoField defaultLanguage)) $
, checkVersion CabalSpecV1_10 (any isJust (buildInfoField defaultLanguage)) $
PackageBuildWarning $
"To use the 'default-language' field the package needs to specify "
++ "at least 'cabal-version: >= 1.10'."
, check (specVersion pkg >= mkVersion [1,10]
, check (specVersion pkg >= CabalSpecV1_10
&& (any isNothing (buildInfoField defaultLanguage))) $
PackageBuildWarning $
"Packages using 'cabal-version: >= 1.10' must specify the "
......@@ -1204,33 +1164,33 @@ checkCabalVersion pkg =
++ "different modules then list the other ones in the "
++ "'other-languages' field."
, checkVersion [1,18]
, checkVersion CabalSpecV1_18
(not . null $ extraDocFiles pkg) $
PackageDistInexcusable $
"To use the 'extra-doc-files' field the package needs to specify "
++ "at least 'cabal-version: >= 1.18'."
, checkVersion [2,0]
, checkVersion CabalSpecV2_0
(not (null (subLibraries pkg))) $
PackageDistInexcusable $
"To use multiple 'library' sections or a named library section "
++ "the package needs to specify at least 'cabal-version: 2.0'."
-- check use of reexported-modules sections
, checkVersion [1,21]
, checkVersion CabalSpecV1_22
(any (not.null.reexportedModules) (allLibraries pkg)) $
PackageDistInexcusable $
"To use the 'reexported-module' field the package needs to specify "
++ "at least 'cabal-version: >= 1.22'."
-- check use of thinning and renaming
, checkVersion [1,25] usesBackpackIncludes $
, checkVersion CabalSpecV2_0 usesBackpackIncludes $
PackageDistInexcusable $
"To use the 'mixins' field the package needs to specify "
++ "at least 'cabal-version: 2.0'."
-- check use of 'extra-framework-dirs' field
, checkVersion [1,23] (any (not . null) (buildInfoField extraFrameworkDirs)) $
, checkVersion CabalSpecV1_24 (any (not . null) (buildInfoField extraFrameworkDirs)) $
-- Just a warning, because this won't break on old Cabal versions.
PackageDistSuspiciousWarn $
"To use the 'extra-framework-dirs' field the package needs to specify"
......@@ -1238,13 +1198,13 @@ checkCabalVersion pkg =
-- check use of default-extensions field
-- don't need to do the equivalent check for other-extensions
, checkVersion [1,10] (any (not . null) (buildInfoField defaultExtensions)) $
, checkVersion CabalSpecV1_10 (any (not . null) (buildInfoField defaultExtensions)) $
PackageBuildWarning $
"To use the 'default-extensions' field the package needs to specify "
++ "at least 'cabal-version: >= 1.10'."
-- check use of extensions field
, check (specVersion pkg >= mkVersion [1,10]
, check (specVersion pkg >= CabalSpecV1_10
&& (any (not . null) (buildInfoField oldExtensions))) $
PackageBuildWarning $
"For packages using 'cabal-version: >= 1.10' the 'extensions' "
......@@ -1253,7 +1213,7 @@ checkCabalVersion pkg =
++ "the 'other-extensions' field lists extensions that are used in "
++ "some modules, e.g. via the {-# LANGUAGE #-} pragma."
, checkVersion [3,0] (any (not . null)
, checkVersion CabalSpecV3_0 (any (not . null)
(concatMap buildInfoField
[ asmSources
, cmmSources
......@@ -1264,38 +1224,38 @@ checkCabalVersion pkg =
++ " and 'extra-library-flavours' requires the package "
++ " to specify at least 'cabal-version: 3.0'."
, checkVersion [2,5] (any (not . null) $ buildInfoField extraDynLibFlavours) $
, checkVersion CabalSpecV3_0 (any (not . null) $ buildInfoField extraDynLibFlavours) $
PackageDistInexcusable $
"The use of 'extra-dynamic-library-flavours' requires the package "
++ " to specify at least 'cabal-version: >= 2.5'. The flavours are: "
++ " to specify at least 'cabal-version: 3.0'. The flavours are: "
++ commaSep [ flav
| flavs <- buildInfoField extraDynLibFlavours
, flav <- flavs ]
, checkVersion [2,1] (any (not . null)
, checkVersion CabalSpecV2_2 (any (not . null)
(buildInfoField virtualModules)) $
PackageDistInexcusable $
"The use of 'virtual-modules' requires the package "
++ " to specify at least 'cabal-version: >= 2.1'."
++ " to specify at least 'cabal-version: 2.2'."
-- check use of "source-repository" section
, checkVersion [1,6] (not (null (sourceRepos pkg))) $
, checkVersion CabalSpecV1_6 (not (null (sourceRepos pkg))) $
PackageDistInexcusable $
"The 'source-repository' section is new in Cabal 1.6. "
++ "Unfortunately it messes up the parser in earlier Cabal versions "
++ "so you need to specify 'cabal-version: >= 1.6'."
-- check for new language extensions
, checkVersion [1,2,3] (not (null mentionedExtensionsThatNeedCabal12)) $
, checkVersion CabalSpecV1_4 (not (null mentionedExtensionsThatNeedCabal12)) $
PackageDistInexcusable $
"Unfortunately the language extensions "
++ commaSep (map (quote . prettyShow) mentionedExtensionsThatNeedCabal12)
++ " break the parser in earlier Cabal versions so you need to "
++ "specify 'cabal-version: >= 1.2.3'. Alternatively if you require "
++ "specify 'cabal-version: >= 1.4'. Alternatively if you require "
++ "compatibility with earlier Cabal versions then you may be able to "
++ "use an equivalent compiler-specific flag."
, checkVersion [1,4] (not (null mentionedExtensionsThatNeedCabal14)) $
, checkVersion CabalSpecV1_4 (not (null mentionedExtensionsThatNeedCabal14)) $
PackageDistInexcusable $
"Unfortunately the language extensions "
++ commaSep (map (quote . prettyShow) mentionedExtensionsThatNeedCabal14)
......@@ -1304,7 +1264,7 @@ checkCabalVersion pkg =
++ "compatibility with earlier Cabal versions then you may be able to "
++ "use an equivalent compiler-specific flag."
, check (specVersion pkg >= mkVersion [1,23]
, check (specVersion pkg >= CabalSpecV1_24
&& isNothing (setupBuildInfo pkg)
&& buildType pkg == Custom) $
PackageBuildWarning $
......@@ -1314,7 +1274,7 @@ checkCabalVersion pkg =
++ "The 'setup-depends' field uses the same syntax as 'build-depends', "
++ "so a simple example would be 'setup-depends: base, Cabal'."
, check (specVersion pkg < mkVersion [1,23]
, check (specVersion pkg < CabalSpecV1_24
&& isNothing (setupBuildInfo pkg)
&& buildType pkg == Custom) $
PackageDistSuspiciousWarn $
......@@ -1325,7 +1285,7 @@ checkCabalVersion pkg =
++ "The 'setup-depends' field uses the same syntax as 'build-depends', "
++ "so a simple example would be 'setup-depends: base, Cabal'."
, check (specVersion pkg >= mkVersion [1,25]
, check (specVersion pkg >= CabalSpecV2_0
&& elem (autogenPathsModuleName pkg) allModuleNames
&& not (elem (autogenPathsModuleName pkg) allModuleNamesAutogen) ) $
PackageDistInexcusable $
......@@ -1342,23 +1302,13 @@ checkCabalVersion pkg =
-- the version given. This is for cases where a new Cabal version adds
-- a new feature and we want to check that it is not used prior to that
-- version.
checkVersion :: [Int] -> Bool -> PackageCheck -> Maybe PackageCheck
checkVersion :: CabalSpecVersion -> Bool -> PackageCheck -> Maybe PackageCheck
checkVersion ver cond pc
| specVersion pkg >= mkVersion ver = Nothing
| otherwise = check cond pc
| specVersion pkg >= ver = Nothing
| otherwise = check cond pc
buildInfoField field = map field (allBuildInfo pkg)
simpleSpecVersionRangeSyntax =
either (const True) (cataVersionRange alg) (specVersionRaw pkg)
where