Commit cb342e53 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Merge pull request #255 from bgamari/ghc7.8

GHC 7.8: Fix sandbox support  and some debugging conveniences
parents 0e6dc7e5 bb5fa60a
#!/bin/sh -e
#!/bin/bash -e
# Called from Setup.hs.
function make_parser {
......
......@@ -77,9 +77,14 @@ import Data.Version (versionBranch)
data ErrorOccurred = Success | Failure deriving (Show, Eq)
-- | Enable debugging output
debug :: Bool
debug = False
-- | Set GHC's verbosity for debugging
ghcVerbosity :: Maybe Int
ghcVerbosity = Nothing -- Just 5
ignoreTypePrefixes :: [String]
ignoreTypePrefixes = ["GHC.Types", "GHC.Base", "GHC.Show", "System.IO",
"GHC.Float", ":Interactive", "GHC.Num", "GHC.IO",
......@@ -119,18 +124,13 @@ globalImports =
-- is handled specially, which cannot be done in a testing environment.
interpret :: Bool -> Interpreter a -> IO a
interpret allowedStdin action = runGhc (Just libdir) $ do
initGhci
-- If we're in a sandbox, add the relevant package database
dflags <- getSessionDynFlags
sandboxPackages <- liftIO getSandboxPackageConf
let pkgConfs = case sandboxPackages of
Nothing -> extraPkgConfs dflags
Just path ->
let pkg = PkgConfFile path in
(pkg:) . extraPkgConfs dflags
void $ setSessionDynFlags $ dflags { extraPkgConfs = pkgConfs }
initGhci sandboxPackages
case ghcVerbosity of
Just verb -> do dflags <- getSessionDynFlags
void $ setSessionDynFlags $ dflags { verbosity = verb }
Nothing -> return ()
initializeImports
......
......@@ -131,18 +131,28 @@ doc sdoc = do
-- @NoMonomorphismRestriction@), sets the target to interpreted, link in
-- memory, sets a reasonable output width, and potentially a few other
-- things. It should be invoked before other functions from this module.
initGhci :: GhcMonad m => m ()
initGhci = do
--
-- We also require that the sandbox PackageConf (if any) is passed here
-- as setSessionDynFlags will read the package database the first time
-- (and only the first time) it is called.
initGhci :: GhcMonad m => Maybe String -> m ()
initGhci sandboxPackages = do
-- Initialize dyn flags.
-- Start with -XExtendedDefaultRules and -XNoMonomorphismRestriction.
originalFlags <- getSessionDynFlags
let flag = flip xopt_set
unflag = flip xopt_unset
dflags = flag Opt_ExtendedDefaultRules . unflag Opt_MonomorphismRestriction $ originalFlags
pkgConfs = case sandboxPackages of
Nothing -> extraPkgConfs originalFlags
Just path ->
let pkg = PkgConfFile path in
(pkg:) . extraPkgConfs originalFlags
void $ setSessionDynFlags $ dflags { hscTarget = HscInterpreted,
ghcLink = LinkInMemory,
pprCols = 300 }
pprCols = 300,
extraPkgConfs = pkgConfs }
-- | Evaluate a single import statement.
-- If this import statement is importing a module which was previously
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment