[project @ 2001-05-31 11:32:25 by simonmar]
authorsimonmar <unknown>
Thu, 31 May 2001 11:32:25 +0000 (11:32 +0000)
committersimonmar <unknown>
Thu, 31 May 2001 11:32:25 +0000 (11:32 +0000)
- add -hidir flag to control the destination for .hi files when doing
  multiple compilations (matches -odir).

- change the ml_hi_file component of ModuleLocation from Maybe FilePath to
  FilePath.  We never made use of its Maybeness.

- clear out some unused code from the Hsc phase of run_phase and clean up
  a bit.  Fix a bug with the -ohi option at the same time (I don't think
  it works in 5.xx.x before this patch).

ghc/compiler/main/DriverFlags.hs
ghc/compiler/main/DriverPipeline.hs
ghc/compiler/main/DriverState.hs
ghc/compiler/main/Finder.lhs
ghc/compiler/main/HscMain.lhs
ghc/compiler/main/HscTypes.lhs
ghc/compiler/main/Main.hs
ghc/compiler/main/MkIface.lhs
ghc/compiler/rename/RnHiFiles.lhs

index e49a7d9..146cfa6 100644 (file)
@@ -1,7 +1,7 @@
 {-# OPTIONS -#include "hschooks.h" #-}
 
 -----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.55 2001/05/28 03:31:19 sof Exp $
+-- $Id: DriverFlags.hs,v 1.56 2001/05/31 11:32:25 simonmar Exp $
 --
 -- Driver flags
 --
@@ -208,6 +208,7 @@ static_flags =
   ,  ( "osuf"          , HasArg (writeIORef v_Object_suf  . Just) )
   ,  ( "hcsuf"         , HasArg (writeIORef v_HC_suf      . Just) )
   ,  ( "hisuf"         , HasArg (writeIORef v_Hi_suf) )
+  ,  ( "hidir"         , HasArg (writeIORef v_Hi_dir . Just) )
   ,  ( "buildtag"      , HasArg (writeIORef v_Build_tag) )
   ,  ( "tmpdir"                , HasArg (writeIORef v_TmpDir . (++ "/")) )
   ,  ( "ohi"           , HasArg (writeIORef v_Output_hi   . Just) )
index bb7cf41..48ae181 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverPipeline.hs,v 1.72 2001/05/29 17:53:59 sof Exp $
+-- $Id: DriverPipeline.hs,v 1.73 2001/05/31 11:32:25 simonmar Exp $
 --
 -- GHC Driver
 --
@@ -445,13 +445,6 @@ run_phase Hsc basename suff input_fn output_fn
        paths <- readIORef v_Include_paths
        writeIORef v_Include_paths (current_dir : paths)
        
-  -- figure out where to put the .hi file
-       ohi    <- readIORef v_Output_hi
-       hisuf  <- readIORef v_Hi_suf
-       let hifile = case ohi of
-                          Nothing -> basename ++ '.':hisuf
-                          Just fn -> fn
-
   -- figure out which header files to #include in a generated .hc file
        c_includes <- getPackageCIncludes
        cmdline_includes <- dynFlag cmdlineHcIncludes -- -#include options
@@ -466,6 +459,18 @@ run_phase Hsc basename suff input_fn output_fn
 
        writeIORef v_HCHeader cc_injects
 
+  -- gather the imports and module name
+        (srcimps,imps,mod_name) <- getImportsFromFile input_fn
+
+  -- build a ModuleLocation to pass to hscMain.
+       Just (mod, location')
+          <- mkHomeModuleLocn mod_name basename (basename ++ '.':suff)
+
+  -- take -ohi into account if present
+       ohi <- readIORef v_Output_hi
+       let location | Just fn <- ohi = location'{ ml_hi_file = fn }
+                    | otherwise      = location'
+
   -- 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?)
@@ -477,8 +482,7 @@ run_phase Hsc basename suff input_fn output_fn
   -- date wrt M.hs (or M.o doesn't exist) so we must recompile regardless.
        do_recomp <- readIORef v_Recomp
        todo <- readIORef v_GhcMode
-        o_file' <- odir_ify (basename ++ '.':phaseInputExt Ln)
-        o_file <- osuf_ify o_file'
+        let o_file = unJust "source_unchanged" (ml_obj_file location)
        source_unchanged <- 
           if not (do_recomp && ( todo == DoLink || todo == StopBefore Ln ))
             then return False
@@ -491,12 +495,6 @@ run_phase Hsc basename suff input_fn output_fn
                                  then return True
                                  else return False
 
-        -- build a ModuleLocation to pass to hscMain.
-        (srcimps,imps,mod_name) <- getImportsFromFile input_fn
-
-       Just (mod, location)
-          <- mkHomeModuleLocn mod_name basename (basename ++ '.':suff)
-
   -- get the DynFlags
         dyn_flags <- readIORef v_DynFlags
 
index aff192f..18a50c2 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverState.hs,v 1.40 2001/05/28 03:31:19 sof Exp $
+-- $Id: DriverState.hs,v 1.41 2001/05/31 11:32:25 simonmar Exp $
 --
 -- Settings for the driver
 --
@@ -98,6 +98,7 @@ GLOBAL_VAR(v_Output_hi,   Nothing, Maybe String)
 
 GLOBAL_VAR(v_Object_suf,  Nothing, Maybe String)
 GLOBAL_VAR(v_HC_suf,     Nothing, Maybe String)
+GLOBAL_VAR(v_Hi_dir,      Nothing, Maybe String)
 GLOBAL_VAR(v_Hi_suf,      "hi",           String)
 
 GLOBAL_VAR(v_Ld_inputs,        [],      [String])
index 176a244..b858f24 100644 (file)
@@ -138,8 +138,12 @@ maybeHomeModule mod_name = do
 mkHomeModuleLocn mod_name basename source_fn = do
 
    hisuf  <- readIORef v_Hi_suf
-   let hifile = getdir basename ++ '/':moduleNameUserString mod_name 
-                               ++ '.':hisuf
+   hidir  <- readIORef v_Hi_dir
+
+   let dir | Just d <- hidir = d
+          | otherwise       = getdir basename 
+
+       hifile = dir ++ '/':moduleNameUserString mod_name ++ '.':hisuf
 
    -- figure out the .o file name.  It also lives in the same dir
    -- as the source, but can be overriden by a -odir flag.
@@ -149,7 +153,7 @@ mkHomeModuleLocn mod_name basename source_fn = do
                  ModuleLocation{
                     ml_hspp_file = Nothing,
                    ml_hs_file   = Just source_fn,
-                   ml_hi_file   = Just hifile,
+                   ml_hi_file   = hifile,
                    ml_obj_file  = Just o_file
                 }
        ))
