compilers: move language attribute to the class level

We know that if a compiler class inherits CCompiler it's language will
be C, so doing this at the class level makes more sense.
pull/6065/head
Dylan Baker 5 years ago
parent 0bf8862beb
commit ee6e249f65
  1. 3
      mesonbuild/compilers/c.py
  2. 3
      mesonbuild/compilers/cpp.py
  3. 4
      mesonbuild/compilers/cs.py
  4. 3
      mesonbuild/compilers/cuda.py
  5. 3
      mesonbuild/compilers/d.py
  6. 3
      mesonbuild/compilers/fortran.py
  7. 4
      mesonbuild/compilers/java.py
  8. 4
      mesonbuild/compilers/objc.py
  9. 4
      mesonbuild/compilers/objcpp.py
  10. 2
      mesonbuild/compilers/rust.py
  11. 2
      mesonbuild/compilers/swift.py
  12. 4
      mesonbuild/compilers/vala.py

@ -48,10 +48,11 @@ class CCompiler(CLikeCompiler, Compiler):
except KeyError: except KeyError:
raise MesonException('Unknown function attribute "{}"'.format(name)) raise MesonException('Unknown function attribute "{}"'.format(name))
language = 'c'
def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool,
info: 'MachineInfo', exe_wrapper: typing.Optional[str] = None, **kwargs): info: 'MachineInfo', exe_wrapper: typing.Optional[str] = None, **kwargs):
# If a child ObjC or CPP class has already set it, don't set it ourselves # If a child ObjC or CPP class has already set it, don't set it ourselves
self.language = 'c'
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrapper) CLikeCompiler.__init__(self, is_cross, exe_wrapper)

@ -59,10 +59,11 @@ class CPPCompiler(CLikeCompiler, Compiler):
except KeyError: except KeyError:
raise MesonException('Unknown function attribute "{}"'.format(name)) raise MesonException('Unknown function attribute "{}"'.format(name))
language = 'cpp'
def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool,
info: 'MachineInfo', exe_wrap: typing.Optional[str] = None, **kwargs): info: 'MachineInfo', exe_wrap: typing.Optional[str] = None, **kwargs):
# If a child ObjCPP class has already set it, don't set it ourselves # If a child ObjCPP class has already set it, don't set it ourselves
self.language = 'cpp'
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap) CLikeCompiler.__init__(self, is_cross, exe_wrap)

@ -33,9 +33,11 @@ cs_optimization_args = {'0': [],
class CsCompiler(BasicLinkerIsCompilerMixin, Compiler): class CsCompiler(BasicLinkerIsCompilerMixin, Compiler):
language = 'cs'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
info: 'MachineInfo', comp_id, runner=None): info: 'MachineInfo', comp_id, runner=None):
self.language = 'cs'
super().__init__(exelist, version, for_machine, info) super().__init__(exelist, version, for_machine, info)
self.id = comp_id self.id = comp_id
self.is_cross = False self.is_cross = False

@ -30,13 +30,12 @@ if typing.TYPE_CHECKING:
class CudaCompiler(Compiler): class CudaCompiler(Compiler):
LINKER_PREFIX = '-Xlinker=' LINKER_PREFIX = '-Xlinker='
language = 'cuda'
_universal_flags = {'compiler': ['-I', '-D', '-U', '-E'], 'linker': ['-l', '-L']} _universal_flags = {'compiler': ['-I', '-D', '-U', '-E'], 'linker': ['-l', '-L']}
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross, exe_wrapper, host_compiler, info: 'MachineInfo', **kwargs): is_cross, exe_wrapper, host_compiler, info: 'MachineInfo', **kwargs):
if not hasattr(self, 'language'):
self.language = 'cuda'
super().__init__(exelist, version, for_machine, info, **kwargs) super().__init__(exelist, version, for_machine, info, **kwargs)
self.is_cross = is_cross self.is_cross = is_cross
self.exe_wrapper = exe_wrapper self.exe_wrapper = exe_wrapper

@ -412,9 +412,10 @@ class DCompiler(Compiler):
'mtd': ['-mscrtlib=libcmtd'], 'mtd': ['-mscrtlib=libcmtd'],
} }
language = 'd'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
info: 'MachineInfo', arch, is_cross, exe_wrapper, **kwargs): info: 'MachineInfo', arch, is_cross, exe_wrapper, **kwargs):
self.language = 'd'
super().__init__(exelist, version, for_machine, info, **kwargs) super().__init__(exelist, version, for_machine, info, **kwargs)
self.id = 'unknown' self.id = 'unknown'
self.arch = arch self.arch = arch

