[libcxx] r229707 - [libcxx] Tired of colorless compile errors? Enable color diagnostics today!

Nico Weber thakis at chromium.org
Wed Feb 18 18:56:21 PST 2015


On Wed, Feb 18, 2015 at 9:39 AM, Eric Fiselier <eric at efcs.ca> wrote:

> Author: ericwf
> Date: Wed Feb 18 11:39:45 2015
> New Revision: 229707
>
> URL: http://llvm.org/viewvc/llvm-project?rev=229707&view=rev
> Log:
> [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
>
> Modified:
>     libcxx/trunk/test/libcxx/test/config.py
>     libcxx/trunk/www/lit_usage.html
>
> Modified: libcxx/trunk/test/libcxx/test/config.py
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=229707&r1=229706&r2=229707&view=diff
>
> ==============================================================================
> --- libcxx/trunk/test/libcxx/test/config.py (original)
> +++ libcxx/trunk/test/libcxx/test/config.py Wed Feb 18 11:39:45 2015
> @@ -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']
>

FYI, clang understands the gcc spelling too (
http://llvm.org/viewvc/llvm-project?view=revision&revision=179728 ), so
maybe you can just unconditionally tack on -fdiagnostics-color=always.


> +
>      def configure_debug_mode(self):
>          debug_level = self.get_lit_conf('debug_level', None)
>          if not debug_level:
>
> Modified: libcxx/trunk/www/lit_usage.html
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/lit_usage.html?rev=229707&r1=229706&r2=229707&view=diff
>
> ==============================================================================
> --- libcxx/trunk/www/lit_usage.html (original)
> +++ libcxx/trunk/www/lit_usage.html Wed Feb 18 11:39:45 2015
> @@ -192,6 +192,16 @@ was given when building libc++ then that
>  </blockquote>
>  </p>
>
> +<p>
> +<h3 class="lit-option">color_diagnostics</h3>
> +<blockquote class="lit-option-desc">
> +Enable the use of colorized compile diagnostics. If the
> +<code>color_diagnostics</code> option is specified or the enviroment
> variable
> +<code>LIBCXX_COLOR_DIAGNOSTICS</code> is present then color diagnostics
> will be
> +enabled.
> +</blockquote>
> +</p>
> +
>  </div>
>  </body>
>  </html>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150218/9635f79a/attachment.html>


More information about the cfe-commits mailing list