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