7592c60cfd51325e07eaee4e34a52c167dcaabd1
[hadrian.git] / src / Rules / Clean.hs
1 module Rules.Clean (clean, cleanSourceTree, cleanRules) where
2
3 import Base
4
5 clean :: Action ()
6 clean = do
7 cleanSourceTree
8 putBuild "| Remove Hadrian files..."
9 path <- buildRoot
10 removeDirectory $ path -/- generatedDir
11 removeFilesAfter path ["//*"]
12 putSuccess "| Done. "
13
14 cleanSourceTree :: Action ()
15 cleanSourceTree = do
16 path <- buildRoot
17 forM_ [Stage0 ..] $ removeDirectory . (path -/-) . stageString
18 removeDirectory inplaceBinPath
19 removeDirectory inplaceLibPath
20 removeDirectory "sdistprep"
21 cleanFsUtils
22
23 -- Clean all temporary fs files copied by configure into the source folder
24 cleanFsUtils :: Action ()
25 cleanFsUtils = do
26 let dirs = [ "utils/lndir/"
27 , "utils/unlit/"
28 , "rts/"
29 , "libraries/base/include/"
30 , "libraries/base/cbits/"
31 ]
32 liftIO $ forM_ dirs (flip removeFiles ["fs.*"])
33
34
35 cleanRules :: Rules ()
36 cleanRules = "clean" ~> clean