Use Cabal directly in place of ghc-cabal + make build root configurable (#531)
[hadrian.git] / src / Rules / Clean.hs
1 module Rules.Clean (clean, cleanRules) where
2
3 import Base
4
5 clean :: Action ()
6 clean = do
7 putBuild "| Removing Hadrian files..."
8 cleanSourceTree
9 path <- buildRoot
10 removeDirectory path
11 putSuccess "| Done. "
12
13 cleanSourceTree :: Action ()
14 cleanSourceTree = do
15 path <- buildRoot
16 forM_ [Stage0 ..] $ removeDirectory . (path -/-) . stageString
17 removeDirectory "sdistprep"
18 cleanFsUtils
19
20 -- Clean all temporary fs files copied by configure into the source folder
21 cleanFsUtils :: Action ()
22 cleanFsUtils = do
23 let dirs = [ "utils/lndir/"
24 , "utils/unlit/"
25 , "rts/"
26 , "libraries/base/include/"
27 , "libraries/base/cbits/"
28 ]
29 liftIO $ forM_ dirs (flip removeFiles ["fs.*"])
30
31 cleanRules :: Rules ()
32 cleanRules = "clean" ~> clean