Skip to content

Commit 04ad93e

Browse files
committed
Guard PackageInfo behind cabal-version ≥ 3.12
1 parent 8c79789 commit 04ad93e

File tree

17 files changed

+50
-22
lines changed

17 files changed

+50
-22
lines changed

Cabal/src/Distribution/PackageDescription/Check/Target.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,25 @@ checkAutogenModules ams bi = do
652652
-- Paths_* module + some default extension build failure.
653653
autogenCheck autoInfoModuleName CVAutogenPackageInfo
654654
rebindableClashCheck autoInfoModuleName RebindableClashPackageInfo
655+
656+
-- PackageInfo_* module + cabal-version < 3.12
657+
-- See Mikolaj’s comments on #9481 on why this has to be
658+
-- PackageBuildImpossible and not merely PackageDistInexcusable.
659+
checkSpecVer
660+
CabalSpecV3_12
661+
(elem autoInfoModuleName allModsForAuto)
662+
(PackageBuildImpossible CVAutogenPackageInfoGuard)
655663
where
664+
allModsForAuto :: [ModuleName]
665+
allModsForAuto = ams ++ otherModules bi
666+
656667
autogenCheck
657668
:: Monad m
658669
=> ModuleName
659670
-> CheckExplanation
660671
-> CheckM m ()
661672
autogenCheck name warning = do
662673
sv <- asksCM ccSpecVersion
663-
let allModsForAuto = ams ++ otherModules bi
664674
checkP
665675
( sv >= CabalSpecV2_0
666676
&& elem name allModsForAuto

Cabal/src/Distribution/PackageDescription/Check/Warning.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ data CheckExplanation
211211
| CVExpliticDepsCustomSetup
212212
| CVAutogenPaths
213213
| CVAutogenPackageInfo
214+
| CVAutogenPackageInfoGuard
214215
| GlobNoMatch String String
215216
| GlobExactMatch String String FilePath
216217
| GlobNoDir String String FilePath
@@ -778,6 +779,9 @@ ppExplanation CVAutogenPackageInfo =
778779
++ "the module does not come with the package and is generated on "
779780
++ "setup. Modules built with a custom Setup.hs script also go here "
780781
++ "to ensure that commands like sdist don't fail."
782+
ppExplanation CVAutogenPackageInfoGuard =
783+
"To use the autogenerated module PackageInfo_* you need to specify "
784+
++ "`cabal-version: 3.12` or higher."
781785
ppExplanation (GlobNoMatch field glob) =
782786
"In '"
783787
++ field

cabal-testsuite/PackageTests/AutogenModules/Package/my.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
cabal-version: 3.12
12
name: AutogenModules
23
version: 0.1
3-
license: BSD3
4+
license: BSD-3-Clause
45
license-file: LICENSE
56
author: Federico Mastellone
67
maintainer: Federico Mastellone
78
synopsis: AutogenModules
89
category: PackageTests
910
build-type: Simple
10-
cabal-version: 2.0
1111

1212
description:
1313
Check that Cabal recognizes the autogen-modules fields below.

cabal-testsuite/PackageTests/AutogenModules/SrcDist/AutogenModules.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
cabal-version: 3.12
12
name: AutogenModules
23
version: 0.1
3-
license: BSD3
4+
license: BSD-3-Clause
45
license-file: LICENSE
56
author: Federico Mastellone
67
maintainer: Federico Mastellone
78
synopsis: AutogenModules
89
category: PackageTests
910
build-type: Simple
10-
cabal-version: 2.0
1111

1212
description:
1313
Check that Cabal recognizes the autogen-modules fields below.

cabal-testsuite/PackageTests/Check/ConfiguredPackage/CabalVersion/AutoGenMods/pkg.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
cabal-version: 2.0
1+
cabal-version: 3.12
22
build-type: Simple
33
name: pkg
44
synopsis: synopsis
55
description: description
66
version: 0
77
category: example
88
maintainer: none@example.com
9-
license: GPL-3
9+
license: GPL-3.0-or-later
1010
license-file: LICENSE
1111

1212
library
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# cabal check
22
The package will not build sanely due to these errors:
3+
Error: To use the autogenerated module PackageInfo_* you need to specify `cabal-version: 3.12` or higher.
34
Error: Packages using RebindableSyntax with OverloadedStrings or OverloadedLists in default-extensions, in conjunction with the autogenerated module Paths_*, are known to cause compile failures with Cabal < 2.2. To use these default-extensions with a Paths_* autogen module, specify at least 'cabal-version: 2.2'.
45
Error: Packages using RebindableSyntax with OverloadedStrings or OverloadedLists in default-extensions, in conjunction with the autogenerated module PackageInfo_*, are known to cause compile failures with Cabal < 2.2. To use these default-extensions with a PackageInfo_* autogen module, specify at least 'cabal-version: 2.2'.
56
Error: Hackage would reject this package.

cabal-testsuite/PackageTests/NewBuild/CmdRun/Datafiles/foo/foo.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
cabal-version: 3.12
12
name: foo
23
version: 1.0
34
build-type: Simple
4-
cabal-version: >= 1.10
55
data-dir: data
66
data-files: hello.txt
77

cabal-testsuite/PackageTests/NewBuild/T5164/setup-lib/setup-lib.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
cabal-version: 3.12
12
name: setup-lib
23
version: 1.0
34
build-type: Simple
4-
cabal-version: >= 1.10
55
data-files: example.txt
66

77
library

cabal-testsuite/PackageTests/PackageInfoModule/Executable/my.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
Cabal-version: 3.12
12
name: PackageInfoModule
23
version: 0.1
3-
license: BSD3
4+
license: BSD-3-Clause
45
author: Gautier DI FOLCO
56
stability: stable
67
category: PackageTests
78
build-type: Simple
8-
Cabal-version: >= 1.2
99

1010
description:
1111
Check that the generated package info module compiles.

cabal-testsuite/PackageTests/PackageInfoModule/ImportQualifiedPost/my.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
Cabal-version: 3.12
12
name: PackageInfoModule
23
version: 0.1
3-
license: BSD3
4+
license: BSD-3-Clause
45
author: Gautier DI FOLCO
56
category: PackageTests
67
build-type: Simple
7-
Cabal-version: >= 1.2
88

99
description:
1010
Check that the generated package info module compiles.

0 commit comments

Comments
 (0)