compilers: Make get_display_language a class or static method

Currently this is done at the instance level, but we need it at the
class level to allow compiler "lang" args to be gotten early enough.
This patch also removes a couple of instance of branch/leaf classes
providing their own implementation that is identical to the Compiler
version.
pull/6065/head
Dylan Baker 5 years ago
parent ee6e249f65
commit 7460e4ccda
  1. 5
      mesonbuild/compilers/compilers.py
  2. 3
      mesonbuild/compilers/cpp.py
  3. 3
      mesonbuild/compilers/cs.py
  4. 3
      mesonbuild/compilers/cuda.py
  5. 3
      mesonbuild/compilers/fortran.py
  6. 3
      mesonbuild/compilers/objc.py
  7. 3
      mesonbuild/compilers/objcpp.py

@ -731,8 +731,9 @@ class Compiler:
def get_language(self) -> str:
return self.language
def get_display_language(self) -> str:
return self.language.capitalize()
@classmethod
def get_display_language(cls) -> str:
return cls.language.capitalize()
def get_default_suffix(self) -> str:
return self.default_suffix

@ -67,7 +67,8 @@ class CPPCompiler(CLikeCompiler, Compiler):
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap)
def get_display_language(self):
@staticmethod
def get_display_language():
return 'C++'
def get_no_stdinc_args(self):

@ -43,7 +43,8 @@ class CsCompiler(BasicLinkerIsCompilerMixin, Compiler):
self.is_cross = False
self.runner = runner
def get_display_language(self):
@classmethod
def get_display_language(cls):
return 'C sharp'
def get_always_args(self):

@ -61,9 +61,6 @@ class CudaCompiler(Compiler):
def get_always_args(self):
return []
def get_display_language(self):
return 'Cuda'
def get_no_stdinc_args(self):
return []

@ -49,9 +49,6 @@ class FortranCompiler(CLikeCompiler, Compiler):
CLikeCompiler.__init__(self, is_cross, exe_wrapper)
self.id = 'unknown'
def get_display_language(self):
return 'Fortran'
def has_function(self, funcname, prefix, env, *, extra_args=None, dependencies=None):
raise MesonException('Fortran does not have "has_function" capability.\n'
'It is better to test if a Fortran capability is working like:\n\n'

@ -36,7 +36,8 @@ class ObjCCompiler(CLikeCompiler, Compiler):
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap)
def get_display_language(self):
@staticmethod
def get_display_language():
return 'Objective-C'
def sanity_check(self, work_dir, environment):

@ -35,7 +35,8 @@ class ObjCPPCompiler(CLikeCompiler, Compiler):
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap)
def get_display_language(self):
@staticmethod
def get_display_language():
return 'Objective-C++'
def sanity_check(self, work_dir, environment):

Loading…
Cancel
Save