summaryrefslogtreecommitdiff
path: root/Coolbal/Target.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Coolbal/Target.hs')
-rw-r--r--Coolbal/Target.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/Coolbal/Target.hs b/Coolbal/Target.hs
index 64a0a16..68ac043 100644
--- a/Coolbal/Target.hs
+++ b/Coolbal/Target.hs
@@ -14,7 +14,7 @@ import Data.List (intercalate)
import Data.Time.Clock (UTCTime)
import GHC.Generics (Generic)
import Numeric (showHex)
-import System.Directory (createDirectoryIfMissing, doesFileExist, getModificationTime)
+import System.Directory (createDirectoryIfMissing, doesFileExist, getModificationTime, removeDirectoryRecursive)
import System.Exit (ExitCode(..), die, exitWith)
import System.FilePath ((</>))
import System.IO.Error (catchIOError)
@@ -49,6 +49,9 @@ class IsTarget a where
-- directory of the project.
targetExecute :: a -> Maybe (FilePath -> [String] -> IO ())
+ -- | Remove the build artifacts for this target.
+ targetRemoveBuildArtifacts :: FilePath -> a -> IO ()
+
data AnyTarget = AnyTargetExe ExeTarget
deriving (Show, Generic)
@@ -118,6 +121,11 @@ instance IsTarget ExeTarget where
rawSystem (projdir </> "dist-coolbal/bin" </> filename) args
>>= exitWith
+ targetRemoveBuildArtifacts projdir tg =
+ removeDirectoryRecursive
+ (projdir </> "dist-coolbal/build"
+ </> escapeFileName (targetNameQualifiedFilename tg))
+
checkExitCode :: ExitCode -> IO ()
checkExitCode ExitSuccess = return ()
checkExitCode c@(ExitFailure _) = exitWith c