From fab5634916191816ddecf1a2a958fa7ed2eac1ec Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sat, 24 Jun 2017 20:16:30 -0400 Subject: [PATCH] Add 'Compiler.get_display_language' Use this when we print language-related information to the console and via the Ninja backend. --- mesonbuild/backend/ninjabackend.py | 2 +- mesonbuild/compilers/c.py | 2 +- mesonbuild/compilers/compilers.py | 3 +++ mesonbuild/compilers/cpp.py | 3 +++ mesonbuild/compilers/cs.py | 3 +++ mesonbuild/compilers/objc.py | 3 +++ mesonbuild/compilers/objcpp.py | 3 +++ mesonbuild/interpreter.py | 13 ++++++------- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 0c3525c1b..e8090e701 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1606,7 +1606,7 @@ rule FORTRAN_DEP_HACK output_args=' '.join(compiler.get_output_args('$out')), compile_only_args=' '.join(compiler.get_compile_only_args()) ) - description = ' description = Compiling %s object $out.\n' % langname.title() + description = ' description = Compiling %s object $out.\n' % compiler.get_display_language() if compiler.get_id() == 'msvc': deps = ' deps = msvc\n' else: diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index c164ccd70..cf9d1ee8f 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -179,7 +179,7 @@ class CCompiler(Compiler): return ['-Wl,--out-implib=' + implibname] def sanity_check_impl(self, work_dir, environment, sname, code): - mlog.debug('Sanity testing ' + self.language + ' compiler:', ' '.join(self.exelist)) + mlog.debug('Sanity testing ' + self.get_display_language() + ' compiler:', ' '.join(self.exelist)) mlog.debug('Is cross compiler: %s.' % str(self.is_cross)) extra_flags = [] diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 3d5498603..232109337 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -584,6 +584,9 @@ class Compiler: def get_language(self): return self.language + def get_display_language(self): + return self.language.capitalize() + def get_default_suffix(self): return self.default_suffix diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 6d50e5793..01525b06b 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -32,6 +32,9 @@ class CPPCompiler(CCompiler): self.language = 'cpp' CCompiler.__init__(self, exelist, version, is_cross, exe_wrap) + def get_display_language(self): + return 'C++' + def get_no_stdinc_args(self): return ['-nostdinc++'] diff --git a/mesonbuild/compilers/cs.py b/mesonbuild/compilers/cs.py index c65a539cf..4f6fec12a 100644 --- a/mesonbuild/compilers/cs.py +++ b/mesonbuild/compilers/cs.py @@ -25,6 +25,9 @@ class MonoCompiler(Compiler): self.id = 'mono' self.monorunner = 'mono' + def get_display_language(self): + return 'C#' + def get_output_args(self, fname): return ['-out:' + fname] diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index b011c818d..388e83b95 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -24,6 +24,9 @@ class ObjCCompiler(CCompiler): self.language = 'objc' CCompiler.__init__(self, exelist, version, is_cross, exe_wrap) + def get_display_language(self): + return 'Objective-C' + def sanity_check(self, work_dir, environment): # TODO try to use sanity_check_impl instead of duplicated code source_name = os.path.join(work_dir, 'sanitycheckobjc.m') diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index b181f9aaf..c2e464798 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -24,6 +24,9 @@ class ObjCPPCompiler(CPPCompiler): self.language = 'objcpp' CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap) + def get_display_language(self): + return 'Objective-C++' + def sanity_check(self, work_dir, environment): # TODO try to use sanity_check_impl instead of duplicated code source_name = os.path.join(work_dir, 'sanitycheckobjcpp.mm') diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 7f279c1ee..b08de189f 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -741,7 +741,7 @@ class CompilerHolder(InterpreterObject): def unittest_args_method(self, args, kwargs): # At time, only D compilers have this feature. if not hasattr(self.compiler, 'get_unittest_args'): - raise InterpreterException('This {} compiler has no unittest arguments.'.format(self.compiler.language)) + raise InterpreterException('This {} compiler has no unittest arguments.'.format(self.compiler.get_display_language())) return self.compiler.get_unittest_args() def has_member_method(self, args, kwargs): @@ -971,8 +971,7 @@ class CompilerHolder(InterpreterObject): raise InvalidCode('Search directory %s is not an absolute path.' % i) linkargs = self.compiler.find_library(libname, self.environment, search_dirs) if required and not linkargs: - l = self.compiler.language.capitalize() - raise InterpreterException('{} library {!r} not found'.format(l, libname)) + raise InterpreterException('{} library {!r} not found'.format(self.compiler.get_display_language(), libname)) lib = dependencies.ExternalLibrary(libname, linkargs, self.environment, self.compiler.language) return ExternalLibraryHolder(lib) @@ -986,7 +985,7 @@ class CompilerHolder(InterpreterObject): h = mlog.green('YES') else: h = mlog.red('NO') - mlog.log('Compiler for {} supports argument {}:'.format(self.compiler.language, args[0]), h) + mlog.log('Compiler for {} supports argument {}:'.format(self.compiler.get_display_language(), args[0]), h) return result def has_multi_arguments_method(self, args, kwargs): @@ -998,7 +997,7 @@ class CompilerHolder(InterpreterObject): h = mlog.red('NO') mlog.log( 'Compiler for {} supports arguments {}:'.format( - self.compiler.language, ' '.join(args)), + self.compiler.get_display_language(), ' '.join(args)), h) return result @@ -1794,7 +1793,7 @@ class Interpreter(InterpreterBase): continue else: raise - mlog.log('Native %s compiler: ' % lang, mlog.bold(' '.join(comp.get_exelist())), ' (%s %s)' % (comp.id, comp.version), sep='') + mlog.log('Native %s compiler: ' % comp.get_display_language(), mlog.bold(' '.join(comp.get_exelist())), ' (%s %s)' % (comp.id, comp.version), sep='') if not comp.get_language() in self.coredata.external_args: (preproc_args, compile_args, link_args) = environment.get_args_from_envvars(comp) self.coredata.external_preprocess_args[comp.get_language()] = preproc_args @@ -1802,7 +1801,7 @@ class Interpreter(InterpreterBase): self.coredata.external_link_args[comp.get_language()] = link_args self.build.add_compiler(comp) if need_cross_compiler: - mlog.log('Cross %s compiler: ' % lang, mlog.bold(' '.join(cross_comp.get_exelist())), ' (%s %s)' % (cross_comp.id, cross_comp.version), sep='') + mlog.log('Cross %s compiler: ' % cross_comp.get_display_language(), mlog.bold(' '.join(cross_comp.get_exelist())), ' (%s %s)' % (cross_comp.id, cross_comp.version), sep='') self.build.add_cross_compiler(cross_comp) if self.environment.is_cross_build() and not need_cross_compiler: self.build.add_cross_compiler(comp)