From da52c55fc35dc2fc81fa9da5e9dc96dd352186ab Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 18 Feb 2015 17:39:45 +0000 Subject: [libcxx] Tired of colorless compile errors? Enable color diagnostics today! Summary: This patch adds a lit option to enable color diagnostics when either `--param=color_diagnostics` is passed to LIT or `LIBCXX_COLOR_DIAGNOSTICS` is present in the environment. My only concern with this patch is that GCC and Clang take different flags and that only GCC 4.9 and greater support `-fdiagnostics-color=always` Does anybody have objections to this going in? Reviewers: jroelofs, danalbert Reviewed By: danalbert Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7729 llvm-svn: 229707 --- libcxx/test/libcxx/test/config.py | 20 ++++++++++++++++++++ libcxx/www/lit_usage.html | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py index 5633d3d056f..f2435b7d6ff 100644 --- a/libcxx/test/libcxx/test/config.py +++ b/libcxx/test/libcxx/test/config.py @@ -91,6 +91,7 @@ class Configuration(object): self.configure_env() self.configure_compile_flags() self.configure_link_flags() + self.configure_color_diagnostics() self.configure_debug_mode() self.configure_warnings() self.configure_sanitizer() @@ -469,6 +470,25 @@ class Configuration(object): else: self.lit_config.fatal("unrecognized system: %r" % target_platform) + def configure_color_diagnostics(self): + use_color = self.get_lit_conf('color_diagnostics') + if use_color is None: + use_color = os.environ.get('LIBCXX_COLOR_DIAGNOSTICS') + if use_color is None: + return + if use_color != '': + self.lit_config.fatal('Invalid value for color_diagnostics "%s".' + % use_color) + cxx_type = self.cxx.type + if cxx_type is None: + self.lit_config.warning( + 'Unable to force color output for unknown compiler "%s"' + % cxx.path) + elif cxx_type in ['clang', 'apple-clang']: + self.cxx.flags += ['-fcolor-diagnostics'] + elif cxx_type == 'gcc': + self.cxx.flags += ['-fdiagnostics-color=always'] + def configure_debug_mode(self): debug_level = self.get_lit_conf('debug_level', None) if not debug_level: diff --git a/libcxx/www/lit_usage.html b/libcxx/www/lit_usage.html index 77179f21f60..c6bfbae357d 100644 --- a/libcxx/www/lit_usage.html +++ b/libcxx/www/lit_usage.html @@ -192,6 +192,16 @@ was given when building libc++ then that sanitizer will be used by default.

+

+

color_diagnostics

+
+Enable the use of colorized compile diagnostics. If the +color_diagnostics option is specified or the enviroment variable +LIBCXX_COLOR_DIAGNOSTICS is present then color diagnostics will be +enabled. +
+

+ -- cgit v1.2.3