Commit 7d04b9f2 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

hadrian: Allow override of Cabal configuration in hadrian.settings

Fixes #17612 by adding a `cabal.configure.opts` key for
`hadrian.settings`.
parent 28b5349a
Pipeline #15552 passed with stages
in 682 minutes and 12 seconds
......@@ -385,25 +385,27 @@ the right names for them:
only when building the given package, or that the said options should be used
when building all known packages, if the Hadrian command ever gets them to be
built;
- the third slot is the builder, `ghc` or `cc`, to refer to GHC commands or
C compiler commands;
- the final slot is the builder mode, `{c, hs, link, deps, toolargs}`:
- the remaining slots specify the builder and how it was invoked,
* `ghc` refers to GHC commands; the final slot refers to how GHC is invoked:
* `c` for commands that build C files with GHC
* `hs` for commands that compile Haskell modules with GHC
* `link` for GHC linking command
* `deps` for commands that figure out dependencies between Haskell modules
(with `ghc -M`)
* `toolargs` for GHC commands that are used to generate the right ghci
argument for `hadrian/ghci.sh` to work
* `c.opts` for commands that build C files with GHC
* `hs.opts` for commands that compile Haskell modules with GHC
* `link.opts` for GHC linking command
* `deps.opts` for commands that figure out dependencies between Haskell modules
(with `ghc -M`)
* `toolargs.opts` for GHC commands that are used to generate the right ghci
argument for `hadrian/ghci.sh` to work
for GHC and `{c, deps}`:
* `cc` refers to C compiler commands
* `c` for commands that call the C compiler on some C files
* `deps` for commands that call the C compiler for figuring out
dependencies between C files
* `c.opts` for commands that call the C compiler on some C files
* `deps.opts` for commands that call the C compiler for figuring out
dependencies between C files
* `cabal.configure.opts` refers to Cabal configure command line. Note that
package flags can be given by adding `--flags=...` arguments.
for the C compiler;
- using a wildcard (`*`) ranges over all possible values for a given "slot";
- `=` entirely overrides the arguments for a given builder in a given context,
with the value specified on the right hand side of `=`, while `+=` merely
......
......@@ -226,11 +226,18 @@ builderPredicate = builderSetting <&> (\(wstg, wpkg, builderMode) ->
wildcard (pure True) stage wstg <&&>
wildcard (pure True) package wpkg <&&>
(case builderMode of
Left ghcMode -> wildcard (builder Ghc) (builder . Ghc) ghcMode
Right ccMode -> wildcard (builder Cc) (builder . Cc) ccMode))
BM_Ghc ghcMode -> wildcard (builder Ghc) (builder . Ghc) ghcMode
BM_Cc ccMode -> wildcard (builder Cc) (builder . Cc) ccMode
BM_CabalConfigure -> builder (Cabal Setup) )
)
where (<&&>) = liftA2 (&&)
-- | Which builder a setting should apply to
data BuilderMode = BM_Ghc (Wildcard GhcMode)
| BM_Cc (Wildcard CcMode)
| BM_CabalConfigure
-- | Interpretation-agnostic description of the builder settings
-- supported by Hadrian.
--
......@@ -238,6 +245,7 @@ builderPredicate = builderSetting <&> (\(wstg, wpkg, builderMode) ->
--
-- > (<stage> or *).(<package name> or *).ghc.(<ghc mode> or *).opts
-- > (<stage> or *).(<package name> or *).cc.(<cc mode> or *).opts
-- > (<stage> or *).(<package name> or *).cabal.configure.opts
--
-- where:
-- - @<stage>@ is one of @stage0@, @stage1@, @stage2@ or @stage3@;
......@@ -255,13 +263,15 @@ builderPredicate = builderSetting <&> (\(wstg, wpkg, builderMode) ->
-- apply GHC or C compiler options uniformly over all stages, packages
-- and compiler modes, if we so desire, by using a wildcard in the
-- appropriate spot.
builderSetting :: Match f => f (Wildcard Stage, Wildcard Package, Either (Wildcard GhcMode) (Wildcard CcMode))
builderSetting :: Match f
=> f (Wildcard Stage, Wildcard Package, BuilderMode)
builderSetting = (,,)
<$> wild stages
<*> wild pkgs
<*> matchOneOf
[ str "ghc" *> fmap Left (wild ghcBuilder) <* str "opts"
, str "cc" *> fmap Right (wild ccBuilder) <* str "opts"
[ str "ghc" *> fmap BM_Ghc (wild ghcBuilder) <* str "opts"
, str "cc" *> fmap BM_Cc (wild ccBuilder) <* str "opts"
, BM_CabalConfigure <$ str "cabal" <* str "configure" <* str "opts"
]
where ghcBuilder =
......
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