Occurrrence analysis improvements for NOINLINE functions
[ghc.git] / hadrian / src / Main.hs
1 module Main (main) where
2
3 import Development.Shake
4 import Hadrian.Expression
5 import Hadrian.Utilities
6
7 import qualified Base
8 import qualified CommandLine
9 import qualified Environment
10 import qualified Rules
11 import qualified Rules.Clean
12 import qualified Rules.Documentation
13 import qualified Rules.Install
14 import qualified Rules.SourceDist
15 import qualified Rules.Selftest
16 import qualified Rules.Test
17 import qualified UserSettings
18
19 main :: IO ()
20 main = do
21 -- Provide access to command line arguments and some user settings through
22 -- Shake's type-indexed map 'shakeExtra'.
23 argsMap <- CommandLine.cmdLineArgsMap
24 let extra = insertExtra UserSettings.buildProgressColour
25 $ insertExtra UserSettings.successColour
26 $ insertExtra UserSettings.userBuildRoot
27 $ insertExtra (VerboseCommand UserSettings.verboseCommand) argsMap
28
29 BuildRoot buildRoot = UserSettings.userBuildRoot
30
31 rebuild = [ (RebuildLater, buildRoot -/- "stage0//*")
32 | CommandLine.lookupFreeze1 argsMap ]
33
34 options :: ShakeOptions
35 options = shakeOptions
36 { shakeChange = ChangeModtimeAndDigest
37 , shakeFiles = buildRoot -/- Base.shakeFilesDir
38 , shakeProgress = progressSimple
39 , shakeRebuild = rebuild
40 , shakeTimings = True
41 , shakeExtra = extra }
42
43 rules :: Rules ()
44 rules = do
45 Rules.buildRules
46 Rules.Documentation.documentationRules
47 Rules.Clean.cleanRules
48 Rules.Install.installRules
49 Rules.oracleRules
50 Rules.Selftest.selftestRules
51 Rules.SourceDist.sourceDistRules
52 Rules.Test.testRules
53 Rules.topLevelTargets
54
55 shakeArgsWith options CommandLine.optDescrs $ \_ targets -> do
56 Environment.setupEnvironment
57 return . Just $ if null targets
58 then rules
59 else want targets >> withoutActions rules