the first step to make ghc-mod independent from GHC's version.
This commit is contained in:
parent
16e050439d
commit
dd7b7b8305
@ -18,7 +18,6 @@ import Distribution.PackageDescription (PackageDescription)
|
||||
import DynFlags
|
||||
import Exception
|
||||
import GHC
|
||||
import GHC.Paths (libdir)
|
||||
import Language.Haskell.GhcMod.CabalApi
|
||||
import Language.Haskell.GhcMod.ErrMsg
|
||||
import Language.Haskell.GhcMod.GHCChoice
|
||||
@ -26,6 +25,16 @@ import qualified Language.Haskell.GhcMod.Gap as Gap
|
||||
import Language.Haskell.GhcMod.Types
|
||||
import System.Exit
|
||||
import System.IO
|
||||
import System.Process
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
getSystemLibDir :: IO (Maybe FilePath)
|
||||
getSystemLibDir = do
|
||||
res <- readProcess "ghc" ["--print-libdir"] []
|
||||
return $ case res of
|
||||
"" -> Nothing
|
||||
dirn -> Just (init dirn)
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -38,7 +47,9 @@ withGHCDummyFile = withGHC "Dummy"
|
||||
withGHC :: Alternative m => FilePath -- ^ A target file displayed in an error message.
|
||||
-> Ghc (m a) -- ^ 'Ghc' actions created by the Ghc utilities.
|
||||
-> IO (m a)
|
||||
withGHC file body = ghandle ignore $ runGhc (Just libdir) $ do
|
||||
withGHC file body = do
|
||||
mlibdir <- getSystemLibDir
|
||||
ghandle ignore $ runGhc mlibdir $ do
|
||||
dflags <- getSessionDynFlags
|
||||
defaultCleanupHandler dflags body
|
||||
where
|
||||
@ -150,4 +161,6 @@ setTargetFiles files = do
|
||||
|
||||
-- | Return the 'DynFlags' currently in use in the GHC session.
|
||||
getDynamicFlags :: IO DynFlags
|
||||
getDynamicFlags = runGhc (Just libdir) getSessionDynFlags
|
||||
getDynamicFlags = do
|
||||
mlibdir <- getSystemLibDir
|
||||
runGhc mlibdir getSessionDynFlags
|
||||
|
@ -66,7 +66,6 @@ Library
|
||||
, directory
|
||||
, filepath
|
||||
, ghc
|
||||
, ghc-paths
|
||||
, ghc-syb-utils
|
||||
, hlint >= 1.8.58
|
||||
, io-choice
|
||||
@ -121,7 +120,6 @@ Test-Suite spec
|
||||
, directory
|
||||
, filepath
|
||||
, ghc
|
||||
, ghc-paths
|
||||
, ghc-syb-utils
|
||||
, hlint >= 1.7.1
|
||||
, io-choice
|
||||
|
Loading…
Reference in New Issue
Block a user