-- DLL building
doMkDLL,
- matchOptions, -- used in module GHC
+ getOptionsFromStringBuffer, -- used in module GHC
) where
#include "HsVersions.h"
import BasicTypes ( SuccessFlag(..) )
import Maybes ( expectJust )
import Ctype ( is_ident )
-
-import ParserCoreUtils ( getCoreModuleName )
+import StringBuffer ( StringBuffer(..), lexemeToString )
+import ParserCoreUtils ( getCoreModuleName )
import EXCEPTION
import DATA_IOREF ( readIORef, writeIORef, IORef )
+import GLAEXTS ( Int(..) )
import Directory
import System
let input_fn = expectJust "compile:hs" (ml_hs_file location)
let input_fnpp = expectJust "compile:hspp" (ms_hspp_file mod_summary)
- when (verb >= 2) (hPutStrLn stderr ("compile: input file " ++ input_fnpp))
+ when (verb >= 2) (putMsg ("compile: input file " ++ input_fnpp))
-- Add in the OPTIONS from the source file
-- This is nasty: we've done this once already, in the compilation manager
-- It might be better to cache the flags in the ml_hspp_file field,say
- opts <- getOptionsFromSource input_fnpp
+ let hspp_buf = expectJust "compile:hspp_buf" (ms_hspp_buf mod_summary)
+ opts = getOptionsFromStringBuffer hspp_buf
(dflags1,unhandled_flags) <- parseDynamicFlags dflags0 opts
checkProcessArgsResult unhandled_flags input_fn
return Succeeded
#endif
+link JustTypecheck dflags batch_attempt_linking hpt
+ = return Succeeded
+
link BatchCompile dflags batch_attempt_linking hpt
| batch_attempt_linking
= do
return (opts ++ rest)
| otherwise -> return []
+getOptionsFromStringBuffer :: StringBuffer -> [String]
+getOptionsFromStringBuffer buffer@(StringBuffer _ len# _) =
+ let
+ ls = lines (lexemeToString buffer (I# len#)) -- lazy, so it's ok
+ in
+ look ls
+ where
+ look [] = []
+ look (l':ls) = do
+ let l = removeSpaces l'
+ case () of
+ () | null l -> look ls
+ | prefixMatch "#" l -> look ls
+ | prefixMatch "{-# LINE" l -> look ls -- -}
+ | Just opts <- matchOptions l
+ -> opts ++ look ls
+ | otherwise -> []
+
-- detect {-# OPTIONS_GHC ... #-}. For the time being, we accept OPTIONS
-- instead of OPTIONS_GHC, but that is deprecated.
matchOptions s
import FiniteMap
import Panic
import Digraph
-import ErrUtils ( showPass, Messages )
+import ErrUtils ( showPass, Messages, putMsg )
import qualified ErrUtils
import Util
-import StringBuffer ( StringBuffer(..), hGetStringBuffer, lexemeToString )
+import StringBuffer ( StringBuffer, hGetStringBuffer )
import Outputable
import SysTools ( cleanTempFilesExcept )
import BasicTypes ( SuccessFlag(..), succeeded, failed )
import System ( exitWith, ExitCode(..) )
import Time ( ClockTime )
import EXCEPTION as Exception hiding (handle)
-import GLAEXTS ( Int(..) )
import DATA_IOREF
import IO
import Prelude hiding (init)
then
-- Easy; just relink it all.
- do when (verb >= 2) $
- hPutStrLn stderr "Upsweep completely successful."
+ do when (verb >= 2) $ putMsg "Upsweep completely successful."
-- Clean up after ourselves
cleanTempFilesExcept dflags (ppFilesFromSummaries modsDone)
when (ghci_mode == BatchCompile && isJust ofile && not do_linking
&& verb > 0) $
- hPutStrLn stderr ("Warning: output was redirected with -o, " ++
+ putMsg ("Warning: output was redirected with -o, " ++
"but no output will be generated\n" ++
"because there is no " ++ main_mod ++ " module.")
-- Tricky. We need to back out the effects of compiling any
-- half-done cycles, both so as to clean up the top level envs
-- and to avoid telling the interactive linker to link them.
- do when (verb >= 2) $
- hPutStrLn stderr "Upsweep partially successful."
+ do when (verb >= 2) $ putMsg "Upsweep partially successful."
let modsDone_names
= map ms_mod modsDone
unload :: HscEnv -> [Linkable] -> IO ()
unload hsc_env stable_linkables -- Unload everthing *except* 'stable_linkables'
= case ghcMode (hsc_dflags hsc_env) of
- BatchCompile -> return ()
+ BatchCompile -> return ()
+ JustTypecheck -> return ()
#ifdef GHCI
Interactive -> Linker.unload (hsc_dflags hsc_env) stable_linkables
#else
return (dflags', "<buffer>", buf)
--- code adapted from the file-based version in DriverUtil
-getOptionsFromStringBuffer :: StringBuffer -> [String]
-getOptionsFromStringBuffer buffer@(StringBuffer _ len# _) =
- let
- ls = lines (lexemeToString buffer (I# len#)) -- lazy, so it's ok
- in
- look ls
- where
- look [] = []
- look (l':ls) = do
- let l = removeSpaces l'
- case () of
- () | null l -> look ls
- | prefixMatch "#" l -> look ls
- | prefixMatch "{-# LINE" l -> look ls -- -}
- | Just opts <- matchOptions l
- -> opts ++ look ls
- | otherwise -> []
-
-----------------------------------------------------------------------------
-- Error messages
-----------------------------------------------------------------------------
import DriverPhases ( isHaskellUserSrcFilename )
import Config
import Outputable
+import ErrUtils ( putMsg )
import Panic ( GhcException(..) )
import Util ( Suffix, global, notNull, consIORef,
normalisePath, pgmPath, platformPath )
-- b) don't do it at all if dry-run is set
traceCmd dflags phase_name cmd_line action
= do { let verb = verbosity dflags
- ; when (verb >= 2) $ hPutStrLn stderr ("*** " ++ phase_name)
- ; when (verb >= 3) $ hPutStrLn stderr cmd_line
+ ; when (verb >= 2) $ putMsg ("*** " ++ phase_name)
+ ; when (verb >= 3) $ putMsg cmd_line
; hFlush stderr
-- Test for -n flag