aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/mixins
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-01-10 09:54:46 -0800
committerEli Schwartz <eschwartz93@gmail.com>2022-01-10 15:53:26 -0500
commit1209b8820bad58fd3865069b63f3a1125d9824bc (patch)
tree95b8e6d0e706d377b8cfbf46f44a503097386e85 /mesonbuild/compilers/mixins
parentf67994476da4bdc5389c558989809df48a172c6e (diff)
downloadmeson-1209b8820bad58fd3865069b63f3a1125d9824bc.zip
meson-1209b8820bad58fd3865069b63f3a1125d9824bc.tar.gz
meson-1209b8820bad58fd3865069b63f3a1125d9824bc.tar.bz2
compilers: push the compiler id to a class variable
It really is a per class value, and shouldn't be set per instance. It also allows us to get rid of useless constructors, including those breaking mypy
Diffstat (limited to 'mesonbuild/compilers/mixins')
-rw-r--r--mesonbuild/compilers/mixins/arm.py6
-rw-r--r--mesonbuild/compilers/mixins/c2000.py3
-rw-r--r--mesonbuild/compilers/mixins/ccrx.py3
-rw-r--r--mesonbuild/compilers/mixins/clang.py3
-rw-r--r--mesonbuild/compilers/mixins/compcert.py3
-rw-r--r--mesonbuild/compilers/mixins/elbrus.py3
-rw-r--r--mesonbuild/compilers/mixins/gnu.py2
-rw-r--r--mesonbuild/compilers/mixins/intel.py6
-rw-r--r--mesonbuild/compilers/mixins/pgi.py3
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py9
-rw-r--r--mesonbuild/compilers/mixins/xc16.py3
11 files changed, 25 insertions, 19 deletions
diff --git a/mesonbuild/compilers/mixins/arm.py b/mesonbuild/compilers/mixins/arm.py
index fc39851..5bf862d 100644
--- a/mesonbuild/compilers/mixins/arm.py
+++ b/mesonbuild/compilers/mixins/arm.py
@@ -74,10 +74,11 @@ class ArmCompiler(Compiler):
"""Functionality that is common to all ARM family compilers."""
+ id = 'arm'
+
def __init__(self) -> None:
if not self.is_cross:
raise mesonlib.EnvironmentException('armcc supports only cross-compilation.')
- self.id = 'arm'
default_warn_args = [] # type: T.List[str]
self.warn_args = {'0': [],
'1': default_warn_args,
@@ -140,6 +141,8 @@ class ArmclangCompiler(Compiler):
This is the Keil armclang.
'''
+ id = 'armclang'
+
def __init__(self) -> None:
if not self.is_cross:
raise mesonlib.EnvironmentException('armclang supports only cross-compilation.')
@@ -148,7 +151,6 @@ class ArmclangCompiler(Compiler):
raise mesonlib.EnvironmentException(f'Unsupported Linker {self.linker.exelist}, must be armlink')
if not mesonlib.version_compare(self.version, '==' + self.linker.version):
raise mesonlib.EnvironmentException('armlink version does not match with compiler version')
- self.id = 'armclang'
self.base_options = {
OptionKey(o) for o in
['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
diff --git a/mesonbuild/compilers/mixins/c2000.py b/mesonbuild/compilers/mixins/c2000.py
index ab0278e..f614d16 100644
--- a/mesonbuild/compilers/mixins/c2000.py
+++ b/mesonbuild/compilers/mixins/c2000.py
@@ -55,10 +55,11 @@ c2000_debug_args = {
class C2000Compiler(Compiler):
+ id = 'c2000'
+
def __init__(self) -> None:
if not self.is_cross:
raise EnvironmentException('c2000 supports only cross-compilation.')
- self.id = 'c2000'
self.can_compile_suffixes.add('asm') # Assembly
self.can_compile_suffixes.add('cla') # Control Law Accelerator (CLA)
diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py
index eba4c45..d87769e 100644
--- a/mesonbuild/compilers/mixins/ccrx.py
+++ b/mesonbuild/compilers/mixins/ccrx.py
@@ -59,10 +59,11 @@ class CcrxCompiler(Compiler):
is_cross = True
can_compile_suffixes = set() # type: T.Set[str]
+ id = 'ccrx'
+
def __init__(self) -> None:
if not self.is_cross:
raise EnvironmentException('ccrx supports only cross-compilation.')
- self.id = 'ccrx'
# Assembly
self.can_compile_suffixes.add('src')
default_warn_args = [] # type: T.List[str]
diff --git a/mesonbuild/compilers/mixins/clang.py b/mesonbuild/compilers/mixins/clang.py
index 1391297..663a87e 100644
--- a/mesonbuild/compilers/mixins/clang.py
+++ b/mesonbuild/compilers/mixins/clang.py
@@ -45,9 +45,10 @@ clang_optimization_args = {
class ClangCompiler(GnuLikeCompiler):
+ id = 'clang'
+
def __init__(self, defines: T.Optional[T.Dict[str, str]]):
super().__init__()
- self.id = 'clang'
self.defines = defines or {}
self.base_options.update(
{OptionKey('b_colorout'), OptionKey('b_lto_threads'), OptionKey('b_lto_mode')})
diff --git a/mesonbuild/compilers/mixins/compcert.py b/mesonbuild/compilers/mixins/compcert.py
index 3211f6a..283c043 100644
--- a/mesonbuild/compilers/mixins/compcert.py
+++ b/mesonbuild/compilers/mixins/compcert.py
@@ -60,8 +60,9 @@ ccomp_args_to_wul = [
class CompCertCompiler(Compiler):
+ id = 'ccomp'
+
def __init__(self) -> None:
- self.id = 'ccomp'
# Assembly
self.can_compile_suffixes.add('s')
default_warn_args = [] # type: T.List[str]
diff --git a/mesonbuild/compilers/mixins/elbrus.py b/mesonbuild/compilers/mixins/elbrus.py
index 80fbe12..aac9811 100644
--- a/mesonbuild/compilers/mixins/elbrus.py
+++ b/mesonbuild/compilers/mixins/elbrus.py
@@ -32,9 +32,10 @@ class ElbrusCompiler(GnuLikeCompiler):
# Elbrus compiler is nearly like GCC, but does not support
# PCH, LTO, sanitizers and color output as of version 1.21.x.
+ id = 'lcc'
+
def __init__(self) -> None:
super().__init__()
- self.id = 'lcc'
self.base_options = {OptionKey(o) for o in ['b_pgo', 'b_coverage', 'b_ndebug', 'b_staticpic', 'b_lundef', 'b_asneeded']}
default_warn_args = ['-Wall']
self.warn_args = {'0': [],
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index bc40af4..ea3aab4 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -328,10 +328,10 @@ class GnuCompiler(GnuLikeCompiler):
GnuCompiler represents an actual GCC in its many incarnations.
Compilers imitating GCC (Clang/Intel) should use the GnuLikeCompiler ABC.
"""
+ id = 'gcc'
def __init__(self, defines: T.Optional[T.Dict[str, str]]):
super().__init__()
- self.id = 'gcc'
self.defines = defines or {}
self.base_options.update({OptionKey('b_colorout'), OptionKey('b_lto_threads')})
diff --git a/mesonbuild/compilers/mixins/intel.py b/mesonbuild/compilers/mixins/intel.py
index 1417743..2698b39 100644
--- a/mesonbuild/compilers/mixins/intel.py
+++ b/mesonbuild/compilers/mixins/intel.py
@@ -66,6 +66,7 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
'3': ['-O3'],
's': ['-Os'],
}
+ id = 'intel'
def __init__(self) -> None:
super().__init__()
@@ -77,7 +78,6 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
self.base_options = {mesonlib.OptionKey(o) for o in [
'b_pch', 'b_lundef', 'b_asneeded', 'b_pgo', 'b_coverage',
'b_ndebug', 'b_staticpic', 'b_pie']}
- self.id = 'intel'
self.lang_header = 'none'
def get_pch_suffix(self) -> str:
@@ -145,9 +145,7 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
's': ['/Os'],
}
- def __init__(self, target: str) -> None:
- super().__init__(target)
- self.id = 'intel-cl'
+ id = 'intel-cl'
def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]:
args = super().get_compiler_check_args(mode)
diff --git a/mesonbuild/compilers/mixins/pgi.py b/mesonbuild/compilers/mixins/pgi.py
index 51de8af..2bc7012 100644
--- a/mesonbuild/compilers/mixins/pgi.py
+++ b/mesonbuild/compilers/mixins/pgi.py
@@ -43,9 +43,10 @@ pgi_buildtype_args = {
class PGICompiler(Compiler):
+ id = 'pgi'
+
def __init__(self) -> None:
self.base_options = {OptionKey('b_pch')}
- self.id = 'pgi'
default_warn_args = ['-Minform=inform']
self.warn_args = {'0': [],
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index ddd5476..9031195 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -388,9 +388,7 @@ class MSVCCompiler(VisualStudioLikeCompiler):
"""Specific to the Microsoft Compilers."""
- def __init__(self, target: str):
- super().__init__(target)
- self.id = 'msvc'
+ id = 'msvc'
def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> T.List[str]:
args = super().get_compile_debugfile_args(rel_obj, pch)
@@ -420,9 +418,10 @@ class ClangClCompiler(VisualStudioLikeCompiler):
"""Specific to Clang-CL."""
+ id = 'clang-cl'
+
def __init__(self, target: str):
super().__init__(target)
- self.id = 'clang-cl'
# Assembly
self.can_compile_suffixes.add('s')
@@ -450,4 +449,4 @@ class ClangClCompiler(VisualStudioLikeCompiler):
converted += [i]
return converted
else:
- return dep.get_compile_args() \ No newline at end of file
+ return dep.get_compile_args()
diff --git a/mesonbuild/compilers/mixins/xc16.py b/mesonbuild/compilers/mixins/xc16.py
index 77c4690..2433561 100644
--- a/mesonbuild/compilers/mixins/xc16.py
+++ b/mesonbuild/compilers/mixins/xc16.py
@@ -55,10 +55,11 @@ xc16_debug_args = {
class Xc16Compiler(Compiler):
+ id = 'xc16'
+
def __init__(self) -> None:
if not self.is_cross:
raise EnvironmentException('xc16 supports only cross-compilation.')
- self.id = 'xc16'
# Assembly
self.can_compile_suffixes.add('s')
default_warn_args = [] # type: T.List[str]