module Rules.Clean (cleanRules) where

import Base
import Package
import Rules.Generate
import Settings.Packages
import Settings.Paths
import Settings.User
import Stage

cleanRules :: Rules ()
cleanRules = do
    "clean" ~> do
        putBuild $ "| Remove files in " ++ buildRootPath ++ "..."
        removeFilesAfter buildRootPath ["//*"]
        putBuild $ "| Remove files in " ++ programInplacePath ++ "..."
        removeFilesAfter programInplacePath ["//*"]
        putBuild $ "| Remove files in inplace/lib..."
        removeFilesAfter "inplace/lib" ["//*"]
        putBuild $ "| Remove files in " ++ derivedConstantsPath ++ "..."
        removeFilesAfter derivedConstantsPath ["//*"]
        forM_ includesDependencies $ \file -> do
            putBuild $ "| Remove " ++ file
            removeFileIfExists file
        putBuild $ "| Remove files generated by ghc-cabal..."
        forM_ knownPackages $ \pkg ->
            forM_ [Stage0 ..] $ \stage -> do
                let dir = pkgPath pkg -/- targetDirectory stage pkg
                removeDirectoryIfExists dir
        putSuccess $ "| Done. "

module Rules.Clean (cleanRules) where

import Base
import Package
import Rules.Generate
import Settings.Packages
import Settings.Paths
import Settings.User
import Stage

cleanRules :: Rules ()
cleanRules = do
    "clean" ~> do
        putBuild $ "| Remove files in " ++ buildRootPath ++ "..."
        liftIO $ removeFiles buildRootPath ["//*"]
        putBuild $ "| Remove files in " ++ programInplacePath ++ "..."
        liftIO $ removeFiles programInplacePath ["//*"]
        putBuild $ "| Remove files in inplace/lib..."
        liftIO $ removeFiles "inplace/lib" ["//*"]
        putBuild $ "| Remove files in " ++ derivedConstantsPath ++ "..."
        liftIO $ removeFiles derivedConstantsPath ["//*"]
        forM_ includesDependencies $ \file -> do
            putBuild $ "| Remove " ++ file
            removeFileIfExists file
        putBuild $ "| Remove files generated by ghc-cabal..."
        forM_ knownPackages $ \pkg ->
            forM_ [Stage0 ..] $ \stage -> do
                let dir = pkgPath pkg -/- targetDirectory stage pkg
                removeDirectoryIfExists dir
        putSuccess $ "| Done. "

Use removeFiles instead of removeFilesAfter.
Use removeFiles instead of removeFilesAfter.

See #131.
