[project @ 2001-10-26 00:53:27 by sof]
[ghc-hetmet.git] / ghc / compiler / main / Main.hs
index b11326c..dfe059b 100644 (file)
@@ -1,7 +1,7 @@
 {-# OPTIONS -fno-warn-incomplete-patterns -optc-DNON_POSIX_SOURCE #-}
 
 -----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.87 2001/08/14 13:40:08 sewardj Exp $
+-- $Id: Main.hs,v 1.90 2001/10/26 00:53:27 sof Exp $
 --
 -- GHC Driver program
 --
@@ -43,7 +43,7 @@ import DriverFlags    ( dynFlag, buildStaticHscOpts, dynamic_flags,
                          processArgs, static_flags)
 
 import DriverMkDepend  ( beginMkDependHS, endMkDependHS )
-import DriverPhases    ( Phase(Hsc, HCc), haskellish_src_file, objish_file )
+import DriverPhases    ( Phase(HsPp, Hsc, HCc), haskellish_src_file, objish_file )
 
 import DriverUtil      ( add, handle, handleDyn, later, splitFilename,
                          unknownFlagErr, getFileSuffix )
@@ -211,10 +211,7 @@ main =
                                 -- leave out hscOutName for now
                                 hscOutName = panic "Main.main:hscOutName not set",
 
-                                verbosity = case mode of
-                                               DoInteractive -> 1
-                                               DoMake        -> 1
-                                               _other        -> 0,
+                                verbosity = 1
                                })
 
        -- the rest of the arguments are "dynamic"
@@ -260,7 +257,7 @@ main =
        -- -ohi sanity checking
    ohi    <- readIORef v_Output_hi
    if (isJust ohi && 
-       (mode == DoMake || mode == DoInteractive || length srcs > 1))
+       (mode == DoMake || mode == DoInteractive || srcs `lengthExceeds` 1))
        then throwDyn (UsageError "-ohi can only be used when compiling a single source file")
        else do
 
@@ -270,7 +267,7 @@ main =
 
        -- -o sanity checking
    o_file <- readIORef v_Output_file
-   if (length srcs > 1 && isJust o_file && mode /= DoLink && mode /= DoMkDLL)
+   if (srcs `lengthExceeds` 1 && isJust o_file && mode /= DoLink && mode /= DoMkDLL)
        then throwDyn (UsageError "can't apply -o to multiple source files")
        else do
 
@@ -289,11 +286,12 @@ main =
 
          -- just preprocess (Haskell source only)
          let src_and_suff = (src, getFileSuffix src)
-         pp <- if not (haskellish_src_file src) || mode == StopBefore Hsc
+         let not_hs_file  = not (haskellish_src_file src)
+         pp <- if not_hs_file || mode == StopBefore Hsc || mode == StopBefore HsPp
                        then return src_and_suff else do
                phases <- genPipeline (StopBefore Hsc) stop_flag
-                           False{-not persistent-} defaultHscLang
-                           src_and_suff
+                                     False{-not persistent-} defaultHscLang
+                                     src_and_suff
                pipeLoop phases src_and_suff False{-no linking-} False{-no -o flag-}
                        basename suffix