Skip to content

Commit ef29ebb

Browse files
jasagredompickeringmergify[bot]
authored
Concat arguments when enabling haddock (#10783)
* Concat arguments when enabling haddock Arguments were unioned with <> which is left-biased, therefore -haddock swallowed all other args as indeed described in #10782. I think the bug was introduced by 80f0a65, which makes the expression modified in this PR to be non-empty if documentation was enabled. Fixes #10782 * Add test for #10783 (concatenate arguments when enabling haddock) --------- Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 7e0acf7 commit ef29ebb

File tree

7 files changed

+57
-7
lines changed

7 files changed

+57
-7
lines changed

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,13 +2319,16 @@ elaborateInstallPlan
23192319
]
23202320
<> perPkgOptionMapLast pkgid packageConfigProgramPaths
23212321
elabProgramArgs =
2322-
Map.fromList
2323-
[ (programId prog, args)
2324-
| prog <- configuredPrograms compilerprogdb
2325-
, let args = programOverrideArgs $ addHaddockIfDocumentationEnabled prog
2326-
, not (null args)
2327-
]
2328-
<> perPkgOptionMapMappend pkgid packageConfigProgramArgs
2322+
Map.unionWith
2323+
(++)
2324+
( Map.fromList
2325+
[ (programId prog, args)
2326+
| prog <- configuredPrograms compilerprogdb
2327+
, let args = programOverrideArgs $ addHaddockIfDocumentationEnabled prog
2328+
, not (null args)
2329+
]
2330+
)
2331+
(perPkgOptionMapMappend pkgid packageConfigProgramArgs)
23292332
elabProgramPathExtra = perPkgOptionNubList pkgid packageConfigProgramPathExtra
23302333
elabConfigureScriptArgs = perPkgOptionList pkgid packageConfigConfigureArgs
23312334
elabExtraLibDirs = perPkgOptionList pkgid packageConfigExtraLibDirs
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for HaddockArgsCombine
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cabal-version: 3.14
2+
name: HaddockArgsCombine
3+
version: 0.1.0.0
4+
license: NONE
5+
author: Matthew Pickering
6+
maintainer: matthewtpickering@gmail.com
7+
build-type: Simple
8+
extra-doc-files: CHANGELOG.md
9+
10+
executable HaddockArgsCombine
11+
main-is: Main.hs
12+
build-depends: base
13+
hs-source-dirs: app
14+
default-language: Haskell2010
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Main where
2+
3+
import Data.List
4+
5+
main :: IO ()
6+
main = putStrLn "Hello, Haskell!"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# cabal v2-run
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- HaddockArgsCombine-0.1.0.0 (exe:HaddockArgsCombine) (first run)
6+
Configuring executable 'HaddockArgsCombine' for HaddockArgsCombine-0.1.0.0...
7+
Preprocessing executable 'HaddockArgsCombine' for HaddockArgsCombine-0.1.0.0...
8+
Building executable 'HaddockArgsCombine' for HaddockArgsCombine-0.1.0.0...
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Test.Cabal.Prelude
2+
main = cabalTest $ do
3+
fails $ cabal "v2-run" ["--ghc-options=-Wall -Werror", "--enable-documentation"]

changelog.d/pr-10783

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
synopsis: GHC arguments are no longer swallowed by enabling documentation
2+
packages: Cabal
3+
prs: #10783
4+
issues: #10782
5+
significance: significant
6+
7+
description: {
8+
9+
- Arguments to GHC are now properly concatenated with `-haddock` if documentation is enabled.
10+
11+
}

0 commit comments

Comments
 (0)