Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,310
Issues
4,310
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
382
Merge Requests
382
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
fdc35b18
Commit
fdc35b18
authored
Dec 16, 2017
by
patrickdoc
Committed by
Andrey Mokhov
Dec 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken colours with `-j` (
#484
)
* Fix colours * Simplify data types * Fix doc typo
parent
7d2368d7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
27 deletions
+85
-27
README.md
README.md
+1
-1
circle.yml
circle.yml
+1
-1
doc/user-settings.md
doc/user-settings.md
+13
-2
hadrian.cabal
hadrian.cabal
+0
-1
src/Hadrian/Utilities.hs
src/Hadrian/Utilities.hs
+68
-19
src/UserSettings.hs
src/UserSettings.hs
+2
-3
No files found.
README.md
View file @
fdc35b18
...
...
@@ -43,7 +43,7 @@ on Cabal sandboxes (`build.cabal.*`), Stack (`build.stack.*`) or the global pack
(
`build.global-db.*`
). Also see
[
instructions for building GHC on Windows using Stack
][
windows-build
]
.
*
Hadrian is written in Haskell and depends on
`shake`
(plus a few packages that
`shake`
depends on),
`
ansi-terminal`
,
`
mtl`
,
`quickcheck`
, and GHC core libraries.
`mtl`
,
`quickcheck`
, and GHC core libraries.
*
If you have never built GHC before, start with the
[
preparation guide
][
ghc-preparation
]
.
...
...
circle.yml
View file @
fdc35b18
...
...
@@ -9,7 +9,7 @@ dependencies:
-
brew update
-
brew install ghc cabal-install python3
-
cabal update
-
cabal install alex happy
ansi-terminal
mtl shake quickcheck
-
cabal install alex happy mtl shake quickcheck
cache_directories
:
-
$HOME/.cabal
-
$HOME/.ghc
...
...
doc/user-settings.md
View file @
fdc35b18
...
...
@@ -204,9 +204,20 @@ used by default by overriding `buildProgressColour` and `successColour`:
```
haskell
-- | Set colour for build progress messages (e.g. executing a build command).
buildProgressColour
::
BuildProgressColour
buildProgressColour
=
BuildProgressColour
(
Dull
,
Magenta
)
buildProgressColour
=
mkBuildProgressColour
(
Dull
Magenta
)
-- | Set colour for success messages (e.g. a package is built successfully).
successColour
::
SuccessColour
successColour
=
SuccessColour
(
Dull
,
Green
)
successColour
=
mkSuccessColour
(
Dull
Green
)
```
Your options are
`Dull Colour`
,
`Vivid Colour`
, or
`Extended Code`
.
`Dull`
colours are the ANSI 8-bit colours,
`Vivid`
correspond to the 16-bit codes that
end with ";1", and
`Extended`
let's you enter a manual code for the 256 colour
set. E.g.
```
Dull Blue
Vivid Cyan
Extended "203"
```
hadrian.cabal
View file @
fdc35b18
...
...
@@ -117,7 +117,6 @@ executable hadrian
other-extensions: MultiParamTypeClasses
, TypeFamilies
build-depends: base >= 4.8 && < 5
, ansi-terminal == 0.6.*
, Cabal >= 2.0.0.2 && < 2.2
, containers == 0.5.*
, directory >= 1.2 && < 1.4
...
...
src/Hadrian/Utilities.hs
View file @
fdc35b18
...
...
@@ -20,10 +20,12 @@ module Hadrian.Utilities (
createDirectory
,
copyDirectory
,
moveDirectory
,
removeDirectory
,
-- * Diagnostic info
UseColour
(
..
),
putColoured
,
BuildProgressColour
(
..
),
putBuild
,
SuccessColour
(
..
),
putSuccess
,
ProgressInfo
(
..
),
putProgressInfo
,
renderAction
,
renderProgram
,
renderLibrary
,
renderBox
,
renderUnicorn
,
UseColour
(
..
),
Colour
(
..
),
ANSIColour
(
..
),
putColoured
,
BuildProgressColour
,
mkBuildProgressColour
,
putBuild
,
SuccessColour
,
mkSuccessColour
,
putSuccess
,
ProgressInfo
(
..
),
putProgressInfo
,
renderAction
,
renderProgram
,
renderLibrary
,
renderBox
,
renderUnicorn
,
-- * Miscellaneous
(
<&>
),
(
%%>
),
cmdLineLengthLimit
,
...
...
@@ -42,7 +44,7 @@ import Data.Typeable (TypeRep, typeOf)
import
Development.Shake
hiding
(
Normal
)
import
Development.Shake.Classes
import
Development.Shake.FilePath
import
System.
Console.ANSI
import
System.
Environment
(
lookupEnv
)
import
System.Info.Extra
import
qualified
Control.Exception.Base
as
IO
...
...
@@ -264,43 +266,90 @@ removeDirectory dir = do
data
UseColour
=
Never
|
Auto
|
Always
deriving
(
Eq
,
Show
,
Typeable
)
-- | Terminal output colours
data
Colour
=
Dull
ANSIColour
-- ^ 8-bit ANSI colours
|
Vivid
ANSIColour
-- ^ 16-bit vivid ANSI colours
|
Extended
String
-- ^ Extended 256-bit colours, manual code stored
-- | ANSI terminal colours
data
ANSIColour
=
Black
-- ^ ANSI code: 30
|
Red
-- ^ 31
|
Green
-- ^ 32
|
Yellow
-- ^ 33
|
Blue
-- ^ 34
|
Magenta
-- ^ 35
|
Cyan
-- ^ 36
|
White
-- ^ 37
|
Reset
-- ^ 0
-- | Convert ANSI colour names into their associated codes
colourCode
::
ANSIColour
->
String
colourCode
Black
=
"30"
colourCode
Red
=
"31"
colourCode
Green
=
"32"
colourCode
Yellow
=
"33"
colourCode
Blue
=
"34"
colourCode
Magenta
=
"35"
colourCode
Cyan
=
"36"
colourCode
White
=
"37"
colourCode
Reset
=
"0"
-- | Create the final ANSI code.
mkColour
::
Colour
->
String
mkColour
(
Dull
c
)
=
colourCode
c
mkColour
(
Vivid
c
)
=
colourCode
c
++
";1"
mkColour
(
Extended
code
)
=
"38;5;"
++
code
-- | A more colourful version of Shake's 'putNormal'.
putColoured
::
ColorIntensity
->
Color
->
String
->
Action
()
putColoured
intensity
colour
msg
=
do
putColoured
::
String
->
String
->
Action
()
putColoured
code
msg
=
do
useColour
<-
userSetting
Never
supported
<-
liftIO
$
hSupportsANSI
IO
.
stdout
supported
<-
liftIO
$
(
&&
)
<$>
IO
.
hIsTerminalDevice
IO
.
stdout
<*>
(
not
<$>
isDumb
)
let
c
Never
=
False
c
Auto
=
supported
||
IO
.
isWindows
-- Colours do work on Windows
c
Always
=
True
when
(
c
useColour
)
.
liftIO
$
setSGR
[
SetColor
Foreground
intensity
colour
]
putNormal
msg
when
(
c
useColour
)
.
liftIO
$
setSGR
[]
>>
IO
.
hFlush
IO
.
stdout
if
c
useColour
then
putNormal
$
"
\ESC
["
++
code
++
"m"
++
msg
++
"
\ESC
[0m"
else
putNormal
msg
where
isDumb
=
maybe
False
(
==
"dumb"
)
<$>
lookupEnv
"TERM"
newtype
BuildProgressColour
=
BuildProgressColour
(
ColorIntensity
,
Color
)
newtype
BuildProgressColour
=
BuildProgressColour
String
deriving
Typeable
-- | Generate an encoded colour for progress output from names.
mkBuildProgressColour
::
Colour
->
BuildProgressColour
mkBuildProgressColour
c
=
BuildProgressColour
$
mkColour
c
-- | Default 'BuildProgressColour'.
magenta
::
BuildProgressColour
magenta
=
BuildProgressColour
(
Dull
,
Magenta
)
magenta
=
mkBuildProgressColour
(
Dull
Magenta
)
-- | Print a build progress message (e.g. executing a build command).
putBuild
::
String
->
Action
()
putBuild
msg
=
do
BuildProgressColour
(
intensity
,
colour
)
<-
userSetting
magenta
putColoured
intensity
colour
msg
BuildProgressColour
code
<-
userSetting
magenta
putColoured
code
msg
newtype
SuccessColour
=
SuccessColour
(
ColorIntensity
,
Color
)
newtype
SuccessColour
=
SuccessColour
String
deriving
Typeable
-- | Generate an encoded colour for successful output from names
mkSuccessColour
::
Colour
->
SuccessColour
mkSuccessColour
c
=
SuccessColour
$
mkColour
c
-- | Default 'SuccessColour'.
green
::
SuccessColour
green
=
SuccessColour
(
Dull
,
Green
)
green
=
mkSuccessColour
(
Dull
Green
)
-- | Print a success message (e.g. a package is built successfully).
putSuccess
::
String
->
Action
()
putSuccess
msg
=
do
SuccessColour
(
intensity
,
colour
)
<-
userSetting
green
putColoured
intensity
colour
msg
SuccessColour
code
<-
userSetting
green
putColoured
code
msg
data
ProgressInfo
=
None
|
Brief
|
Normal
|
Unicorn
deriving
(
Eq
,
Show
,
Typeable
)
...
...
src/UserSettings.hs
View file @
fdc35b18
...
...
@@ -8,7 +8,6 @@ module UserSettings (
)
where
import
Hadrian.Utilities
import
System.Console.ANSI
import
Flavour
import
Expression
...
...
@@ -46,11 +45,11 @@ verboseCommand = do
-- | Set colour for build progress messages (e.g. executing a build command).
buildProgressColour
::
BuildProgressColour
buildProgressColour
=
BuildProgressColour
(
Dull
,
Magenta
)
buildProgressColour
=
mkBuildProgressColour
(
Dull
Magenta
)
-- | Set colour for success messages (e.g. a package is built successfully).
successColour
::
SuccessColour
successColour
=
SuccessColour
(
Dull
,
Green
)
successColour
=
mkSuccessColour
(
Dull
Green
)
-- TODO: Set this flag from the command line.
-- | Set this flag to 'True' to disable building Stage2 GHC (i.e. the @ghc-stage2@
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment