From a0666ebf9c4e193f176fa1aeafbcbf13445b51f4 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 1 Jul 2016 23:38:25 +0300 Subject: [PATCH] Gcc versions older than 4.9 do not support color output. --- mesonbuild/backend/backends.py | 7 ++++--- mesonbuild/backend/ninjabackend.py | 6 +++--- mesonbuild/compilers.py | 8 ++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 05a3565f5..fcc3d3b56 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -83,8 +83,9 @@ class Backend(): return i raise RuntimeError('No compiler for language ' + lang) - def get_compiler_for_source(self, src): - for i in self.build.compilers: + def get_compiler_for_source(self, src, is_cross): + comp = self.build.cross_compilers if is_cross else self.build.compilers + for i in comp: if i.can_compile(src): return i if isinstance(src, mesonlib.File): @@ -133,7 +134,7 @@ class Backend(): abs_files = [] result = [] for src in unity_src: - comp = self.get_compiler_for_source(src) + comp = self.get_compiler_for_source(src, target.is_cross) language = comp.get_language() suffix = '.' + comp.get_default_suffix() if language not in langlist: diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 9bc4842df..a1bccc26a 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -665,7 +665,7 @@ int dummy; outname_rel = os.path.join(self.get_target_dir(target), fname) src_list = target.get_sources() class_list = [] - compiler = self.get_compiler_for_source(src_list[0]) + compiler = self.get_compiler_for_source(src_list[0], False) assert(compiler.get_language() == 'java') c = 'c' m = '' @@ -716,7 +716,7 @@ int dummy; fname = target.get_filename() outname_rel = os.path.join(self.get_target_dir(target), fname) src_list = target.get_sources() - compiler = self.get_compiler_for_source(src_list[0]) + compiler = self.get_compiler_for_source(src_list[0], False) assert(compiler.get_language() == 'cs') rel_srcs = [s.rel_to_builddir(self.build_to_src) for s in src_list] deps = [] @@ -1424,7 +1424,7 @@ rule FORTRAN_DEP_HACK if isinstance(src, RawFilename) and src.fname.endswith('.h'): raise RuntimeError('Fug') extra_orderdeps = [] - compiler = self.get_compiler_for_source(src) + compiler = self.get_compiler_for_source(src, target.is_cross) commands = [] # The first thing is implicit include directories: source, build and private. commands += compiler.get_include_args(self.get_target_private_dir(target), False) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 30cd2bccd..8ee86bc75 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -1644,7 +1644,9 @@ class GnuCCompiler(CCompiler): self.base_options.append('b_lundef') def get_colorout_args(self, colortype): - return gnu_color_args[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: @@ -1831,7 +1833,9 @@ class GnuCPPCompiler(CPPCompiler): self.base_options.append('b_lundef') def get_colorout_args(self, colortype): - return gnu_color_args[colortype][:] + if mesonlib.version_compare(self.version, '>=4.9.0'): + return gnu_color_args[colortype][:] + return [] def get_always_args(self): return ['-pipe']