[project @ 2000-10-31 12:07:43 by simonpj]
[ghc-hetmet.git] / ghc / compiler / main / DriverPipeline.hs
index 022b707..1a3fc0d 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverPipeline.hs,v 1.8 2000/10/26 16:21:02 sewardj Exp $
+-- $Id: DriverPipeline.hs,v 1.13 2000/10/30 18:13:15 sewardj Exp $
 --
 -- GHC Driver
 --
@@ -30,7 +30,6 @@ import DriverMkDepend
 import DriverPhases
 import DriverFlags
 import HscMain
-import Finder
 import TmpFiles
 import HscTypes
 import Outputable
@@ -38,13 +37,10 @@ import Module
 import CmdLineOpts
 import Config
 import Util
-import MkIface         ( pprIface )
 
-import Posix
 import Directory
 import System
 import IOExts
--- import Posix                commented out temp by SLPJ to get going on windows
 import Exception
 
 import IO
@@ -391,6 +387,8 @@ run_phase MkDependHS basename suff input_fn _output_fn = do
 -----------------------------------------------------------------------------
 -- Hsc phase
 
+-- Compilation of a single module, in "legacy" mode (_not_ under
+-- the direction of the compilation manager).
 run_phase Hsc basename suff input_fn output_fn
   = do
        
@@ -406,15 +404,15 @@ run_phase Hsc basename suff input_fn output_fn
        ohi    <- readIORef v_Output_hi
        hisuf  <- readIORef v_Hi_suf
        let hifile = case ohi of
-                          Nothing -> current_dir ++ {-ToDo: modname!!-}basename
-                                       ++ hisuf
+                          Nothing -> current_dir ++ "/" ++ basename
+                                       ++ "." ++ hisuf
                           Just fn -> fn
 
   -- figure out if the source has changed, for recompilation avoidance.
   -- only do this if we're eventually going to generate a .o file.
   -- (ToDo: do when generating .hc files too?)
   --
-  -- Setting source_unchanged to "-fsource_unchanged" means that M.o seems
+  -- Setting source_unchanged to "-fsource-unchanged" means that M.o seems
   -- to be up to date wrt M.hs; so no need to recompile unless imports have
   -- changed (which the compiler itself figures out).
   -- Setting source_unchanged to "" tells the compiler that M.o is out of
@@ -434,12 +432,13 @@ run_phase Hsc basename suff input_fn output_fn
                                  then return "-fsource-unchanged"
                                  else return ""
 
-   -- build a bogus ModSummary to pass to hscMain.
-       let summary = ModSummary {
-                       ms_location = error "no loc",
-                       ms_ppsource = Just (input_fn, error "no fingerprint"),
-                       ms_imports = error "no imports"
-                    }
+   -- build a bogus ModuleLocation to pass to hscMain.
+        let location = ModuleLocation {
+                          ml_hs_file   = Nothing,
+                          ml_hspp_file = Just input_fn,
+                          ml_hi_file   = Just hifile,
+                          ml_obj_file  = Just o_file
+                       }
 
   -- get the DynFlags
         dyn_flags <- readIORef v_DynFlags
@@ -447,8 +446,8 @@ run_phase Hsc basename suff input_fn output_fn
   -- run the compiler!
         pcs <- initPersistentCompilerState
        result <- hscMain dyn_flags{ hscOutName = output_fn }
-                         (error "no Finder!")
-                         summary 
+                         (source_unchanged == "-fsource-unchanged")
+                         location
                          Nothing        -- no iface
                          emptyModuleEnv -- HomeSymbolTable
                          emptyModuleEnv -- HomeIfaceTable
@@ -572,7 +571,7 @@ run_phase SplitMangle _basename _suff input_fn _output_fn
 
        -- this is the prefix used for the split .s files
        tmp_pfx <- readIORef v_TmpDir
-       x <- getProcessID
+       x <- myGetProcessID
        let split_s_prefix = tmp_pfx ++ "/ghc" ++ show x
        writeIORef v_Split_prefix split_s_prefix
        addFilesToClean [split_s_prefix ++ "__*"] -- d:-)
@@ -689,8 +688,9 @@ preprocess filename =
   do pipeline <- genPipeline (StopBefore Hsc) ("preprocess") filename
      runPipeline pipeline filename False{-no linking-} False{-no -o flag-}
 
+
 -----------------------------------------------------------------------------
--- Compile a single module.
+-- Compile a single module, under the control of the compilation manager.
 --
 -- This is the interface between the compilation manager and the
 -- compiler proper (hsc), where we deal with tedious details like
@@ -703,8 +703,7 @@ preprocess filename =
 -- the .hs file if necessary, and compiling up the .stub_c files to
 -- generate Linkables.
 
-compile :: Finder                  -- to find modules
-        -> ModSummary              -- summary, including source
+compile :: ModSummary              -- summary, including source
         -> Maybe ModIface          -- old interface, if available
         -> HomeSymbolTable         -- for home module ModDetails
        -> HomeIfaceTable          -- for home module Ifaces
@@ -721,7 +720,7 @@ data CompResult
    | CompErrs PersistentCompilerState  -- updated PCS
 
 
-compile finder summary old_iface hst hit pcs = do 
+compile summary old_iface hst hit pcs = do 
    verb <- readIORef v_Verbose
    when verb (hPutStrLn stderr 
                  (showSDoc (text "compile: compiling" 
@@ -729,10 +728,9 @@ compile finder summary old_iface hst hit pcs = do
 
    init_dyn_flags <- readIORef v_InitDynFlags
    writeIORef v_DynFlags init_dyn_flags
-   
-   let input_fn = case ms_ppsource summary of
-                       Just (ppsource, fingerprint) -> ppsource
-                       Nothing -> hs_file (ms_location summary)
+
+   let location = ms_location summary   
+   let input_fn = unJust (ml_hs_file location) "compile:hs"
 
    when verb (hPutStrLn stderr ("compile: input file " ++ input_fn))
 
@@ -749,7 +747,8 @@ compile finder summary old_iface hst hit pcs = do
 
    -- run the compiler
    hsc_result <- hscMain dyn_flags{ hscOutName = output_fn } 
-                         finder summary old_iface hst hit pcs
+                        (panic "compile:source_unchanged")
+                         location old_iface hst hit pcs
 
    case hsc_result of {
       HscFail pcs -> return (CompErrs pcs);
@@ -762,7 +761,7 @@ compile finder summary old_iface hst hit pcs = do
                Nothing -> return (CompOK details Nothing pcs);
                Just iface -> do
 
-          let (basename, _) = splitFilename (hs_file (ms_location summary))
+          let (basename, _) = splitFilename input_fn
           maybe_stub_o <- dealWithStubs basename maybe_stub_h maybe_stub_c
           let stub_unlinked = case maybe_stub_o of
                                  Nothing -> []