aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mensinger <daniel@mensinger-ka.de>2019-12-05 15:01:22 +0100
committerMichael Hirsch, Ph.D <10931741+scivision@users.noreply.github.com>2019-12-05 11:08:12 -0500
commit0cf31e2340c20ecac7934a504be5f2989e90edb4 (patch)
tree2f70e01573e12f6f20ea19aeae464e341a753836
parentf1971fed908f5a6e181e5a864f8177b16587d2de (diff)
downloadmeson-0cf31e2340c20ecac7934a504be5f2989e90edb4.zip
meson-0cf31e2340c20ecac7934a504be5f2989e90edb4.tar.gz
meson-0cf31e2340c20ecac7934a504be5f2989e90edb4.tar.bz2
lgtm: fix Multiple calls to __init__
Some slight refactoring for the dependency classes and I switched the elbrus compiler to the GnuLikeCompiler. This is also the correct use according to the documentation of GnuLikeCompiler.
-rw-r--r--mesonbuild/compilers/mixins/elbrus.py6
-rw-r--r--mesonbuild/dependencies/base.py5
-rw-r--r--mesonbuild/dependencies/cuda.py5
-rw-r--r--mesonbuild/dependencies/dev.py8
4 files changed, 11 insertions, 13 deletions
diff --git a/mesonbuild/compilers/mixins/elbrus.py b/mesonbuild/compilers/mixins/elbrus.py
index 387c5b8..e157d87 100644
--- a/mesonbuild/compilers/mixins/elbrus.py
+++ b/mesonbuild/compilers/mixins/elbrus.py
@@ -19,18 +19,18 @@ import typing
import subprocess
import re
-from .gnu import GnuCompiler
+from .gnu import GnuLikeCompiler
from ...mesonlib import Popen_safe
if typing.TYPE_CHECKING:
from ...environment import Environment
-class ElbrusCompiler(GnuCompiler):
+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.
def __init__(self, defines: typing.Dict[str, str]):
- GnuCompiler.__init__(self, defines)
+ super().__init__()
self.id = 'lcc'
self.base_options = ['b_pgo', 'b_coverage',
'b_ndebug', 'b_staticpic',
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 2e83d8e..d11aebf 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -273,7 +273,10 @@ class InternalDependency(Dependency):
class HasNativeKwarg:
def __init__(self, kwargs):
- self.for_machine = MachineChoice.BUILD if kwargs.get('native', False) else MachineChoice.HOST
+ self.for_machine = self.get_for_machine_from_kwargs(kwargs)
+
+ def get_for_machine_from_kwargs(self, kwargs):
+ return MachineChoice.BUILD if kwargs.get('native', False) else MachineChoice.HOST
class ExternalDependency(Dependency, HasNativeKwarg):
def __init__(self, type_name, environment, language, kwargs):
diff --git a/mesonbuild/dependencies/cuda.py b/mesonbuild/dependencies/cuda.py
index 5f60a11..7048e81 100644
--- a/mesonbuild/dependencies/cuda.py
+++ b/mesonbuild/dependencies/cuda.py
@@ -20,7 +20,7 @@ from .. import mlog
from .. import mesonlib
from ..environment import detect_cpu_family
-from .base import (DependencyException, ExternalDependency, HasNativeKwarg)
+from .base import (DependencyException, ExternalDependency)
class CudaDependency(ExternalDependency):
@@ -28,8 +28,7 @@ class CudaDependency(ExternalDependency):
supported_languages = ['cuda', 'cpp', 'c'] # see also _default_language
def __init__(self, environment, kwargs):
- HasNativeKwarg.__init__(self, kwargs) # initialize self.for_machine
- compilers = environment.coredata.compilers[self.for_machine]
+ compilers = environment.coredata.compilers[self.get_for_machine_from_kwargs(kwargs)]
language = self._detect_language(compilers)
if language not in self.supported_languages:
raise DependencyException('Language \'{}\' is not supported by the CUDA Toolkit. Supported languages are {}.'.format(language, self.supported_languages))
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index 894bfdc..15907d4 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -25,7 +25,7 @@ from ..mesonlib import version_compare, stringlistify, extract_as_list, MachineC
from ..environment import get_llvm_tool_names
from .base import (
DependencyException, DependencyMethods, ExternalDependency, PkgConfigDependency,
- strip_system_libdirs, ConfigToolDependency, CMakeDependency, HasNativeKwarg
+ strip_system_libdirs, ConfigToolDependency, CMakeDependency
)
from .misc import ThreadDependency
@@ -205,17 +205,13 @@ class LLVMDependencyConfigTool(ConfigToolDependency):
__cpp_blacklist = {'-DNDEBUG'}
def __init__(self, environment, kwargs):
- # Already called by `super().__init__`, but need `self.for_machine`
- # before `super().__init__` is called.
- HasNativeKwarg.__init__(self, kwargs)
-
self.tools = get_llvm_tool_names('llvm-config')
# Fedora starting with Fedora 30 adds a suffix of the number
# of bits in the isa that llvm targets, for example, on x86_64
# and aarch64 the name will be llvm-config-64, on x86 and arm
# it will be llvm-config-32.
- if environment.machines[self.for_machine].is_64_bit:
+ if environment.machines[self.get_for_machine_from_kwargs(kwargs)].is_64_bit:
self.tools.append('llvm-config-64')
else:
self.tools.append('llvm-config-32')