<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 18, 2015 at 9:39 AM, Eric Fiselier <span dir="ltr"><<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: ericwf<br>
Date: Wed Feb 18 11:39:45 2015<br>
New Revision: 229707<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=229707&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=229707&view=rev</a><br>
Log:<br>
[libcxx] Tired of colorless compile errors? Enable color diagnostics today!<br>
<br>
Summary:<br>
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.<br>
<br>
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`<br>
<br>
Does anybody have objections to this going in?<br>
<br>
Reviewers: jroelofs, danalbert<br>
<br>
Reviewed By: danalbert<br>
<br>
Subscribers: cfe-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D7729" target="_blank">http://reviews.llvm.org/D7729</a><br>
<br>
Modified:<br>
    libcxx/trunk/test/libcxx/test/config.py<br>
    libcxx/trunk/www/lit_usage.html<br>
<br>
Modified: libcxx/trunk/test/libcxx/test/config.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=229707&r1=229706&r2=229707&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=229707&r1=229706&r2=229707&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/test/libcxx/test/config.py (original)<br>
+++ libcxx/trunk/test/libcxx/test/config.py Wed Feb 18 11:39:45 2015<br>
@@ -91,6 +91,7 @@ class Configuration(object):<br>
         self.configure_env()<br>
         self.configure_compile_flags()<br>
         self.configure_link_flags()<br>
+        self.configure_color_diagnostics()<br>
         self.configure_debug_mode()<br>
         self.configure_warnings()<br>
         self.configure_sanitizer()<br>
@@ -469,6 +470,25 @@ class Configuration(object):<br>
         else:<br>
             self.lit_config.fatal("unrecognized system: %r" % target_platform)<br>
<br>
+    def configure_color_diagnostics(self):<br>
+        use_color = self.get_lit_conf('color_diagnostics')<br>
+        if use_color is None:<br>
+            use_color = os.environ.get('LIBCXX_COLOR_DIAGNOSTICS')<br>
+        if use_color is None:<br>
+            return<br>
+        if use_color != '':<br>
+            self.lit_config.fatal('Invalid value for color_diagnostics "%s".'<br>
+                                  % use_color)<br>
+        cxx_type = self.cxx.type<br>
+        if cxx_type is None:<br>
+            self.lit_config.warning(<br>
+                'Unable to force color output for unknown compiler "%s"'<br>
+                % cxx.path)<br>
+        elif cxx_type in ['clang', 'apple-clang']:<br>
+            self.cxx.flags += ['-fcolor-diagnostics']<br>
+        elif cxx_type == 'gcc':<br>
+            self.cxx.flags += ['-fdiagnostics-color=always']<br></blockquote><div><br></div><div>FYI, clang understands the gcc spelling too ( <a href="http://llvm.org/viewvc/llvm-project?view=revision&revision=179728">http://llvm.org/viewvc/llvm-project?view=revision&revision=179728</a> ), so maybe you can just unconditionally tack on -fdiagnostics-color=always.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+<br>
     def configure_debug_mode(self):<br>
         debug_level = self.get_lit_conf('debug_level', None)<br>
         if not debug_level:<br>
<br>
Modified: libcxx/trunk/www/lit_usage.html<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/lit_usage.html?rev=229707&r1=229706&r2=229707&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/lit_usage.html?rev=229707&r1=229706&r2=229707&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/www/lit_usage.html (original)<br>
+++ libcxx/trunk/www/lit_usage.html Wed Feb 18 11:39:45 2015<br>
@@ -192,6 +192,16 @@ was given when building libc++ then that<br>
 </blockquote><br>
 </p><br>
<br>
+<p><br>
+<h3 class="lit-option">color_diagnostics</h3><br>
+<blockquote class="lit-option-desc"><br>
+Enable the use of colorized compile diagnostics. If the<br>
+<code>color_diagnostics</code> option is specified or the enviroment variable<br>
+<code>LIBCXX_COLOR_DIAGNOSTICS</code> is present then color diagnostics will be<br>
+enabled.<br>
+</blockquote><br>
+</p><br>
+<br>
 </div><br>
 </body><br>
 </html><br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>