Commit e42e5462 authored by Oleg Grenrus's avatar Oleg Grenrus

Resolve #6288

- Add availableSince to language/extension fields
   - Also autogen-modules once we are on that.
- Remove default-language check for cabal-version: 3.4

We cannot make the field `uniqueFieldAlaDef`, as that would require
specifying `default-language` in each subconditional.
I leave it for https://github.com/haskell/cabal/issues/6925

Note: the default language is whatever is the compiler's default.
The GHC-8.10 default is its variant of Haskell2010
with NondecreasingIndentation and without DatatypeContexts
parent d7fd25ac
......@@ -1151,10 +1151,10 @@ checkCabalVersion pkg =
"To use the 'default-language' field the package needs to specify "
++ "at least 'cabal-version: >= 1.10'."
, check (specVersion pkg >= CabalSpecV1_10
, check (specVersion pkg >= CabalSpecV1_10 && specVersion pkg < CabalSpecV3_4
&& (any isNothing (buildInfoField defaultLanguage))) $
PackageBuildWarning $
"Packages using 'cabal-version: >= 1.10' must specify the "
"Packages using 'cabal-version: >= 1.10' and before 'cabal-version: 3.4' must specify the "
++ "'default-language' field for each component (e.g. Haskell98 or "
++ "Haskell2010). If a component uses different languages in "
++ "different modules then list the other ones in the "
......
......@@ -530,10 +530,15 @@ buildInfoFieldGrammar = BuildInfo
<*> monoidalFieldAla "virtual-modules" (alaList' VCat MQuoted) L.virtualModules
^^^ availableSince CabalSpecV2_2 []
<*> monoidalFieldAla "autogen-modules" (alaList' VCat MQuoted) L.autogenModules
^^^ availableSince CabalSpecV2_0 []
<*> optionalFieldAla "default-language" MQuoted L.defaultLanguage
^^^ availableSince CabalSpecV1_10 Nothing
<*> monoidalFieldAla "other-languages" (alaList' FSep MQuoted) L.otherLanguages
^^^ availableSince CabalSpecV1_10 []
<*> monoidalFieldAla "default-extensions" (alaList' FSep MQuoted) L.defaultExtensions
^^^ availableSince CabalSpecV1_10 []
<*> monoidalFieldAla "other-extensions" formatOtherExtensions L.otherExtensions
^^^ availableSince CabalSpecV1_10 []
<*> monoidalFieldAla "extensions" (alaList' FSep MQuoted) L.oldExtensions
^^^ deprecatedSince CabalSpecV1_12
"Please use 'default-extensions' or 'other-extensions' fields."
......
......@@ -34,6 +34,9 @@ relative to the respective preceding *published* version.
* Remove ``-any`` and ``-none`` syntax for version ranges
Use ``>=0`` and ``<0`` respectively.
* :pkg-field:`default-language` is optional.
The Default value is to use the compiler's default language.
* :pkg-field:`mixins` field allow specifying a sublibrary.
``cabal-version: 3.0``
......
To use the 'default-language' field the package needs to specify at least 'cabal-version: >= 1.10'.
issue-6288-a.cabal:13:3: The field "default-language" is available only since the Cabal specification version 1.10. This field will be ignored.
Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
Packages using 'cabal-version: >= 1.10' and before 'cabal-version: 3.4' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
......@@ -7,7 +7,7 @@ maintainer: Federico Mastellone
synopsis: AutogenModules
category: PackageTests
build-type: Simple
cabal-version: 1.24
cabal-version: 2.0
description:
Check that Cabal recognizes the autogen-modules fields below.
......@@ -22,6 +22,7 @@ Library
other-modules:
MyLibModule
autogen-modules:
Paths_AutogenModules
MyLibHelperModule
Executable Exe
......@@ -33,6 +34,7 @@ Executable Exe
Paths_AutogenModules
MyExeHelperModule
autogen-modules:
Paths_AutogenModules
MyExeHelperModule
Test-Suite Test
......@@ -45,6 +47,7 @@ Test-Suite Test
Paths_AutogenModules
MyTestHelperModule
autogen-modules:
Paths_AutogenModules
MyTestHelperModule
Benchmark Bench
......@@ -57,4 +60,5 @@ Benchmark Bench
Paths_AutogenModules
MyBenchHelperModule
autogen-modules:
Paths_AutogenModules
MyBenchHelperModule
......@@ -25,16 +25,16 @@ main = setupAndCabalTest $ do
let gotTestSuite = head $ testSuites (localPkgDescr lbi)
let gotBenchmark = head $ benchmarks (localPkgDescr lbi)
assertEqual "library 'autogen-modules' field does not match expected"
[fromString "MyLibHelperModule"]
[fromString "Paths_AutogenModules", fromString "MyLibHelperModule"]
(libModulesAutogen gotLibrary)
assertEqual "executable 'autogen-modules' field does not match expected"
[fromString "MyExeHelperModule"]
[fromString "Paths_AutogenModules", fromString "MyExeHelperModule"]
(exeModulesAutogen gotExecutable)
assertEqual "test-suite 'autogen-modules' field does not match expected"
[fromString "MyTestHelperModule"]
[fromString "Paths_AutogenModules", fromString "MyTestHelperModule"]
(testModulesAutogen gotTestSuite)
assertEqual "benchmark 'autogen-modules' field does not match expected"
[fromString "MyBenchHelperModule"]
[fromString "Paths_AutogenModules", fromString "MyBenchHelperModule"]
(benchmarkModulesAutogen gotBenchmark)
-- Package check messages.
......
......@@ -4,6 +4,7 @@ build-type: Simple
cabal-version: 2.0
library
default-language: Haskell2010
build-depends: base, impl, sig-with-th
hs-source-dirs: .
mixins: sig-with-th requires (Sig as Impl)
......@@ -11,12 +12,14 @@ library
exposed-modules: Go
library sig-with-th
default-language: Haskell2010
build-depends: base
hs-source-dirs: sig-with-th
signatures: Sig
exposed-modules: THFuns
library impl
default-language: Haskell2010
build-depends: base
hs-source-dirs: impl
exposed-modules: Impl
# Setup configure
Configuring th-backpack-failure-1.0...
Warning: Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
# Setup build
Preprocessing library 'sig-with-th' for th-backpack-failure-1.0..
Building library 'sig-with-th' instantiated with Sig = <Sig>
......
# Setup configure
Configuring th-backpack-failure-1.0...
Warning: Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
# Setup build
Preprocessing library 'sig-with-th' for th-backpack-failure-1.0..
Building library 'sig-with-th' instantiated with Sig = <Sig>
......
......@@ -11,10 +11,12 @@ description:
Check that Cabal recognizes the benchmark stanza defined below.
Library
default-language: Haskell2010
exposed-modules: MyLibrary
build-depends: base
benchmark dummy
default-language: Haskell2010
main-is: dummy.hs
type: exitcode-stdio-1.0
build-depends: base
# Setup configure
Configuring BenchmarkStanza-0.1...
Warning: Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
# Setup configure
Configuring BenchmarkStanza-0.1...
Warning: Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
......@@ -5,12 +5,13 @@ author: Iain Nicol
stability: stable
category: PackageTests
build-type: Simple
Cabal-version: >= 1.2
Cabal-version: >= 1.10
description:
Check that Cabal successfully invokes Haddock.
Library
default-language: Haskell2010
exposed-modules: CPP, Literate, NoCPP, Simple
other-extensions: CPP
build-depends: base
name: T3847
version: 1.0
build-type: Simple
cabal-version: >= 1.8
cabal-version: >= 1.10
library
default-language: Haskell2010
test-suite tests
default-language: Haskell2010
other-extensions: ThisDoesNotExist
type: exitcode-stdio-1.0
main-is: Main.hs
......
......@@ -4,10 +4,12 @@ build-type: Simple
cabal-version: >= 1.10
library
default-language: Haskell2010
build-depends: base
exposed-modules: A
executable exe
default-language: Haskell2010
build-depends: T4025, base
hs-source-dirs: exe
main-is: Main.hs
# Setup configure
Configuring T4025-1.0...
Warning: Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
# Setup build
Preprocessing library for T4025-1.0..
Building library for T4025-1.0..
......
# Setup configure
Configuring T4025-1.0...
Warning: Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field.
# Setup build
Preprocessing library for T4025-1.0..
Building library for T4025-1.0..
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment