Use Cabal directly in place of ghc-cabal + make build root configurable (#531)
[hadrian.git] / src / Rules / Configure.hs
1 module Rules.Configure (configureRules) where
2
3 import qualified System.Info.Extra as System
4
5 import Base
6 import Builder
7 import CommandLine
8 import Context
9 import GHC
10 import Target
11 import Utilities
12
13 configureRules :: Rules ()
14 configureRules = do
15 [configFile, "settings", configH, "compiler/ghc.cabal"] &%> \outs -> do
16 skip <- not <$> cmdConfigure
17 if skip
18 then unlessM (doesFileExist configFile) $
19 error $ "Configuration file " ++ configFile ++ " is missing.\n"
20 ++ "Run the configure script manually or let Hadrian run it "
21 ++ "automatically by passing the flag --configure."
22 else do
23 -- We cannot use windowsHost here due to a cyclic dependency.
24 when System.isWindows $ do
25 putBuild "| Checking for Windows tarballs..."
26 quietly $ cmd ["bash", "mk/get-win32-tarballs.sh", "download", System.arch]
27 let srcs = map (<.> "in") outs
28 context = vanillaContext Stage0 compiler
29 need srcs
30 build $ target context (Configure ".") srcs outs
31
32 ["configure", configH <.> "in"] &%> \_ -> do
33 skip <- not <$> cmdConfigure
34 if skip
35 then unlessM (doesFileExist "configure") $
36 error $ "The configure script is missing.\nRun the boot script "
37 ++ "manually let Hadrian run it automatically by passing the "
38 ++ "flag --configure."
39 else do
40 need ["configure.ac"]
41 putBuild "| Running boot..."
42 verbosity <- getVerbosity
43 quietly $ cmd [EchoStdout (verbosity >= Loud)] "python3 boot"