Refactor paths using Context.
[hadrian.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 cleanRules :: Rules ()
13 cleanRules = do
14 "clean" ~> do
15 putBuild $ "| Remove files in " ++ buildRootPath ++ "..."
16 liftIO $ removeFiles buildRootPath ["//*"]
17 putBuild $ "| Remove files in " ++ programInplacePath ++ "..."
18 liftIO $ removeFiles programInplacePath ["//*"]
19 putBuild $ "| Remove files in inplace/lib..."
20 liftIO $ removeFiles "inplace/lib" ["//*"]
21 putBuild $ "| Remove files in " ++ derivedConstantsPath ++ "..."
22 liftIO $ removeFiles derivedConstantsPath ["//*"]
23 forM_ includesDependencies $ \file -> do
24 putBuild $ "| Remove " ++ file
25 removeFileIfExists file
26 putBuild $ "| Remove files generated by ghc-cabal..."
27 forM_ knownPackages $ \pkg ->
28 forM_ [Stage0 ..] $ \stage -> do
29 let dir = pkgPath pkg -/- contextDirectory (vanillaContext stage pkg)
30 removeDirectoryIfExists dir
31 putBuild $ "| Remove the Shake database " ++ shakeFilesPath ++ "..."
32 removeFilesAfter shakeFilesPath ["//*"]
33 putSuccess $ "| Done. "