Hadrian: work around Cabal's/GHC's different Arch/OS strings
[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.Nofib
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 (VerboseCommand UserSettings.verboseCommand) argsMap
27
28 BuildRoot buildRoot = CommandLine.lookupBuildRoot argsMap
29
30 rebuild = [ (RebuildLater, buildRoot -/- "stage0//*")
31 | CommandLine.lookupFreeze1 argsMap ]
32
33 options :: ShakeOptions
34 options = shakeOptions
35 { shakeChange = ChangeModtimeAndDigest
36 , shakeFiles = buildRoot -/- Base.shakeFilesDir
37 , shakeProgress = progressSimple
38 , shakeRebuild = rebuild
39 , shakeTimings = True
40 , shakeExtra = extra }
41
42 rules :: Rules ()
43 rules = do
44 Rules.buildRules
45 Rules.Documentation.documentationRules
46 Rules.Clean.cleanRules
47 Rules.Nofib.nofibRules
48 Rules.oracleRules
49 Rules.Selftest.selftestRules
50 Rules.SourceDist.sourceDistRules
51 Rules.Test.testRules
52 Rules.topLevelTargets
53
54 shakeArgsWith options CommandLine.optDescrs $ \_ targets -> do
55 Environment.setupEnvironment
56 return . Just $ if null targets
57 then rules
58 else want targets >> withoutActions rules