Skip to content

Commit

Permalink
check: guard PackageInfo behind cabal-version ≥ 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ffaf1 committed Nov 27, 2023
1 parent dbe4b32 commit 15719e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Cabal/src/Distribution/PackageDescription/Check/Target.hs
Original file line number Diff line number Diff line change
Expand Up @@ -652,15 +652,23 @@ checkAutogenModules ams bi = do
-- Paths_* module + some default extension build failure.
autogenCheck autoInfoModuleName CVAutogenPackageInfo
rebindableClashCheck autoInfoModuleName RebindableClashPackageInfo

-- PackageInfo_* module + cabal-version < 3.12
checkSpecVer
CabalSpecV3_12
(elem autoInfoModuleName allModsForAuto)
(PackageDistInexcusable CVAutogenPackageInfoGuard)
where
allModsForAuto :: [ModuleName]
allModsForAuto = ams ++ otherModules bi

autogenCheck
:: Monad m
=> ModuleName
-> CheckExplanation
-> CheckM m ()
autogenCheck name warning = do
sv <- asksCM ccSpecVersion
let allModsForAuto = ams ++ otherModules bi
checkP
( sv >= CabalSpecV2_0
&& elem name allModsForAuto
Expand Down
4 changes: 4 additions & 0 deletions Cabal/src/Distribution/PackageDescription/Check/Warning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ data CheckExplanation
| CVExpliticDepsCustomSetup
| CVAutogenPaths
| CVAutogenPackageInfo
| CVAutogenPackageInfoGuard
| GlobNoMatch String String
| GlobExactMatch String String FilePath
| GlobNoDir String String FilePath
Expand Down Expand Up @@ -778,6 +779,9 @@ ppExplanation CVAutogenPackageInfo =
++ "the module does not come with the package and is generated on "
++ "setup. Modules built with a custom Setup.hs script also go here "
++ "to ensure that commands like sdist don't fail."
ppExplanation CVAutogenPackageInfoGuard =
"To use the autogenerated module PackageInfo_* you need to specify "
++ "`cabal-version: 3.12` or higher."
ppExplanation (GlobNoMatch field glob) =
"In '"
++ field
Expand Down

0 comments on commit 15719e3

Please sign in to comment.