Added a flag to the compiler to tell let it to not delete the temporary files it used
This commit is contained in:
parent
b0fac1f82a
commit
eef0ac53e0
8
Main.hs
8
Main.hs
|
@ -63,6 +63,7 @@ options =
|
||||||
, Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")"
|
, Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")"
|
||||||
, Option [] ["usage-checking"] (ReqArg optUsageChecking "SETTING") "usage checking (EXPERIMENTAL) (options: on, off)"
|
, Option [] ["usage-checking"] (ReqArg optUsageChecking "SETTING") "usage checking (EXPERIMENTAL) (options: on, off)"
|
||||||
, Option [] ["sanity-check"] (ReqArg optSanityCheck "SETTING") "internal sanity check (options: on, off)"
|
, Option [] ["sanity-check"] (ReqArg optSanityCheck "SETTING") "internal sanity check (options: on, off)"
|
||||||
|
, Option ['k'] ["keep-temporaries"] (NoArg $ optKeepTemporaries) "keep temporary files"
|
||||||
]
|
]
|
||||||
|
|
||||||
optMode :: String -> OptFunc
|
optMode :: String -> OptFunc
|
||||||
|
@ -96,6 +97,9 @@ optFrontend s ps
|
||||||
optVerbose :: OptFunc
|
optVerbose :: OptFunc
|
||||||
optVerbose ps = return $ ps { csVerboseLevel = csVerboseLevel ps + 1 }
|
optVerbose ps = return $ ps { csVerboseLevel = csVerboseLevel ps + 1 }
|
||||||
|
|
||||||
|
optKeepTemporaries :: OptFunc
|
||||||
|
optKeepTemporaries ps = return $ ps { csKeepTemporaries = True }
|
||||||
|
|
||||||
optOutput :: String -> OptFunc
|
optOutput :: String -> OptFunc
|
||||||
optOutput s ps = return $ ps { csOutputFile = s }
|
optOutput s ps = return $ ps { csOutputFile = s }
|
||||||
|
|
||||||
|
@ -177,7 +181,9 @@ instance Die (StateT [FilePath] PassM) where
|
||||||
dieReport err = do files <- get
|
dieReport err = do files <- get
|
||||||
-- If removing the files fails, we don't want to die with that error; we want the user to see the original error,
|
-- If removing the files fails, we don't want to die with that error; we want the user to see the original error,
|
||||||
-- so ignore errors arising from removing the files:
|
-- so ignore errors arising from removing the files:
|
||||||
liftIO $ removeFiles files
|
optsPS <- lift $ getCompState
|
||||||
|
when (not $ csKeepTemporaries optsPS) $
|
||||||
|
liftIO $ removeFiles files
|
||||||
lift $ dieReport err
|
lift $ dieReport err
|
||||||
|
|
||||||
compileFull :: String -> StateT [FilePath] PassM ()
|
compileFull :: String -> StateT [FilePath] PassM ()
|
||||||
|
|
|
@ -61,6 +61,7 @@ data CompState = CompState {
|
||||||
csUsageChecking :: Bool,
|
csUsageChecking :: Bool,
|
||||||
csVerboseLevel :: Int,
|
csVerboseLevel :: Int,
|
||||||
csOutputFile :: String,
|
csOutputFile :: String,
|
||||||
|
csKeepTemporaries :: Bool,
|
||||||
|
|
||||||
-- Set by preprocessor
|
-- Set by preprocessor
|
||||||
csCurrentFile :: String,
|
csCurrentFile :: String,
|
||||||
|
@ -94,6 +95,7 @@ emptyState = CompState {
|
||||||
csUsageChecking = False, -- For now! TODO turn this on by default
|
csUsageChecking = False, -- For now! TODO turn this on by default
|
||||||
csVerboseLevel = 0,
|
csVerboseLevel = 0,
|
||||||
csOutputFile = "-",
|
csOutputFile = "-",
|
||||||
|
csKeepTemporaries = False,
|
||||||
|
|
||||||
csCurrentFile = "none",
|
csCurrentFile = "none",
|
||||||
csUsedFiles = Set.empty,
|
csUsedFiles = Set.empty,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user