Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cabal-tests/Cabal-tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test-suite unit-tests
UnitTests.Distribution.Simple.Glob
UnitTests.Distribution.Simple.Program.GHC
UnitTests.Distribution.Simple.Program.Internal
UnitTests.Distribution.Simple.Setup.Config
UnitTests.Distribution.Simple.Utils
UnitTests.Distribution.SPDX
UnitTests.Distribution.System
Expand Down
2 changes: 2 additions & 0 deletions Cabal-tests/tests/UnitTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import qualified UnitTests.Distribution.Simple.Command
import qualified UnitTests.Distribution.Simple.Glob
import qualified UnitTests.Distribution.Simple.Program.GHC
import qualified UnitTests.Distribution.Simple.Program.Internal
import qualified UnitTests.Distribution.Simple.Setup.Config
import qualified UnitTests.Distribution.Simple.Utils
import qualified UnitTests.Distribution.System
import qualified UnitTests.Distribution.Utils.CharSet
Expand Down Expand Up @@ -46,6 +47,7 @@ tests =
, UnitTests.Distribution.Simple.Program.GHC.tests
, testGroup "Distribution.Simple.Program.Internal"
UnitTests.Distribution.Simple.Program.Internal.tests
, UnitTests.Distribution.Simple.Setup.Config.tests
, testGroup "Distribution.Simple.Utils" $
UnitTests.Distribution.Simple.Utils.tests ghcPath
, testGroup "Distribution.Utils.Generic"
Expand Down
65 changes: 65 additions & 0 deletions Cabal-tests/tests/UnitTests/Distribution/Simple/Setup/Config.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
module UnitTests.Distribution.Simple.Setup.Config
( tests
) where

import Distribution.Compiler (CompilerFlavor (..))
import Distribution.Simple.Command (CommandParse (..), commandParseArgs)
import Distribution.Simple.Compiler (DebugInfoLevel (..))
import Distribution.Simple.Flag qualified as Flag
import Distribution.Simple.Program.Db (emptyProgramDb)
import Distribution.Simple.Setup
( ConfigFlags (..)
, configureCommand
, emptyConfigFlags
)

import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit

tests :: TestTree
tests =
testGroup
"Distribution.Simple.Setup.Config"
[ testGroup
"--ghc / -g compiler selection"
[ testCase "--ghc selects GHC" $
configHcFlavor (parse ["--ghc"]) @?= Flag.Flag GHC
, testCase "--ghcjs selects GHCJS" $
configHcFlavor (parse ["--ghcjs"]) @?= Flag.Flag GHCJS
, testCase "-g no longer selects GHC" $
configHcFlavor (parse ["-g"]) @?= Flag.NoFlag
, testCase "--ghc -g selects GHC and does not conflict" $
configHcFlavor (parse ["--ghc", "-g"]) @?= Flag.Flag GHC
, testCase "-g --ghcjs selects GHCJS and does not conflict" $
configHcFlavor (parse ["-g", "--ghcjs"]) @?= Flag.Flag GHCJS
]
, testGroup
"--enable-debug-info / -g debug info"
[ testCase "-g sets NormalDebugInfo" $
configDebugInfo (parse ["-g"]) @?= Flag.Flag NormalDebugInfo
, testCase "--enable-debug-info sets NormalDebugInfo" $
configDebugInfo (parse ["--enable-debug-info"]) @?= Flag.Flag NormalDebugInfo
, testCase "-g1 sets MinimalDebugInfo" $
configDebugInfo (parse ["-g1"]) @?= Flag.Flag MinimalDebugInfo
, testCase "-g3 sets MaximalDebugInfo" $
configDebugInfo (parse ["-g3"]) @?= Flag.Flag MaximalDebugInfo
, testCase "--enable-debug-info=2 sets NormalDebugInfo" $
configDebugInfo (parse ["--enable-debug-info=2"]) @?= Flag.Flag NormalDebugInfo
, testCase "--disable-debug-info sets NoDebugInfo" $
configDebugInfo (parse ["--disable-debug-info"]) @?= Flag.Flag NoDebugInfo
]
]