@@ -191,7 +195,7 @@ maybePackageModule mod_name = do
                          ModuleLocation{ 
                                 ml_hspp_file = Nothing,
                                ml_hs_file   = Nothing,
-                               ml_hi_file   = Just (path ++ '/':hi),
+                               ml_hi_file   = path ++ '/':hi,
                                ml_obj_file  = Nothing
                           }
                   ))
index d10faa2..a138007 100644 (file)
@@ -129,8 +129,7 @@ hscMain ghci_mode dflags mod location source_unchanged have_object
 
       (pcs_ch, errs_found, (recomp_reqd, maybe_checked_iface))
          <- _scc_ "checkOldIface"
-           checkOldIface ghci_mode dflags hit hst pcs 
-               (unJust "hscMain" (ml_hi_file location))
+           checkOldIface ghci_mode dflags hit hst pcs (ml_hi_file location)
                source_unchanged maybe_old_iface;
 
       if errs_found then
index 4671fc4..a490730 100644 (file)
@@ -93,7 +93,7 @@ data ModuleLocation
    = ModuleLocation {
         ml_hs_file   :: Maybe FilePath,
         ml_hspp_file :: Maybe FilePath,  -- path of preprocessed source
-        ml_hi_file   :: Maybe FilePath,
+        ml_hi_file   :: FilePath,
         ml_obj_file  :: Maybe FilePath
      }
      deriving Show
index 60b1d6e..e9bc928 100644 (file)
@@ -1,6 +1,6 @@
 {-# OPTIONS -fno-warn-incomplete-patterns #-}
 -----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.66 2001/05/28 03:31:19 sof Exp $
+-- $Id: Main.hs,v 1.67 2001/05/31 11:32:25 simonmar Exp $
 --
 -- GHC Driver program
 --
@@ -63,7 +63,6 @@ import Maybe
 -----------------------------------------------------------------------------
 -- ToDo:
 
--- -nohi doesn't work
 -- new mkdependHS doesn't support all the options that the old one did (-X et al.)
 -- time commands when run with -v
 -- split marker
index 992f086..85b7a92 100644 (file)
@@ -55,7 +55,7 @@ import Type           ( splitSigmaTy, tidyTopType, deNoteType, namesOfDFunHead )
 import SrcLoc          ( noSrcLoc )
 import Outputable
 import Module          ( ModuleName )
-import Util            ( sortLt, unJust )
+import Util            ( sortLt )
 import ErrUtils                ( dumpIfSet_dyn )
 
 import Monad           ( when )
@@ -112,7 +112,7 @@ mkFinalIface ghci_mode dflags location
                --     so there's no need to write a new interface file.  But even if 
                --     the usages have changed, the module version may not have.
 
-     hi_file_path = unJust "mkFinalIface" (ml_hi_file location)
+     hi_file_path = ml_hi_file location
      new_decls    = mkIfaceDecls ty_cls_dcls rule_dcls inst_dcls
      inst_dcls    = map ifaceInstance (md_insts new_details)
      ty_cls_dcls  = foldNameEnv ifaceTyCls [] (md_types new_details)
index 6d4f26f..7e2a3db 100644 (file)
@@ -522,7 +522,7 @@ mkHiPath hi_boot_file locn
        if b then returnRn hi_boot_ver_path
             else returnRn hi_boot_path
   | otherwise    = returnRn hi_path
-       where (Just hi_path)     = ml_hi_file locn
+       where hi_path            = ml_hi_file locn
              (hi_base, _hi_suf) = splitFilename hi_path
              hi_boot_path       = hi_base ++ ".hi-boot"
              hi_boot_ver_path   = hi_base ++ ".hi-boot-" ++ cHscIfaceFileVersion