Commit 473f76a4 authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Merge pull request #1440 from 23Skidoo/ghc-info-ignore-ghc-options

Ignore 'ghc-options' when parsing 'ghc --info' output.
parents 85cb83d7 d9283d29
......@@ -101,8 +101,8 @@ import Distribution.Simple.Program
, ProgramLocation(..), ProgramSearchPath, ProgramSearchPathEntry(..)
, rawSystemProgram
, rawSystemProgramStdout, rawSystemProgramStdoutConf
, getProgramInvocationOutput
, requireProgramVersion, requireProgram, getProgramOutput
, getProgramOutput, getProgramInvocationOutput, suppressOverrideArgs
, requireProgramVersion, requireProgram
, userMaybeSpecifyPath, programPath, lookupProgram, addKnownProgram
, ghcProgram, ghcPkgProgram, hsc2hsProgram
, arProgram, ranlibProgram, ldProgram
......@@ -142,20 +142,6 @@ import System.Environment (getEnv)
import Distribution.Compat.Exception (catchExit, catchIO)
import Distribution.System (Platform, platformFromTriple)
getGhcInfo :: Verbosity -> ConfiguredProgram -> IO [(String, String)]
getGhcInfo verbosity ghcProg =
case programVersion ghcProg of
Just ghcVersion
| ghcVersion >= Version [6,7] [] ->
do xs <- getProgramOutput verbosity ghcProg ["--info"]
case reads xs of
[(i, ss)]
| all isSpace ss ->
return i
_ ->
die "Can't parse --info output of GHC"
_ ->
return []
-- -----------------------------------------------------------------------------
-- Configuring
......@@ -401,11 +387,27 @@ getLanguages _ ghcProg
where
Just ghcVersion = programVersion ghcProg
getGhcInfo :: Verbosity -> ConfiguredProgram -> IO [(String, String)]
getGhcInfo verbosity ghcProg =
case programVersion ghcProg of
Just ghcVersion
| ghcVersion >= Version [6,7] [] ->
do xs <- getProgramOutput verbosity (suppressOverrideArgs ghcProg)
["--info"]
case reads xs of
[(i, ss)]
| all isSpace ss ->
return i
_ ->
die "Can't parse --info output of GHC"
_ ->
return []
getExtensions :: Verbosity -> ConfiguredProgram -> IO [(Extension, Flag)]
getExtensions verbosity ghcProg
| ghcVersion >= Version [6,7] [] = do
str <- rawSystemStdout verbosity (programPath ghcProg)
str <- getProgramOutput verbosity (suppressOverrideArgs ghcProg)
["--supported-languages"]
let extStrs = if ghcVersion >= Version [7] []
then lines str
......
......@@ -48,6 +48,7 @@ module Distribution.Simple.Program (
, ProgramLocation(..)
, runProgram
, getProgramOutput
, suppressOverrideArgs
-- * Program invocations
, ProgramInvocation(..)
......
......@@ -24,6 +24,7 @@ module Distribution.Simple.Program.Types (
-- * Configured program and related functions
ConfiguredProgram(..),
programPath,
suppressOverrideArgs,
ProgArg,
ProgramLocation(..),
simpleConfiguredProgram,
......@@ -52,7 +53,8 @@ data Program = Program {
--
-- It is supplied with the prevailing search path which will typically
-- just be used as-is, but can be extended or ignored as needed.
programFindLocation :: Verbosity -> ProgramSearchPath -> IO (Maybe FilePath),
programFindLocation :: Verbosity -> ProgramSearchPath
-> IO (Maybe FilePath),
-- | Try to find the version of the program. For many programs this is
-- not possible or is not necessary so it's ok to return Nothing.
......@@ -112,6 +114,10 @@ data ProgramLocation
programPath :: ConfiguredProgram -> FilePath
programPath = locationPath . programLocation
-- | Suppress any extra arguments added by the user.
suppressOverrideArgs :: ConfiguredProgram -> ConfiguredProgram
suppressOverrideArgs prog = prog { programOverrideArgs = [] }
-- | Make a simple named program.
--
-- By default we'll just search for it in the path and not try to find the
......
Supports Markdown
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