-- | Parse the given @configure@ command line arguments starting from
-- 'emptyConfigFlags', so that only the options actually given are set.
-- Parsing failures are reported as test failures.
parse :: [String] -> ConfigFlags
parse args =
case commandParseArgs (configureCommand emptyProgramDb) False args of
CommandReadyToGo (f, _) -> f emptyConfigFlags
CommandErrors errs ->
error $ "unexpected parse errors: " ++ show errs
CommandHelp _ ->
error "unexpected help"
CommandList _ ->
error "unexpected list"
4 changes: 2 additions & 2 deletions Cabal/src/Distribution/Simple/Setup/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ configureOptions showOrParseArgs =
configHcFlavor
(\v flags -> flags{configHcFlavor = v})
( choiceOpt
[ (Flag GHC, ("g", ["ghc"]), "Compile with GHC")
[ (Flag GHC, ([], ["ghc"]), "Compile with GHC")
, (Flag GHCJS, ([], ["ghcjs"]), "Compile with GHCJS")
, (Flag UHC, ([], ["uhc"]), "Compile with UHC")
]
Expand Down Expand Up @@ -599,7 +599,7 @@ configureOptions showOrParseArgs =
Flag MaximalDebugInfo -> [Just "3"]
_ -> []
)
""
"g"
["enable-debug-info"]
"Emit debug info (n is 0--3, default is 0)"
, noArg
Expand Down
17 changes: 17 additions & 0 deletions changelog.d/12201.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
synopsis: Removes the short `-g` option for the `--ghc` flag
packages: [Cabal]
prs: 12201
---

- Removes the short `-g` option for the `--ghc` flag. This is now used as the short option for `--enable-debug-info`.
```diff
$ cabal build --help
...
- -g, --ghc # Compile with GHC
+ --ghc # Compile with GHC
...
- --enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
+ -g[n], --enable-debug-info[=n]
+ # Emit debug info (n is 0--3, default is 0)
```
5 changes: 3 additions & 2 deletions doc/cmd-v1-help/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Flags for v1-configure:
files (default dist)
--cabal-file=PATH # use this Cabal file
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -73,7 +73,8 @@ Flags for v1-configure:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v1-help/install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Flags for v1-install:
files (default dist)
--cabal-file=PATH # use this Cabal file
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -84,7 +84,8 @@ Flags for v1-install:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v1-help/reconfigure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Flags for v1-reconfigure:
files (default dist)
--cabal-file=PATH # use this Cabal file
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -72,7 +72,8 @@ Flags for v1-reconfigure:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/bench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Flags for bench:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -77,7 +77,8 @@ Flags for bench:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Flags for build:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -77,7 +77,8 @@ Flags for build:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Flags for configure:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -90,7 +90,8 @@ Flags for configure:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/exec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Flags for exec:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -79,7 +79,8 @@ Flags for exec:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/freeze.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Flags for freeze:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -82,7 +82,8 @@ Flags for freeze:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/gen-bounds.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Flags for gen-bounds:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -68,7 +68,8 @@ Flags for gen-bounds:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/haddock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Flags for haddock:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -82,7 +82,8 @@ Flags for haddock:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Flags for install:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -60,7 +60,8 @@ Flags for install:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/list-bin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Flags for list-bin:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -69,7 +69,8 @@ Flags for list-bin:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/outdated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Flags for outdated:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -70,7 +70,8 @@ Flags for outdated:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
5 changes: 3 additions & 2 deletions doc/cmd-v2-help/path.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Flags for path:
--builddir=DIR # The directory where Cabal puts generated build
files (default dist)
--keep-temp-files # Keep temporary files.
-g, --ghc # Compile with GHC
--ghc # Compile with GHC
--ghcjs # Compile with GHCJS
--uhc # Compile with UHC
-w PATH or -wPATH, --with-compiler=PATH
Expand Down Expand Up @@ -71,7 +71,8 @@ Flags for path:
# Build with optimization (n is 0--2, default is
1)
--disable-optimization # Build without optimization
--enable-debug-info[=n] # Emit debug info (n is 0--3, default is 0)
-g[n], --enable-debug-info[=n]
# Emit debug info (n is 0--3, default is 0)
--disable-debug-info # Don't emit debug info
--enable-build-info # Enable build information generation during
project building
Expand Down
Loading
Loading