summaryrefslogtreecommitdiff
path: root/lib/Support/Process.cpp
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2013-09-11 00:36:48 +0000
committerNico Rieck <nico.rieck@gmail.com>2013-09-11 00:36:48 +0000
commit44a61bde15d456527156ee2080f0964344b939fe (patch)
treec62e30e826059e609c06769baf2982ca7ce8b757 /lib/Support/Process.cpp
parentf495a2679248bca1a426052b3a297326bb46e9db (diff)
downloadllvm-44a61bde15d456527156ee2080f0964344b939fe.tar.gz
llvm-44a61bde15d456527156ee2080f0964344b939fe.tar.bz2
llvm-44a61bde15d456527156ee2080f0964344b939fe.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190460 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Process.cpp')
-rw-r--r--lib/Support/Process.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp
index 2c0d37bb32..d5168f03a6 100644
--- a/lib/Support/Process.cpp
+++ b/lib/Support/Process.cpp
@@ -80,6 +80,24 @@ TimeValue self_process::get_wall_time() const {
#endif
+#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;") }
+};
+
// Include the platform-specific parts of this class.
#ifdef LLVM_ON_UNIX
#include "Unix/Process.inc"