import ErrUtils ( showPass )
import Util
import DriverUtil
+import TmpFiles
import Outputable
import Panic
import CmdLineOpts ( DynFlags(..) )
-- Easy; just relink it all.
do when (verb >= 2) $
hPutStrLn stderr "Upsweep completely successful."
+
+ -- clean up after ourselves
+ cleanTempFilesExcept verb (ppFilesFromSummaries modsDone)
+
linkresult
<- link ghci_mode dflags a_root_is_Main ui3 pls2
case linkresult of
= map (unJust "linkables_to_link" . findModuleLinkable_maybe ui4)
mods_to_keep_names
+ -- clean up after ourselves
+ cleanTempFilesExcept verb (ppFilesFromSummaries mods_to_keep)
+
linkresult <- link ghci_mode dflags False linkables_to_link pls2
case linkresult of
LinkErrs _ _
map ms_mod mods_to_keep)
+ppFilesFromSummaries summaries
+ = [ fn | Just fn <- map (ml_hspp_file . ms_location) summaries ]
+
-----------------------------------------------------------------------------
-- getValidLinkables
{-# OPTIONS -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.49 2001/01/21 16:37:06 sewardj Exp $
+-- $Id: Main.hs,v 1.50 2001/02/12 13:33:46 simonmar Exp $
--
-- GHC Driver program
--
later (do forget_it <- readIORef v_Keep_tmp_files
unless forget_it $ do
verb <- dynFlag verbosity
- cleanTempFiles (verb >= 2)
+ cleanTempFiles verb
) $ do
-- exceptions will be blocked while we clean the temporary files,
-- so there shouldn't be any difficulty if we receive further
-----------------------------------------------------------------------------
--- $Id: TmpFiles.hs,v 1.14 2000/12/11 15:26:00 sewardj Exp $
+-- $Id: TmpFiles.hs,v 1.15 2001/02/12 13:33:47 simonmar Exp $
--
-- Temporary file management
--
module TmpFiles (
Suffix,
initTempFileStorage, -- :: IO ()
- cleanTempFiles, -- :: IO ()
+ cleanTempFiles, -- :: Int -> IO ()
+ cleanTempFilesExcept, -- :: Int -> [FilePath] -> IO ()
newTempName, -- :: Suffix -> IO FilePath
addFilesToClean, -- :: [FilePath] -> IO ()
+ removeTmpFiles, -- :: Int -> [FilePath] -> IO ()
v_TmpDir
) where
return ()
)
-cleanTempFiles :: Bool -> IO ()
-cleanTempFiles verbose = do
+cleanTempFiles :: Int -> IO ()
+cleanTempFiles verb = do
fs <- readIORef v_FilesToClean
+ removeTmpFiles verb fs
- let blowAway f =
- (do when verbose (hPutStrLn stderr ("Removing: " ++ f))
- if '*' `elem` f then kludgedSystem ("rm -f " ++ f) "Cleaning temp files" >> return ()
- else removeFile f)
- `catchAllIO`
- (\_ -> when verbose (hPutStrLn stderr
- ("Warning: can't remove tmp file " ++ f)))
- mapM_ blowAway fs
+cleanTempFilesExcept :: Int -> [FilePath] -> IO ()
+cleanTempFilesExcept verb dont_delete = do
+ fs <- readIORef v_FilesToClean
+ let leftovers = filter (`notElem` dont_delete) fs
+ removeTmpFiles verb leftovers
+ writeIORef v_FilesToClean dont_delete
type Suffix = String
addFilesToClean :: [FilePath] -> IO ()
addFilesToClean files = mapM_ (add v_FilesToClean) files
+
+removeTmpFiles :: Int -> [FilePath] -> IO ()
+removeTmpFiles verb fs = do
+ let verbose = verb >= 2
+ blowAway f =
+ (do when verbose (hPutStrLn stderr ("Removing: " ++ f))
+ if '*' `elem` f
+ then kludgedSystem ("rm -f " ++ f) "Cleaning temp files" >> return ()
+ else removeFile f)
+ `catchAllIO`
+ (\_ -> when verbose (hPutStrLn stderr
+ ("Warning: can't remove tmp file " ++ f)))
+ mapM_ blowAway fs