{-# 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
--
, ( "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) )
-----------------------------------------------------------------------------
--- $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
--
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
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?)
-- 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
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
-----------------------------------------------------------------------------
--- $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
--
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])
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.
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
}
))
ModuleLocation{
ml_hspp_file = Nothing,
ml_hs_file = Nothing,
- ml_hi_file = Just (path ++ '/':hi),
+ ml_hi_file = path ++ '/':hi,
ml_obj_file = Nothing
}
))
(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
= 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
{-# 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
--
-----------------------------------------------------------------------------
-- 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
import SrcLoc ( noSrcLoc )
import Outputable
import Module ( ModuleName )
-import Util ( sortLt, unJust )
+import Util ( sortLt )
import ErrUtils ( dumpIfSet_dyn )
import Monad ( when )
-- 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)
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