From eef0ac53e01ce80fb4a740f10a09f5126dbacdd4 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 27 Feb 2008 18:23:22 +0000 Subject: [PATCH] Added a flag to the compiler to tell let it to not delete the temporary files it used --- Main.hs | 8 +++++++- data/CompState.hs | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index 35995a1..7f2119f 100644 --- a/Main.hs +++ b/Main.hs @@ -63,6 +63,7 @@ options = , Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")" , 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 ['k'] ["keep-temporaries"] (NoArg $ optKeepTemporaries) "keep temporary files" ] optMode :: String -> OptFunc @@ -96,6 +97,9 @@ optFrontend s ps optVerbose :: OptFunc optVerbose ps = return $ ps { csVerboseLevel = csVerboseLevel ps + 1 } +optKeepTemporaries :: OptFunc +optKeepTemporaries ps = return $ ps { csKeepTemporaries = True } + optOutput :: String -> OptFunc optOutput s ps = return $ ps { csOutputFile = s } @@ -177,7 +181,9 @@ instance Die (StateT [FilePath] PassM) where 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, -- so ignore errors arising from removing the files: - liftIO $ removeFiles files + optsPS <- lift $ getCompState + when (not $ csKeepTemporaries optsPS) $ + liftIO $ removeFiles files lift $ dieReport err compileFull :: String -> StateT [FilePath] PassM () diff --git a/data/CompState.hs b/data/CompState.hs index 1d9a1f9..ed255d0 100644 --- a/data/CompState.hs +++ b/data/CompState.hs @@ -61,6 +61,7 @@ data CompState = CompState { csUsageChecking :: Bool, csVerboseLevel :: Int, csOutputFile :: String, + csKeepTemporaries :: Bool, -- Set by preprocessor csCurrentFile :: String, @@ -94,6 +95,7 @@ emptyState = CompState { csUsageChecking = False, -- For now! TODO turn this on by default csVerboseLevel = 0, csOutputFile = "-", + csKeepTemporaries = False, csCurrentFile = "none", csUsedFiles = Set.empty,