aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-07-03 02:29:50 +0300
committerGitHub <noreply@github.com>2016-07-03 02:29:50 +0300
commitd6ab5027feac5e3c784e9a6577cbe790c9082643 (patch)
treef94b8e1b0f40ac7cd8dcd4596c7811d1428f9d76 /mesonbuild/compilers.py
parentc0057da133d212dd4e0efeab84e2a34f814c5c83 (diff)
parenta0666ebf9c4e193f176fa1aeafbcbf13445b51f4 (diff)
downloadmeson-d6ab5027feac5e3c784e9a6577cbe790c9082643.zip
meson-d6ab5027feac5e3c784e9a6577cbe790c9082643.tar.gz
meson-d6ab5027feac5e3c784e9a6577cbe790c9082643.tar.bz2
Merge pull request #623 from mesonbuild/colorout
Enable colored output with GCC.
Diffstat (limited to 'mesonbuild/compilers.py')
-rw-r--r--mesonbuild/compilers.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py
index 5d94182..8ee86bc 100644
--- a/mesonbuild/compilers.py
+++ b/mesonbuild/compilers.py
@@ -129,6 +129,10 @@ msvc_winlibs = ['kernel32.lib', 'user32.lib', 'gdi32.lib',
'winspool.lib', 'shell32.lib', 'ole32.lib', 'oleaut32.lib',
'uuid.lib', 'comdlg32.lib', 'advapi32.lib']
+gnu_color_args = {'auto' : ['-fdiagnostics-color=auto'],
+ 'always': ['-fdiagnostics-color=always'],
+ 'never' : ['-fdiagnostics-color=never'],
+ }
base_options = {
'b_pch': coredata.UserBooleanOption('b_pch', 'Use precompiled headers', True),
@@ -144,6 +148,9 @@ base_options = {
'b_coverage': coredata.UserBooleanOption('b_coverage',
'Enable coverage tracking.',
False),
+ 'b_colorout' : coredata.UserComboOption('b_colorout', 'Use colored output',
+ ['auto', 'always', 'never'],
+ 'always'),
}
def sanitizer_compile_args(value):
@@ -169,6 +176,10 @@ def get_base_compile_args(options, compiler):
except KeyError:
pass
try:
+ args += compiler.get_colorout_args(options['b_colorout'].value)
+ except KeyError:
+ pass
+ try:
args += sanitizer_compile_args(options['b_sanitize'].value)
except KeyError:
pass
@@ -325,6 +336,9 @@ class Compiler():
extra_flags += environment.cross_info.config['properties'].get(lang_link_args_key, [])
return extra_flags
+ def get_colorout_args(self, colortype):
+ return []
+
class CCompiler(Compiler):
def __init__(self, exelist, version, is_cross, exe_wrapper=None):
super().__init__(exelist, version)
@@ -1624,10 +1638,16 @@ class GnuCCompiler(CCompiler):
self.warn_args = {'1': ['-Wall', '-Winvalid-pch'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch'],
'3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']}
- self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
+ self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
+ 'b_colorout']
if self.gcc_type != GCC_OSX:
self.base_options.append('b_lundef')
+ def get_colorout_args(self, colortype):
+ if mesonlib.version_compare(self.version, '>=4.9.0'):
+ return gnu_color_args[colortype][:]
+ return []
+
def get_pic_args(self):
if self.gcc_type == GCC_MINGW:
return [] # On Window gcc defaults to fpic being always on.
@@ -1807,10 +1827,16 @@ class GnuCPPCompiler(CPPCompiler):
self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'],
'3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']}
- self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage']
+ self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
+ 'b_colorout']
if self.gcc_type != GCC_OSX:
self.base_options.append('b_lundef')
+ def get_colorout_args(self, colortype):
+ if mesonlib.version_compare(self.version, '>=4.9.0'):
+ return gnu_color_args[colortype][:]
+ return []
+
def get_always_args(self):
return ['-pipe']