-- Implementations of the various modes (--show-iface, mkdependHS. etc.)
import LoadIface ( showIface )
+import HscMain ( newHscEnv )
import DriverPipeline ( oneShot, compileFile )
import DriverMkDepend ( doMkDependHS )
#ifdef GHCI
-- Various other random stuff that we need
import Config ( cProjectVersion, cBooterVersion, cProjectName )
-import Packages ( dumpPackages, initPackages )
+import Packages ( dumpPackages )
import DriverPhases ( Phase(..), isSourceFilename, anyHsc,
startPhase, isHaskellSrcFilename )
-import StaticFlags ( staticFlags, v_Ld_inputs, parseStaticFlags )
+import StaticFlags
import DynFlags ( defaultDynFlags )
import BasicTypes ( failed )
-import ErrUtils ( Message, debugTraceMsg, putMsg )
+import ErrUtils ( putMsg )
import FastString ( getFastStringTable, isZEncoded, hasZEncoding )
import Outputable
import Util
import Panic
-- Standard Haskell libraries
-import EXCEPTION ( throwDyn )
-import IO
-import Directory ( doesDirectoryExist )
-import System ( getArgs, exitWith, ExitCode(..) )
-import Monad
-import List
-import Maybe
+import Control.Exception ( throwDyn )
+import System.IO
+import System.Directory ( doesDirectoryExist )
+import System.Environment
+import System.Exit
+import Control.Monad
+import Data.List
+import Data.Maybe
-----------------------------------------------------------------------------
-- ToDo:
PrintLibdir -> putStrLn (topDir dflags)
ShowVersion -> showVersion
ShowNumVersion -> putStrLn cProjectVersion
- ShowInterface f -> showIface f
+ ShowInterface f -> doShowIface dflags f
DoMake -> doMake session srcs
DoMkDependHS -> doMkDependHS session (map fst srcs)
StopBefore p -> oneShot dflags p srcs
when (notNull unknown_opts) (unknownFlagsErr unknown_opts)
-- -prof and --interactive are not a good combination
- when (notNull (wayNames dflags) && isInterpretiveMode cli_mode) $
+ when (notNull (filter (/= WayThreaded) (wayNames dflags))
+ && isInterpretiveMode cli_mode) $
do throwDyn (UsageError
- "--interactive can't be used with -prof, -ticky, -unreg or -smp.")
+ "--interactive can't be used with -prof, -ticky, or -unreg.")
-- -ohi sanity check
if (isJust (outputHi dflags) &&
(isCompManagerMode cli_mode || srcs `lengthExceeds` 1))
when (failed ok_flag) (exitWith (ExitFailure 1))
return ()
+
+-- ---------------------------------------------------------------------------
+-- --show-iface mode
+
+doShowIface :: DynFlags -> FilePath -> IO ()
+doShowIface dflags file = do
+ hsc_env <- newHscEnv dflags
+ showIface hsc_env file
+
-- ---------------------------------------------------------------------------
-- Various banners and verbosity output.