Commit 123bdb37 authored by kaiha's avatar kaiha
Browse files

Enable optional UserSettings.hs file

Fix #247

The defaul user settings are stored in ./src/UserSettings.hs. If the
user want to override these settings, he can copy this file into ./ and
make the desired changes to ./UserSettings.hs.
parent 45b5f134
......@@ -15,3 +15,6 @@ cabal.sandbox.config
# build.stack.sh specific
/.stack-work/
# the user settings
/UserSettings.hs
......@@ -88,7 +88,7 @@ by Shake oracles.
#### User settings
The `make`-based build system uses `mk/build.mk` to specify user build settings. We
use [`src/Settings/User.hs`][user-settings] for the same purpose, see
use `./UserSettings.hs` for the same purpose, see
[documentation](doc/user-settings.md).
#### Clean and full rebuild
......@@ -155,7 +155,6 @@ helped me endure and enjoy the project.
[windows-build]: https://github.com/snowleopard/hadrian/blob/master/doc/windows.md
[build-artefacts-issue]: https://github.com/snowleopard/hadrian/issues/113
[ghc-split-objs-bug]: https://ghc.haskell.org/trac/ghc/ticket/11315
[user-settings]: https://github.com/snowleopard/hadrian/blob/master/src/Settings/User.hs
[test-issue]: https://github.com/snowleopard/hadrian/issues/197
[dynamic-issue]: https://github.com/snowleopard/hadrian/issues/4
[validation-issue]: https://github.com/snowleopard/hadrian/issues/187
......
# User settings
You can customise Hadrian by specifying user build settings in file
`src/Settings/User.hs`. Here we document currently supported settings.
You can customise Hadrian by copying the file ./src/UserSettings.hs to
./UserSettings.hs and specifying user build settings in
`./UserSettings.hs`. Here we document currently supported settings.
## Build directory
......
......@@ -16,7 +16,8 @@ source-repository head
executable hadrian
main-is: Main.hs
hs-source-dirs: src
hs-source-dirs: .
, src
other-modules: Base
, Builder
, CmdLineFlag
......
......@@ -5,101 +5,8 @@ module Settings.User (
turnWarningsIntoErrors, splitObjects, verboseCommands, putBuild, putSuccess
) where
import System.Console.ANSI
import Base
import CmdLineFlag
import GHC
import Predicate
import Settings.Default
-- See doc/user-settings.md for instructions.
-- | All build results are put into 'buildRootPath' directory.
buildRootPath :: FilePath
buildRootPath = "_build"
-- | Modify default build command line arguments.
userArgs :: Args
userArgs = builder Ghc ? remove ["-Wall", "-fwarn-tabs"]
-- | Modify the set of packages that are built by default in each stage.
userPackages :: Packages
userPackages = mempty
-- | Add user defined packages. Don't forget to add them to 'userPackages' too.
userKnownPackages :: [Package]
userKnownPackages = []
-- | Choose the integer library: 'integerGmp' or 'integerSimple'.
integerLibrary :: Package
integerLibrary = integerGmp
-- FIXME: We skip 'dynamic' since it's currently broken #4.
-- | Modify the set of ways in which library packages are built.
userLibraryWays :: Ways
userLibraryWays = remove [dynamic]
-- | Modify the set of ways in which the 'rts' package is built.
userRtsWays :: Ways
userRtsWays = mempty
-- | User defined flags. Note the following type semantics:
-- * @Bool@: a plain Boolean flag whose value is known at compile time.
-- * @Action Bool@: a flag whose value can depend on the build environment.
-- * @Predicate@: a flag whose value can depend on the build environment and
-- on the current build target.
-- TODO: Drop 'trackBuildSystem' as it brings negligible gains.
-- | Set this to True if you are making any changes in the build system and want
-- appropriate rebuilds to be initiated. Switching this to False speeds things
-- up a little (particularly zero builds).
-- WARNING: a complete rebuild is required when changing this setting.
trackBuildSystem :: Bool
trackBuildSystem = True
-- TODO: This should be set automatically when validating.
validating :: Bool
validating = False
-- | Control when split objects are generated. Note, due to the GHC bug #11315
-- it is necessary to do a full clean rebuild when changing this option.
splitObjects :: Predicate
splitObjects = (return cmdSplitObjects) &&^ defaultSplitObjects
-- | Control when to build Haddock documentation.
buildHaddock :: Predicate
buildHaddock = return cmdBuildHaddock
-- TODO: Do we need to be able to set these from command line?
-- TODO: Turn the flags below into a simple list @ghcWays :: [Way]@?
dynamicGhcPrograms :: Bool
dynamicGhcPrograms = False
ghciWithDebugger :: Bool
ghciWithDebugger = False
ghcProfiled :: Bool
ghcProfiled = False
ghcDebugged :: Bool
ghcDebugged = False
-- TODO: Replace with stage2 ? arg "-Werror"? Also see #251.
-- | To enable -Werror in Stage2 set turnWarningsIntoErrors = stage2.
turnWarningsIntoErrors :: Predicate
turnWarningsIntoErrors = return False
-- | Set to True to print full command lines during the build process. Note,
-- this is a Predicate, hence you can enable verbose output only for certain
-- targets, e.g.: @verboseCommands = package ghcPrim@.
verboseCommands :: Predicate
verboseCommands = return False
-- | Customise build progress messages (e.g. executing a build command).
putBuild :: String -> Action ()
putBuild = putColoured Vivid White
-- | Customise build success messages (e.g. a package is built successfully).
putSuccess :: String -> Action ()
putSuccess = putColoured Vivid Green
-- Import the actual user settings from the module UserSettings.
-- The user can put an UserSettings.hs file into the hadrian root
-- folder that takes precedence over the default UserSettings.hs
-- file located in src/.
import UserSettings
--
-- If you want to customize your build you should copy this file from
-- ./src/UserSettings.hs to ./UserSettings.hs and only edit your copy.
--
module UserSettings (
buildRootPath, trackBuildSystem, userArgs, userPackages, userLibraryWays,
userRtsWays, userKnownPackages, integerLibrary, buildHaddock, validating,
ghciWithDebugger, ghcProfiled, ghcDebugged, dynamicGhcPrograms,
turnWarningsIntoErrors, splitObjects, verboseCommands, putBuild, putSuccess
) where
import System.Console.ANSI
import Base
import CmdLineFlag
import GHC
import Predicate
import Settings.Default
-- See doc/user-settings.md for instructions.
-- | All build results are put into 'buildRootPath' directory.
buildRootPath :: FilePath
buildRootPath = "_build"
-- | Modify default build command line arguments.
userArgs :: Args
userArgs = builder Ghc ? remove ["-Wall", "-fwarn-tabs"]
-- | Modify the set of packages that are built by default in each stage.
userPackages :: Packages
userPackages = mempty
-- | Add user defined packages. Don't forget to add them to 'userPackages' too.
userKnownPackages :: [Package]
userKnownPackages = []
-- | Choose the integer library: 'integerGmp' or 'integerSimple'.
integerLibrary :: Package
integerLibrary = integerGmp
-- FIXME: We skip 'dynamic' since it's currently broken #4.
-- | Modify the set of ways in which library packages are built.
userLibraryWays :: Ways
userLibraryWays = remove [dynamic]
-- | Modify the set of ways in which the 'rts' package is built.
userRtsWays :: Ways
userRtsWays = mempty
-- | User defined flags. Note the following type semantics:
-- * @Bool@: a plain Boolean flag whose value is known at compile time.
-- * @Action Bool@: a flag whose value can depend on the build environment.
-- * @Predicate@: a flag whose value can depend on the build environment and
-- on the current build target.
-- TODO: Drop 'trackBuildSystem' as it brings negligible gains.
-- | Set this to True if you are making any changes in the build system and want
-- appropriate rebuilds to be initiated. Switching this to False speeds things
-- up a little (particularly zero builds).
-- WARNING: a complete rebuild is required when changing this setting.
trackBuildSystem :: Bool
trackBuildSystem = True
-- TODO: This should be set automatically when validating.
validating :: Bool
validating = False
-- | Control when split objects are generated. Note, due to the GHC bug #11315
-- it is necessary to do a full clean rebuild when changing this option.
splitObjects :: Predicate
splitObjects = (return cmdSplitObjects) &&^ defaultSplitObjects
-- | Control when to build Haddock documentation.
buildHaddock :: Predicate
buildHaddock = return cmdBuildHaddock
-- TODO: Do we need to be able to set these from command line?
-- TODO: Turn the flags below into a simple list @ghcWays :: [Way]@?
dynamicGhcPrograms :: Bool
dynamicGhcPrograms = True
ghciWithDebugger :: Bool
ghciWithDebugger = False
ghcProfiled :: Bool
ghcProfiled = False
ghcDebugged :: Bool
ghcDebugged = False
-- TODO: Replace with stage2 ? arg "-Werror"? Also see #251.
-- | To enable -Werror in Stage2 set turnWarningsIntoErrors = stage2.
turnWarningsIntoErrors :: Predicate
turnWarningsIntoErrors = return False
-- | Set to True to print full command lines during the build process. Note,
-- this is a Predicate, hence you can enable verbose output only for certain
-- targets, e.g.: @verboseCommands = package ghcPrim@.
verboseCommands :: Predicate
verboseCommands = return False
-- | Customise build progress messages (e.g. executing a build command).
putBuild :: String -> Action ()
putBuild = putColoured Vivid White
-- | Customise build success messages (e.g. a package is built successfully).
putSuccess :: String -> Action ()
putSuccess = putColoured Vivid Green
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