From 8dcd00cef7782c64b5484b106f4fd77c8c87e40a Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Thu, 31 Jan 2019 11:01:04 +0000 Subject: Add werror function to Flavour.hs This function makes it easy to turn on `-Werror` in the correct manner to mimic how CI turns on -Werror. --- hadrian/doc/user-settings.md | 11 +++++++++++ hadrian/src/Flavour.hs | 8 +++++++- hadrian/src/UserSettings.hs | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hadrian/doc/user-settings.md b/hadrian/doc/user-settings.md index 49e560cc7e..b997cd977f 100644 --- a/hadrian/doc/user-settings.md +++ b/hadrian/doc/user-settings.md @@ -102,6 +102,17 @@ patterns such as `"//Prelude.*"` can be used when matching input and output file where `//` matches an arbitrary number of path components and `*` matches an entire path component, excluding any separators. +### Enabling -Werror + +It is useful to enable `-Werror` when building GHC as this setting is +used in the CI to ensure a warning free build. The `werror` function can be +used to easily modify a flavour to turn this setting on. + +``` +devel2WerrorFlavour :: Flavour +devel2WerrorFlavour = werror (developmentFlavour Stage2) +``` + ## Packages Users can add and remove packages from particular build stages. As an example, diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs index e95e0d7e1f..23e2aa8a81 100644 --- a/hadrian/src/Flavour.hs +++ b/hadrian/src/Flavour.hs @@ -1,4 +1,4 @@ -module Flavour (Flavour (..)) where +module Flavour (Flavour (..), werror) where import Expression @@ -32,3 +32,9 @@ data Flavour = Flavour { ghcProfiled :: Bool, -- | Build GHC with debug information. ghcDebugged :: Bool } + + +-- | 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") } diff --git a/hadrian/src/UserSettings.hs b/hadrian/src/UserSettings.hs index 8e0b4fc769..c92dd11d44 100644 --- a/hadrian/src/UserSettings.hs +++ b/hadrian/src/UserSettings.hs @@ -2,6 +2,10 @@ -- hadrian/src/UserSettings.hs to hadrian/UserSettings.hs and edit your copy. -- If you don't copy the file your changes will be tracked by git and you can -- accidentally commit them. +-- +-- See doc/user-settings.md for instructions, and src/Flavour.hs for auxiliary +-- functions for manipulating flavours. +-- Please update doc/user-settings.md when committing changes to this file. module UserSettings ( userFlavours, userPackages, userDefaultFlavour, verboseCommand, buildProgressColour, successColour, finalStage -- cgit v1.2.1