Bump Cabal upper bound (#651)
[hadrian.git] / src / Rules / Nofib.hs
1 module Rules.Nofib where
2
3 import Base
4 import Expression
5 import GHC
6 import Oracles.Setting
7 import Target
8
9 import System.Environment
10 import System.Exit
11
12 nofibRules :: Rules ()
13 nofibRules = do
14 root <- buildRootRules
15
16 -- a phony "nofib" rule that just triggers
17 -- the rule below.
18 "nofib" ~> need [root -/- nofibLogFile]
19
20 -- a rule to produce <build root>/nofig-log
21 -- by running the nofib suite and capturing
22 -- the relevant output.
23 root -/- nofibLogFile %> \fp -> do
24 needNofibDeps
25
26 makePath <- builderPath (Make "nofib")
27 top <- topDirectory
28 ghcPath <- builderPath (Ghc CompileHs Stage2)
29 perlPath <- builderPath Perl
30
31 -- some makefiles in nofib rely on a $MAKE
32 -- env var being defined
33 liftIO (setEnv "MAKE" makePath)
34
35 -- this runs make commands in the nofib
36 -- subdirectory, passing the path to
37 -- the GHC to benchmark and perl to
38 -- nofib's makefiles.
39 let nofibArgs = ["WithNofibHc=" ++ (top -/- ghcPath), "PERL=" ++ perlPath]
40 unit $ cmd (Cwd "nofib") [makePath] ["clean"]
41 unit $ cmd (Cwd "nofib") [makePath] (nofibArgs ++ ["boot"])
42 (Exit e, Stdouterr log) <- cmd (Cwd "nofib") [makePath] nofibArgs
43 writeFile' fp log
44 if e == ExitSuccess
45 then putLoud $ "nofib log available at " ++ fp
46 else error $ "nofib failed, full log available at " ++ fp
47
48 nofibLogFile :: FilePath
49 nofibLogFile = "nofib-log"
50
51
52 -- the dependencies that nofib seems to require.
53 needNofibDeps :: Action ()
54 needNofibDeps = do
55 unlitPath <- programPath (Context Stage1 unlit vanilla)
56 mtlPath <- pkgConfFile (Context Stage1 mtl vanilla)
57 need [ unlitPath, mtlPath ]
58 needBuilder (Ghc CompileHs Stage2)