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