ca5c0627af15876d85741d41aee78239eb0130f0
[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.Generate
7 import Settings.Packages
8 import Settings.Paths
9 import Settings.User
10 import Stage
11
12 clean :: FilePath -> Action ()
13 clean dir = do
14 putBuild $ "| Remove files in " ++ dir ++ "..."
15 removeDirectoryIfExists dir
16
17 cleanRules :: Rules ()
18 cleanRules = do
19 "clean" ~> do
20 forM_ [Stage0 ..] $ \stage -> clean (buildRootPath -/- stageString stage)
21 clean programInplacePath
22 clean "inplace/lib"
23 clean derivedConstantsPath
24 forM_ includesDependencies $ \file -> do
25 putBuild $ "| Remove " ++ file
26 removeFileIfExists file
27 putBuild $ "| Remove files generated by ghc-cabal..."
28 forM_ knownPackages $ \pkg ->
29 forM_ [Stage0 ..] $ \stage -> do
30 let dir = pkgPath pkg -/- contextDirectory (vanillaContext stage pkg)
31 removeDirectoryIfExists dir
32 putBuild $ "| Remove Hadrian files..."
33 removeFilesAfter buildRootPath ["//*"]
34 putSuccess $ "| Done. "