From ee6e249f659cd4658ae2f1a425d4aa01585c23aa Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 25 Nov 2019 11:45:17 -0800 Subject: 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. --- mesonbuild/compilers/objcpp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mesonbuild/compilers/objcpp.py') diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index 76cda7bd0..ea35a3634 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -26,10 +26,12 @@ if typing.TYPE_CHECKING: from ..envconfig import MachineInfo class ObjCPPCompiler(CLikeCompiler, Compiler): + + language = 'objcpp' + def __init__(self, exelist, version, for_machine: MachineChoice, is_cross: bool, info: 'MachineInfo', exe_wrap: typing.Optional[str], **kwargs): - self.language = 'objcpp' Compiler.__init__(self, exelist, version, for_machine, info, **kwargs) CLikeCompiler.__init__(self, is_cross, exe_wrap) -- cgit v1.2.3 From 7460e4ccda339d167402bd077dcaa364fab5e172 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 25 Nov 2019 12:05:19 -0800 Subject: 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. --- mesonbuild/compilers/compilers.py | 5 +++-- mesonbuild/compilers/cpp.py | 3 ++- mesonbuild/compilers/cs.py | 3 ++- mesonbuild/compilers/cuda.py | 3 --- mesonbuild/compilers/fortran.py | 3 --- mesonbuild/compilers/objc.py | 3 ++- mesonbuild/compilers/objcpp.py | 3 ++- 7 files changed, 11 insertions(+), 12 deletions(-) (limited to 'mesonbuild/compilers/objcpp.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index eedd4cf36..713a9e74b 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.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 diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 0cf77ab46..a2dd60f41 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -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): diff --git a/mesonbuild/compilers/cs.py b/mesonbuild/compilers/cs.py index f2b1442eb..d064e7c79 100644 --- a/mesonbuild/compilers/cs.py +++ b/mesonbuild/compilers/cs.py @@ -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): diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index c8ab9ac3b..385e4cf3d 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -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 [] diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 607d7a5f3..4aff72e9e 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -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' diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index 9f8bda801..a4aa5dc7b 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -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): diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index ea35a3634..b42cef600 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -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): -- cgit v1.2.3