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

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