diff options
| author | Nico Rieck <nico.rieck@gmail.com> | 2013-09-11 00:36:48 +0000 |
|---|---|---|
| committer | Nico Rieck <nico.rieck@gmail.com> | 2013-09-11 00:36:48 +0000 |
| commit | 92d649ad61a2c6f7326c1031e966816fb03be622 (patch) | |
| tree | 7fb891790fba9648f06fd6a2c0b21d6e8be6fecd /llvm/lib/Support/Unix | |
| parent | 1e4e6fb892e28ef1f719cdb8a1c20ef3044d830e (diff) | |
| download | bcm5719-llvm-92d649ad61a2c6f7326c1031e966816fb03be622.tar.gz bcm5719-llvm-92d649ad61a2c6f7326c1031e966816fb03be622.zip | |
Support ANSI escape code on Windows
In some cases (e.g. when a build system pipes stderr) the Windows console
API cannot be used to color output. For these, provide a way to switch to
ANSI escape codes. This is required for Clang's -fansi-escape-codes option.
llvm-svn: 190460
Diffstat (limited to 'llvm/lib/Support/Unix')
| -rw-r--r-- | llvm/lib/Support/Unix/Process.inc | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc index 7d8f6250136..f18fa221036 100644 --- a/llvm/lib/Support/Unix/Process.inc +++ b/llvm/lib/Support/Unix/Process.inc @@ -310,29 +310,15 @@ bool Process::StandardErrHasColors() { return FileDescriptorHasColors(STDERR_FILENO); } +void Process::UseANSIEscapeCodes(bool /*enable*/) { + // No effect. +} + bool Process::ColorNeedsFlush() { // No, we use ANSI escape sequences. return false; } -#define COLOR(FGBG, CODE, BOLD) "\033[0;" BOLD FGBG CODE "m" - -#define ALLCOLORS(FGBG,BOLD) {\ - COLOR(FGBG, "0", BOLD),\ - COLOR(FGBG, "1", BOLD),\ - COLOR(FGBG, "2", BOLD),\ - COLOR(FGBG, "3", BOLD),\ - COLOR(FGBG, "4", BOLD),\ - COLOR(FGBG, "5", BOLD),\ - COLOR(FGBG, "6", BOLD),\ - COLOR(FGBG, "7", BOLD)\ - } - -static const char colorcodes[2][2][8][10] = { - { ALLCOLORS("3",""), ALLCOLORS("3","1;") }, - { ALLCOLORS("4",""), ALLCOLORS("4","1;") } -}; - const char *Process::OutputColor(char code, bool bold, bool bg) { return colorcodes[bg?1:0][bold?1:0][code&7]; } |

