X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FMain.hs;h=99b96292205f18bac4a6411a1cf7631477aef980;hb=9fd23f53af8c45b75b8a4b01d0e6fa1ad6f34aa9;hp=bfd2087681ce56b38ccf5fe5c5e9b2ae98648d32;hpb=f53c4074ff7554ceedaa6b7a5edb2bca7a2d3886;p=ghc-hetmet.git diff --git a/ghc/compiler/main/Main.hs b/ghc/compiler/main/Main.hs index bfd2087..99b9629 100644 --- a/ghc/compiler/main/Main.hs +++ b/ghc/compiler/main/Main.hs @@ -1,6 +1,6 @@ {-# OPTIONS -fno-warn-incomplete-patterns #-} ----------------------------------------------------------------------------- --- $Id: Main.hs,v 1.57 2001/02/28 11:44:39 simonpj Exp $ +-- $Id: Main.hs,v 1.63 2001/04/26 13:52:57 simonmar Exp $ -- -- GHC Driver program -- @@ -18,7 +18,6 @@ module Main (main) where #ifdef GHCI import InteractiveUI -import Char ( toLower ) #endif #ifndef mingw32_TARGET_OS @@ -27,6 +26,7 @@ import Posix #endif import CompManager +import ParsePkgConf import DriverPipeline import DriverState import DriverFlags @@ -39,9 +39,9 @@ import TmpFiles import Finder ( initFinder ) import CmStaticInfo import Config +import Outputable import Util - import Concurrent import Directory import IOExts @@ -139,7 +139,9 @@ main = 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 (InstallationError + ("Can't find package.conf in " ++ + inplace_pkgconfig)) -- set the location of our various files if am_installed @@ -155,8 +157,11 @@ main = -- 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 (InstallationError (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) @@ -180,7 +185,7 @@ main = writeIORef v_OptLevel 0 orig_ways <- readIORef v_Ways when (not (null orig_ways) && mode == DoInteractive) $ - do throwDyn (OtherError + do throwDyn (UsageError "--interactive can't be used with -prof, -ticky, -unreg or -smp.") -- Find the build tag, and re-process the build-specific options. @@ -256,15 +261,21 @@ main = -- mkdependHS is special when (mode == DoMkDependHS) beginMkDependHS + -- -ohi sanity checking + ohi <- readIORef v_Output_hi + if (isJust ohi && + (mode == DoMake || mode == DoInteractive || length srcs > 1)) + then throwDyn (UsageError "-ohi can only be used when compiling a single source file") + else do + -- make/interactive require invoking the compilation manager if (mode == DoMake) then beginMake srcs else do if (mode == DoInteractive) then beginInteractive srcs else do - -- sanity checking + -- -o sanity checking o_file <- readIORef v_Output_file - ohi <- readIORef v_Output_hi - if length srcs > 1 && (isJust ohi || (isJust o_file && mode /= DoLink && mode /= DoMkDLL)) - then throwDyn (UsageError "can't apply -o or -ohi options to multiple source files") + if (length srcs > 1 && isJust o_file && mode /= DoLink && mode /= DoMkDLL) + then throwDyn (UsageError "can't apply -o to multiple source files") else do if null srcs then throwDyn (UsageError "no input files") else do @@ -272,9 +283,12 @@ main = let compileFile src = do writeIORef v_DynFlags init_dyn_flags + exists <- doesFileExist src + when (not exists) $ + throwDyn (CmdLineError ("file `" ++ src ++ "' does not exist")) + -- We compile in two stages, because the file may have an -- OPTIONS pragma that affects the compilation pipeline (eg. -fvia-C) - let (basename, suffix) = splitFilename src -- just preprocess @@ -297,14 +311,14 @@ main = 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] setTopDir args = do let (minusbs, others) = partition (prefixMatch "-B") args (case minusbs of - [] -> writeIORef v_TopDir clibdir + [] -> throwDyn (InstallationError ("missing -B option")) some -> writeIORef v_TopDir (drop 2 (last some))) return others @@ -323,7 +337,7 @@ beginMake fileish_args beginInteractive :: [String] -> IO () #ifndef GHCI -beginInteractive = throwDyn (OtherError "not built for interactive use") +beginInteractive = throwDyn (CmdLineError "not built for interactive use") #else beginInteractive fileish_args = do minus_ls <- readIORef v_Cmdline_libraries