Commit 11d4fc50 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

hadrian: Introduce enableDebugInfo flavour transformer

Also refactor things a bit to eliminate repetition.
parent 51fad9e6
Pipeline #11476 passed with stages
in 414 minutes and 51 seconds
module Flavour
( Flavour (..), werror
, DocTargets, DocTarget(..)
-- * Flavour transformers
, addArgs
, splitSections, splitSectionsIf
, enableDebugInfo
) where
import Expression
......@@ -34,7 +37,7 @@ data Flavour = Flavour {
ghciWithDebugger :: Bool,
-- | Build profiled GHC.
ghcProfiled :: Bool,
-- | Build GHC with debug information.
-- | Build GHC with debugging assertions.
ghcDebugged :: Bool,
-- | Whether to build docs and which ones
-- (haddocks, user manual, haddock manual)
......@@ -61,10 +64,21 @@ type DocTargets = Set DocTarget
data DocTarget = Haddocks | SphinxHTML | SphinxPDFs | SphinxMan | SphinxInfo
deriving (Eq, Ord, Show, Bounded, Enum)
-- | Add arguments to the 'args' of a 'Flavour'.
addArgs :: Args -> Flavour -> Flavour
addArgs args' fl = fl { args = args fl <> args' }
-- | Turn on -Werror for packages built with the stage1 compiler.
-- It mimics the CI settings so is useful to turn on when developing.
werror :: Flavour -> Flavour
werror fl = fl { args = args fl <> (builder Ghc ? notStage0 ? arg "-Werror") }
werror = addArgs (builder Ghc ? notStage0 ? arg "-Werror")
-- | Build C and Haskell objects with debugging information.
enableDebugInfo :: Flavour -> Flavour
enableDebugInfo = addArgs $ mconcat
[ builder (Ghc CompileHs) ? notStage0 ? arg "-g3"
, builder (Cc CompileC) ? notStage0 ? arg "-g3"
]
-- | Transform the input 'Flavour' so as to build with
-- @-split-sections@ whenever appropriate. You can
......@@ -74,13 +88,11 @@ werror fl = fl { args = args fl <> (builder Ghc ? notStage0 ? arg "-Werror") }
-- building it. If the given flavour doesn't build
-- anything in a @dyn@-enabled way, then 'splitSections' is a no-op.
splitSectionsIf :: (Package -> Bool) -> Flavour -> Flavour
splitSectionsIf pkgPredicate fl = fl { args = args fl <> splitSectionsArg }
where splitSectionsArg = do
way <- getWay
pkg <- getPackage
(Dynamic `wayUnit` way) ? pkgPredicate pkg ?
builder (Ghc CompileHs) ? arg "-split-sections"
splitSectionsIf pkgPredicate = addArgs $ do
way <- getWay
pkg <- getPackage
(Dynamic `wayUnit` way) ? pkgPredicate pkg ?
builder (Ghc CompileHs) ? arg "-split-sections"
-- | Like 'splitSectionsIf', but with a fixed predicate: use
-- split sections for all packages but the GHC library.
......
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