summaryrefslogtreecommitdiff
path: root/Coolbal
diff options
context:
space:
mode:
Diffstat (limited to 'Coolbal')
-rw-r--r--Coolbal/Options.hs3
-rw-r--r--Coolbal/Target.hs10
2 files changed, 12 insertions, 1 deletions
diff --git a/Coolbal/Options.hs b/Coolbal/Options.hs
index 8b1f807..7901386 100644
--- a/Coolbal/Options.hs
+++ b/Coolbal/Options.hs
@@ -10,6 +10,7 @@ import Options.Applicative
data Options
= Build BuildOptions
+ | Rebuild BuildOptions
| Clean
| Configure
| Run RunOptions
@@ -38,6 +39,8 @@ root =
hsubparser (
command "build" (info (Build <$> buildOptions)
(progDesc "Build the project"))
+ <> command "rebuild" (info (Rebuild <$> buildOptions)
+ (progDesc "Rebuild after deleting compilation artifacts for this project"))
<> command "run" (info (Run <$> runOptions)
(progDesc "Run an executable from the project"))
<> command "clean" (info (pure Clean)
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