Add 'Compiler.get_display_language'

Use this when we print language-related information to the console and
via the Ninja backend.
pull/2002/head
Guillaume Poirier-Morency 8 years ago committed by Jussi Pakkanen
parent ce9cd33f27
commit fab5634916
  1. 2
      mesonbuild/backend/ninjabackend.py
  2. 2
      mesonbuild/compilers/c.py
  3. 3
      mesonbuild/compilers/compilers.py
  4. 3
      mesonbuild/compilers/cpp.py
  5. 3
      mesonbuild/compilers/cs.py
  6. 3
      mesonbuild/compilers/objc.py
  7. 3
      mesonbuild/compilers/objcpp.py
  8. 13
      mesonbuild/interpreter.py

@ -1606,7 +1606,7 @@ rule FORTRAN_DEP_HACK
output_args=' '.join(compiler.get_output_args('$out')), output_args=' '.join(compiler.get_output_args('$out')),
compile_only_args=' '.join(compiler.get_compile_only_args()) 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': if compiler.get_id() == 'msvc':
deps = ' deps = msvc\n' deps = ' deps = msvc\n'
else: else:

@ -179,7 +179,7 @@ class CCompiler(Compiler):
return ['-Wl,--out-implib=' + implibname] return ['-Wl,--out-implib=' + implibname]
def sanity_check_impl(self, work_dir, environment, sname, code): 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)) mlog.debug('Is cross compiler: %s.' % str(self.is_cross))
extra_flags = [] extra_flags = []

@ -584,6 +584,9 @@ class Compiler:
def get_language(self): def get_language(self):
return self.language return self.language
def get_display_language(self):
return self.language.capitalize()
def get_default_suffix(self): def get_default_suffix(self):
return self.default_suffix return self.default_suffix

@ -32,6 +32,9 @@ class CPPCompiler(CCompiler):
self.language = 'cpp' self.language = 'cpp'
CCompiler.__init__(self, exelist, version, is_cross, exe_wrap) CCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
def get_display_language(self):
return 'C++'
def get_no_stdinc_args(self): def get_no_stdinc_args(self):
return ['-nostdinc++'] return ['-nostdinc++']

@ -25,6 +25,9 @@ class MonoCompiler(Compiler):
self.id = 'mono' self.id = 'mono'
self.monorunner = 'mono' self.monorunner = 'mono'
def get_display_language(self):
return 'C#'
def get_output_args(self, fname): def get_output_args(self, fname):
return ['-out:' + fname] return ['-out:' + fname]

@ -24,6 +24,9 @@ class ObjCCompiler(CCompiler):
self.language = 'objc' self.language = 'objc'
CCompiler.__init__(self, exelist, version, is_cross, exe_wrap) CCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
def get_display_language(self):
return 'Objective-C'
def sanity_check(self, work_dir, environment): def sanity_check(self, work_dir, environment):
# TODO try to use sanity_check_impl instead of duplicated code # TODO try to use sanity_check_impl instead of duplicated code
source_name = os.path.join(work_dir, 'sanitycheckobjc.m') source_name = os.path.join(work_dir, 'sanitycheckobjc.m')

@ -24,6 +24,9 @@ class ObjCPPCompiler(CPPCompiler):
self.language = 'objcpp' self.language = 'objcpp'
CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap) CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
def get_display_language(self):
return 'Objective-C++'
def sanity_check(self, work_dir, environment): def sanity_check(self, work_dir, environment):
# TODO try to use sanity_check_impl instead of duplicated code # TODO try to use sanity_check_impl instead of duplicated code
source_name = os.path.join(work_dir, 'sanitycheckobjcpp.mm') source_name = os.path.join(work_dir, 'sanitycheckobjcpp.mm')

@ -741,7 +741,7 @@ class CompilerHolder(InterpreterObject):
def unittest_args_method(self, args, kwargs): def unittest_args_method(self, args, kwargs):
# At time, only D compilers have this feature. # At time, only D compilers have this feature.
if not hasattr(self.compiler, 'get_unittest_args'): 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() return self.compiler.get_unittest_args()
def has_member_method(self, args, kwargs): 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) raise InvalidCode('Search directory %s is not an absolute path.' % i)
linkargs = self.compiler.find_library(libname, self.environment, search_dirs) linkargs = self.compiler.find_library(libname, self.environment, search_dirs)
if required and not linkargs: if required and not linkargs:
l = self.compiler.language.capitalize() raise InterpreterException('{} library {!r} not found'.format(self.compiler.get_display_language(), libname))
raise InterpreterException('{} library {!r} not found'.format(l, libname))
lib = dependencies.ExternalLibrary(libname, linkargs, self.environment, lib = dependencies.ExternalLibrary(libname, linkargs, self.environment,
self.compiler.language) self.compiler.language)
return ExternalLibraryHolder(lib) return ExternalLibraryHolder(lib)
@ -986,7 +985,7 @@ class CompilerHolder(InterpreterObject):
h = mlog.green('YES') h = mlog.green('YES')
else: else:
h = mlog.red('NO') 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 return result
def has_multi_arguments_method(self, args, kwargs): def has_multi_arguments_method(self, args, kwargs):
@ -998,7 +997,7 @@ class CompilerHolder(InterpreterObject):
h = mlog.red('NO') h = mlog.red('NO')
mlog.log( mlog.log(
'Compiler for {} supports arguments {}:'.format( 'Compiler for {} supports arguments {}:'.format(
self.compiler.language, ' '.join(args)), self.compiler.get_display_language(), ' '.join(args)),
h) h)
return result return result
@ -1794,7 +1793,7 @@ class Interpreter(InterpreterBase):
continue continue
else: else:
raise 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: if not comp.get_language() in self.coredata.external_args:
(preproc_args, compile_args, link_args) = environment.get_args_from_envvars(comp) (preproc_args, compile_args, link_args) = environment.get_args_from_envvars(comp)
self.coredata.external_preprocess_args[comp.get_language()] = preproc_args 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.coredata.external_link_args[comp.get_language()] = link_args
self.build.add_compiler(comp) self.build.add_compiler(comp)
if need_cross_compiler: 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) self.build.add_cross_compiler(cross_comp)
if self.environment.is_cross_build() and not need_cross_compiler: if self.environment.is_cross_build() and not need_cross_compiler:
self.build.add_cross_compiler(comp) self.build.add_cross_compiler(comp)

Loading…
Cancel
Save