@ -41,9 +41,10 @@ if TYPE_CHECKING:
class FortranCompiler(CLikeCompiler, Compiler): class FortranCompiler(CLikeCompiler, Compiler):
language = 'fortran'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs):
self.language = 'fortran'
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrapper) CLikeCompiler.__init__(self, is_cross, exe_wrapper)
self.id = 'unknown' self.id = 'unknown'

@ -25,9 +25,11 @@ if typing.TYPE_CHECKING:
from ..envconfig import MachineInfo from ..envconfig import MachineInfo
class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler): class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler):
language = 'java'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
info: 'MachineInfo'): info: 'MachineInfo'):
self.language = 'java'
super().__init__(exelist, version, for_machine, info) super().__init__(exelist, version, for_machine, info)
self.id = 'unknown' self.id = 'unknown'
self.is_cross = False self.is_cross = False

@ -27,10 +27,12 @@ if typing.TYPE_CHECKING:
class ObjCCompiler(CLikeCompiler, Compiler): class ObjCCompiler(CLikeCompiler, Compiler):
language = 'objc'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross: bool, info: 'MachineInfo', is_cross: bool, info: 'MachineInfo',
exe_wrap: typing.Optional[str], **kwargs): exe_wrap: typing.Optional[str], **kwargs):
self.language = 'objc'
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap) CLikeCompiler.__init__(self, is_cross, exe_wrap)

@ -26,10 +26,12 @@ if typing.TYPE_CHECKING:
from ..envconfig import MachineInfo from ..envconfig import MachineInfo
class ObjCPPCompiler(CLikeCompiler, Compiler): class ObjCPPCompiler(CLikeCompiler, Compiler):
language = 'objcpp'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross: bool, info: 'MachineInfo', is_cross: bool, info: 'MachineInfo',
exe_wrap: typing.Optional[str], **kwargs): exe_wrap: typing.Optional[str], **kwargs):
self.language = 'objcpp'
Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) Compiler.__init__(self, exelist, version, for_machine, info, **kwargs)
CLikeCompiler.__init__(self, is_cross, exe_wrap) CLikeCompiler.__init__(self, is_cross, exe_wrap)

@ -33,10 +33,10 @@ rust_optimization_args = {'0': [],
class RustCompiler(Compiler): class RustCompiler(Compiler):
# rustc doesn't invoke the compiler itself, it doesn't need a LINKER_PREFIX # rustc doesn't invoke the compiler itself, it doesn't need a LINKER_PREFIX
language = 'rust'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs): is_cross, info: 'MachineInfo', exe_wrapper=None, **kwargs):
self.language = 'rust'
super().__init__(exelist, version, for_machine, info, **kwargs) super().__init__(exelist, version, for_machine, info, **kwargs)
self.exe_wrapper = exe_wrapper self.exe_wrapper = exe_wrapper
self.id = 'rustc' self.id = 'rustc'

@ -33,10 +33,10 @@ swift_optimization_args = {'0': [],
class SwiftCompiler(Compiler): class SwiftCompiler(Compiler):
LINKER_PREFIX = ['-Xlinker'] LINKER_PREFIX = ['-Xlinker']
language = 'swift'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross, info: 'MachineInfo', **kwargs): is_cross, info: 'MachineInfo', **kwargs):
self.language = 'swift'
super().__init__(exelist, version, for_machine, info, **kwargs) super().__init__(exelist, version, for_machine, info, **kwargs)
self.version = version self.version = version
self.id = 'llvm' self.id = 'llvm'

@ -24,9 +24,11 @@ if typing.TYPE_CHECKING:
from ..envconfig import MachineInfo from ..envconfig import MachineInfo
class ValaCompiler(Compiler): class ValaCompiler(Compiler):
language = 'vala'
def __init__(self, exelist, version, for_machine: MachineChoice, def __init__(self, exelist, version, for_machine: MachineChoice,
is_cross, info: 'MachineInfo'): is_cross, info: 'MachineInfo'):
self.language = 'vala'
super().__init__(exelist, version, for_machine, info) super().__init__(exelist, version, for_machine, info)
self.version = version self.version = version
self.is_cross = is_cross self.is_cross = is_cross

Loading…
Cancel
Save