{-# OPTIONS -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.54 2001/02/20 11:04:42 simonmar Exp $
+-- $Id: Main.hs,v 1.59 2001/03/06 11:23:46 simonmar Exp $
--
-- GHC Driver program
--
#ifdef GHCI
import InteractiveUI
+import Char ( toLower )
#endif
#ifndef mingw32_TARGET_OS
#endif
import CompManager
+import ParsePkgConf
import DriverPipeline
import DriverState
import DriverFlags
import DriverMkDepend
import DriverUtil
import Panic
-import DriverPhases ( Phase(..), haskellish_file )
+import DriverPhases ( Phase(..), haskellish_file, objish_file )
import CmdLineOpts
import TmpFiles
import Finder ( initFinder )
import CmStaticInfo
import Config
+import Outputable
import Util
-
import Concurrent
import Directory
import IOExts
import IO
import Monad
import List
-import Char ( toLower )
import System
import Maybe
-- new mkdependHS doesn't support all the options that the old one did (-X et al.)
-- time commands when run with -v
-- split marker
--- mkDLL
-- java generation
-- user ways
-- Win32 support: proper signal handling
else do am_inplace <- doesFileExist inplace_pkgconfig
if am_inplace
then writeIORef v_Path_package_config inplace_pkgconfig
- else throwDyn (OtherError "can't find package.conf")
+ else throwDyn (OtherError ("Can't find package.conf in " ++ inplace_pkgconfig))
-- set the location of our various files
if am_installed
-- read the package configuration
conf_file <- readIORef v_Path_package_config
- contents <- readFile conf_file
- let pkg_details = read contents -- ToDo: faster
+ r <- parsePkgConf conf_file
+ case r of {
+ Left err -> throwDyn (OtherError (showSDoc err));
+ Right pkg_details -> do
+
writeIORef v_Package_details pkg_details
-- find the phase to stop after (i.e. -E, -C, -c, -S flags)
when (mode == DoMkDependHS) endMkDependHS
when (mode == DoLink) (doLink o_files)
when (mode == DoMkDLL) (doMkDLL o_files)
-
+ }
-- grab the last -B option on the command line, and
-- set topDir to its value.
setTopDir :: [String] -> IO [String]
return others
beginMake :: [String] -> IO ()
-beginMake mods
- = do case mods of
+beginMake fileish_args
+ = do let (objs, mods) = partition objish_file fileish_args
+ mapM (add v_Ld_inputs) objs
+
+ case mods of
[] -> throwDyn (UsageError "no input files")
[mod] -> do state <- cmInit Batch
cmLoadModule state mod
#else
beginInteractive fileish_args
= do minus_ls <- readIORef v_Cmdline_libraries
- let is_libraryish nm
- = let nmr = map toLower (reverse nm)
- in take 2 nmr == "o."
- libs = map Left (filter is_libraryish fileish_args)
- ++ map Right minus_ls
- mods = filter (not.is_libraryish) fileish_args
- mod = case mods of
- [] -> Nothing
- [mod] -> Just mod
- _ -> throwDyn (UsageError
- "only one module allowed with --interactive")
+
+ let (objs, mods) = partition objish_file fileish_args
+ libs = map Left objs ++ map Right minus_ls
+
state <- cmInit Interactive
- interactiveUI state mod libs
+ case mods of
+ [] -> interactiveUI state Nothing libs
+ [mod] -> interactiveUI state (Just mod) libs
+ _ -> throwDyn (UsageError
+ "only one module allowed with --interactive")
#endif