050d7f3de8bc1f372d407428d374dcfe1ecb72ee
[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 -- TODO: consider other files we should track here, e.g. @rts/rts.cabal@.
16 [configFile, "settings", configH, "compiler/ghc.cabal"] &%> \outs -> do
17 skip <- not <$> cmdConfigure
18 if skip
19 then unlessM (doesFileExist configFile) $
20 error $ "Configuration file " ++ configFile ++ " is missing.\n"
21 ++ "Run the configure script manually or let Hadrian run it "
22 ++ "automatically by passing the flag --configure."
23 else do
24 -- We cannot use windowsHost here due to a cyclic dependency.
25 when System.isWindows $ do
26 putBuild "| Checking for Windows tarballs..."
27 quietly $ cmd ["bash", "mk/get-win32-tarballs.sh", "download", System.arch]
28 let srcs = map (<.> "in") outs
29 context = vanillaContext Stage0 compiler
30 need srcs
31 build $ target context (Configure ".") srcs outs
32 -- We need to copy the directory with unpacked Windows tarball to
33 -- the build directory, so that the built GHC has access to it.
34 -- See https://github.com/snowleopard/hadrian/issues/564.
35 when System.isWindows $ do
36 root <- buildRoot
37 copyDirectory "inplace/mingw" (root -/- "mingw")
38
39 ["configure", configH <.> "in"] &%> \_ -> do
40 skip <- not <$> cmdConfigure
41 if skip
42 then unlessM (doesFileExist "configure") $
43 error $ "The configure script is missing.\nRun the boot script "
44 ++ "manually let Hadrian run it automatically by passing the "
45 ++ "flag --configure."
46 else do
47 need ["configure.ac"]
48 putBuild "| Running boot..."
49 verbosity <- getVerbosity
50 quietly $ cmd [EchoStdout (verbosity >= Loud)] "python3 boot --hadrian"