{-# OPTIONS -W -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.25 2000/11/17 16:53:27 simonmar Exp $
+-- $Id: Main.hs,v 1.29 2000/11/21 14:35:52 simonmar Exp $
--
-- GHC Driver program
--
-- make sure we clean up after ourselves
later (do forget_it <- readIORef v_Keep_tmp_files
unless forget_it $ do
- verb <- readIORef v_Verbose
- cleanTempFiles verb
+ verb <- dynFlag verbosity
+ cleanTempFiles (verb >= 2)
) $ do
-- exceptions will be blocked while we clean the temporary files,
-- so there shouldn't be any difficulty if we receive further
installHandler sigINT sig_handler Nothing
#endif
- pgm <- getProgName
- writeIORef v_Prog_name pgm
-
argv <- getArgs
-- grab any -B options from the command line first
hscLang = lang,
-- leave out hscOutName for now
hscOutName = panic "Main.main:hscOutName not set",
+
+ verbosity = case mode of
+ DoInteractive -> 1
+ DoMake -> 1
+ _other -> 0,
+
flags = [] }
-- the rest of the arguments are "dynamic"
-- complain about any unknown flags
mapM unknownFlagErr [ f | f@('-':_) <- srcs ]
- -- get the -v flag
- verb <- readIORef v_Verbose
+ -- save the flag state, because this could be modified by OPTIONS
+ -- pragmas during the compilation, and we'll need to restore it
+ -- before starting the next compilation.
+ saved_driver_state <- readIORef v_Driver_state
+ writeIORef v_InitDriverState saved_driver_state
- when verb (do hPutStr stderr "Glasgow Haskell Compiler, Version "
- hPutStr stderr cProjectVersion
- hPutStr stderr ", for Haskell 98, compiled by GHC version "
- hPutStrLn stderr cBooterVersion)
+ verb <- dynFlag verbosity
- when verb (hPutStrLn stderr ("Using package config file: " ++ conf_file))
+ when (verb >= 2)
+ (do hPutStr stderr "Glasgow Haskell Compiler, Version "
+ hPutStr stderr cProjectVersion
+ hPutStr stderr ", for Haskell 98, compiled by GHC version "
+ hPutStrLn stderr cBooterVersion)
+
+ when (verb >= 2)
+ (hPutStrLn stderr ("Using package config file: " ++ conf_file))
-- initialise the finder
initFinder pkg_details
if null srcs then throwDyn (UsageError "no input files") else do
- -- save the flag state, because this could be modified by OPTIONS
- -- pragmas during the compilation, and we'll need to restore it
- -- before starting the next compilation.
- saved_driver_state <- readIORef v_Driver_state
-
let compileFile (src, phases) = do
writeIORef v_Driver_state saved_driver_state
writeIORef v_DynFlags init_dyn_flags
= do case mods of
[] -> throwDyn (UsageError "no input files")
[mod] -> do state <- cmInit pkg_details Batch
- cmLoadModule state (mkModuleName mod)
+ cmLoadModule state mod
return ()
_ -> throwDyn (UsageError "only one module allowed with --make")
= do state <- cmInit pkg_details Interactive
case mods of
[] -> return ()
- [mod] -> do cmLoadModule state (mkModuleName mod); return ()
+ [mod] -> do cmLoadModule state mod; return ()
_ -> throwDyn (UsageError
"only one module allowed with --interactive")
interactiveUI state