From 92d649ad61a2c6f7326c1031e966816fb03be622 Mon Sep 17 00:00:00 2001 From: Nico Rieck Date: Wed, 11 Sep 2013 00:36:48 +0000 Subject: 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 --- llvm/lib/Support/Process.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'llvm/lib/Support/Process.cpp') diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp index 2c0d37bb329..d5168f03a6d 100644 --- a/llvm/lib/Support/Process.cpp +++ b/llvm/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" -- cgit v1.2.3