Drop removeDirectoryIfExists.
[ghc.git] / src / Rules / Clean.hs
1 module Rules.Clean (cleanRules) where
2
3 import Base
4 import Context
5 import Package
6 import Rules.Actions
7 import Rules.Generate
8 import Settings.Packages
9 import Settings.Paths
10 import Settings.User
11 import Stage
12
13 cleanRules :: Rules ()
14 cleanRules = do
15 "clean" ~> do
16 forM_ [Stage0 ..] $ removeDirectory . (buildRootPath -/-) . stageString
17 removeDirectory programInplacePath
18 removeDirectory "inplace/lib"
19 removeDirectory derivedConstantsPath
20 forM_ includesDependencies $ \file -> do
21 putBuild $ "| Remove " ++ file
22 removeFileIfExists file
23 putBuild $ "| Remove files generated by ghc-cabal..."
24 forM_ knownPackages $ \pkg ->
25 forM_ [Stage0 ..] $ \stage -> do
26 let dir = pkgPath pkg -/- contextDirectory (vanillaContext stage pkg)
27 quietly $ removeDirectory dir
28 putBuild $ "| Remove Hadrian files..."
29 removeFilesAfter buildRootPath ["//*"]
30 putSuccess $ "| Done. "