summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-01-03 18:16:06 -0500
committerBen Gamari <ben@smart-cactus.org>2020-02-06 14:10:36 -0500
commit3f31785d9683ba4c64e5b995c2215aef48984e6f (patch)
tree4022feabeb6b9ab5cc96f49130254c8eacea57d4
parente8004e5d1e993363a89b0107380604c5bc02be6b (diff)
downloadhaskell-wip/T17612.tar.gz
hadrian: Allow override of Cabal configuration in hadrian.settingswip/T17612
Fixes #17612 by adding a `cabal.configure.opts` key for `hadrian.settings`.
-rw-r--r--hadrian/doc/user-settings.md32
-rwxr-xr-xhadrian/src/Settings.hs20
2 files changed, 32 insertions, 20 deletions
diff --git a/hadrian/doc/user-settings.md b/hadrian/doc/user-settings.md
index 04a526605d..064918efe2 100644
--- a/hadrian/doc/user-settings.md
+++ b/hadrian/doc/user-settings.md
@@ -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
diff --git a/hadrian/src/Settings.hs b/hadrian/src/Settings.hs
index 068e7ba914..b57029a967 100755
--- a/hadrian/src/Settings.hs
+++ b/hadrian/src/Settings.hs
@@ -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 =