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.
pull/6299/head
Daniel Mensinger 5 years ago committed by Michael Hirsch, Ph.D
parent f1971fed90
commit 0cf31e2340
  1. 6
      mesonbuild/compilers/mixins/elbrus.py
  2. 5
      mesonbuild/dependencies/base.py
  3. 5
      mesonbuild/dependencies/cuda.py
  4. 8
      mesonbuild/dependencies/dev.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',

@ -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):

@ -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))

@ -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')

Loading…
Cancel
Save