Commit 32ab07bf authored by Bodigrim's avatar Bodigrim Committed by Marge Bot
Browse files

ghc package does not have to depend on terminfo

parent eb5a6b91
......@@ -48,7 +48,7 @@ packages: ./compiler
./utils/iserv
./linters/**/*.cabal
constraints: ghc +internal-interpreter +dynamic-system-linke +terminfo,
constraints: ghc +internal-interpreter +dynamic-system-linke,
ghc-bin +internal-interpreter +threaded,
ghci +internal-interpreter,
haddock +in-ghc-tree,
......
......@@ -4,16 +4,11 @@ module GHC.SysTools.Terminal (stderrSupportsAnsiColors) where
import GHC.Prelude
#if defined(MIN_VERSION_terminfo)
import GHC.IO (catchException)
import Data.Maybe (fromMaybe)
import System.Console.Terminfo (SetupTermError, Terminal, getCapability,
setupTermFromEnv, termColors)
import System.Posix (queryTerminal, stdError)
#elif defined(mingw32_HOST_OS)
#if !defined(mingw32_HOST_OS)
import System.IO (hIsTerminalDevice, stderr)
#else
import GHC.IO (catchException)
import GHC.Utils.Exception (try)
-- import Data.Bits ((.|.), (.&.))
import Foreign (Ptr, peek, with)
import qualified Graphics.Win32 as Win32
import qualified System.Win32 as Win32
......@@ -40,18 +35,10 @@ stderrSupportsAnsiColors = unsafePerformIO stderrSupportsAnsiColors'
-- | Check if ANSI escape sequences can be used to control color in stderr.
stderrSupportsAnsiColors' :: IO Bool
stderrSupportsAnsiColors' = do
#if defined(MIN_VERSION_terminfo)
stderr_available <- queryTerminal stdError
if stderr_available then
fmap termSupportsColors setupTermFromEnv
`catchException` \ (_ :: SetupTermError) -> pure False
else
pure False
where
termSupportsColors :: Terminal -> Bool
termSupportsColors term = fromMaybe 0 (getCapability term termColors) > 0
#elif defined(mingw32_HOST_OS)
#if !defined(mingw32_HOST_OS)
-- Coloured text is a part of ANSI standard, no reason to query terminfo
hIsTerminalDevice stderr
#else
h <- Win32.getStdHandle Win32.sTD_ERROR_HANDLE
`catchException` \ (_ :: IOError) ->
pure Win32.nullHANDLE
......@@ -100,6 +87,4 @@ foreign import WINAPI unsafe "windows.h GetConsoleMode" c_GetConsoleMode
foreign import WINAPI unsafe "windows.h SetConsoleMode" c_SetConsoleMode
:: Win32.HANDLE -> Win32.DWORD -> IO Win32.BOOL
#else
pure False
#endif
......@@ -46,11 +46,6 @@ Flag internal-interpreter
Default: False
Manual: True
Flag terminfo
Description: Build GHC with terminfo support on non-Windows platforms.
Default: True
Manual: True
Flag dynamic-system-linker
Description: The system can load dynamic code. This is not the case for musl.
Default: True
......@@ -98,8 +93,6 @@ Library
if os(windows)
Build-Depends: Win32 >= 2.3 && < 2.14
else
if flag(terminfo)
Build-Depends: terminfo == 0.4.*
Build-Depends: unix >= 2.7 && < 2.9
GHC-Options: -Wall
......
......@@ -172,7 +172,7 @@ toolTargets = [ binary
, text
, transformers
, unlit -- # executable
] ++ if windowsHost then [ win32 ] else [ terminfo, unix ]
] ++ if windowsHost then [ win32 ] else [ unix ]
-- | Create a mapping from files to which component it belongs to.
dirMap :: Action [(FilePath, (Package, [String]))]
......
......@@ -89,7 +89,6 @@ packageArgs = do
, builder (Cabal Flags) ? mconcat
[ andM [expr ghcWithInterpreter, notStage0] `cabalFlag` "internal-interpreter"
, notM cross `cabalFlag` "terminfo"
, ifM stage0
-- We build a threaded stage 1 if the bootstrapping compiler
-- supports it.
......
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