-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.14 2000/10/31 17:30:17 simonpj Exp $
+-- $Id: DriverFlags.hs,v 1.15 2000/11/08 15:25:25 simonmar Exp $
--
-- Driver flags
--
------- Output Redirection ------------------------------------------
, ( "odir" , HasArg (writeIORef v_Output_dir . Just) )
, ( "o" , SepArg (writeIORef v_Output_file . Just) )
- , ( "osuf" , HasArg (writeIORef v_Output_suf . Just) )
+ , ( "osuf" , HasArg (writeIORef v_Object_suf . Just) )
, ( "hisuf" , HasArg (writeIORef v_Hi_suf) )
, ( "tmpdir" , HasArg (writeIORef v_TmpDir . (++ "/")) )
, ( "ohi" , HasArg (\s -> case s of
-----------------------------------------------------------------------------
--- $Id: DriverPipeline.hs,v 1.15 2000/11/02 13:58:45 sewardj Exp $
+-- $Id: DriverPipeline.hs,v 1.16 2000/11/08 15:25:25 simonmar Exp $
--
-- GHC Driver
--
keep_hc <- readIORef v_Keep_hc_files
keep_raw_s <- readIORef v_Keep_raw_s_files
keep_s <- readIORef v_Keep_s_files
+ osuf <- readIORef v_Object_suf
let
----------- ----- ---- --- -- -- - - -
let
----------- ----- ---- --- -- -- - - -
+ myPhaseInputExt Ln = case osuf of Nothing -> phaseInputExt Ln
+ Just s -> s
+ myPhaseInputExt other = phaseInputExt other
+
annotatePipeline
:: [Phase] -- raw pipeline
-> Phase -- phase to stop before
annotatePipeline [] _ = []
annotatePipeline (Ln:_) _ = []
annotatePipeline (phase:next_phase:ps) stop =
- (phase, keep_this_output, phaseInputExt next_phase)
+ (phase, keep_this_output, myPhaseInputExt next_phase)
: annotatePipeline (next_phase:ps) stop
where
keep_this_output
Just s -> return s
Nothing -> error "outputFileName"
else if keep == Persistent
- then do f <- odir_ify (orig_basename ++ '.':suffix)
- osuf_ify f
+ then odir_ify (orig_basename ++ '.':suffix)
else newTempName suffix
-------------------------------------------------------------------------------
deps <- mapM (findDependency basename) imports
- osuf_opt <- readIORef v_Output_suf
+ osuf_opt <- readIORef v_Object_suf
let osuf = case osuf_opt of
- Nothing -> "o"
+ Nothing -> phaseInputExt Ln
Just s -> s
extra_suffixes <- readIORef v_Dep_suffixes
-----------------------------------------------------------------------------
--- $Id: DriverState.hs,v 1.10 2000/10/27 15:40:01 simonpj Exp $
+-- $Id: DriverState.hs,v 1.11 2000/11/08 15:25:25 simonmar Exp $
--
-- Settings for the driver
--
HscLang)
GLOBAL_VAR(v_Output_dir, Nothing, Maybe String)
-GLOBAL_VAR(v_Output_suf, Nothing, Maybe String)
+GLOBAL_VAR(v_Object_suf, Nothing, Maybe String)
GLOBAL_VAR(v_Output_file, Nothing, Maybe String)
GLOBAL_VAR(v_Output_hi, Nothing, Maybe String)
osuf_ify :: String -> IO String
osuf_ify f = do
- osuf_opt <- readIORef v_Output_suf
+ osuf_opt <- readIORef v_Object_suf
case osuf_opt of
Nothing -> return f
Just s -> return (newsuf s f)
import FiniteMap
import Util
import Panic ( panic )
+import Config
import IOExts
import Directory
case lookupFM home_map lhs of {
Just path -> mkHomeModuleLocn mod_name (path ++ '/':basename) lhs;
- Nothing -> return Nothing
+ Nothing -> do
+
+ -- can't find a source file anywhere, check for a lone .hi file.
+ hisuf <- readIORef v_Hi_suf
+ let hi = basename ++ '.':hisuf
+ case lookupFM home_map hi of {
+ Just path -> mkHomeModuleLocn mod_name (path ++ '/':basename) hs;
+ Nothing -> do
- }}
+ -- last chance: .hi-boot and .hi-boot-<ver>
+ let hi_boot = basename ++ ".hi-boot"
+ let hi_boot_ver = basename ++ ".hi-boot-" ++ cHscIfaceFileVersion
+ case lookupFM home_map hi_boot of {
+ Just path -> mkHomeModuleLocn mod_name (path ++ '/':basename) hs;
+ Nothing -> do
+ case lookupFM home_map hi_boot_ver of {
+ Just path -> mkHomeModuleLocn mod_name (path ++ '/':basename) hs;
+ Nothing -> return Nothing
+ }}}}}
mkHomeModuleLocn mod_name basename source_fn = do
{-# OPTIONS -W -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.17 2000/11/03 10:42:39 simonmar Exp $
+-- $Id: Main.hs,v 1.18 2000/11/08 15:25:25 simonmar Exp $
--
-- GHC Driver program
--
pipelines <- mapM (genPipeline mode stop_flag) srcs
let src_pipelines = zip srcs pipelines
+ -- sanity checking
o_file <- readIORef v_Output_file
- if isJust o_file && mode /= DoLink && length srcs > 1
- then throwDyn (UsageError "can't apply -o option to multiple source files")
+ ohi <- readIORef v_Output_hi
+ if length srcs > 1 && (isJust ohi || (isJust o_file && mode /= DoLink))
+ then throwDyn (UsageError "can't apply -o or -ohi options to multiple source files")
else do
if null srcs then throwDyn (UsageError "no input files") else do