mirror of
https://github.com/mesonbuild/meson.git
synced 2026-08-05 15:20:27 +00:00
compilers: Remove Environment parameter from Compiler.has_function
This commit is contained in:
@@ -340,15 +340,12 @@ class ElbrusCCompiler(ElbrusCompiler, CCompiler):
|
||||
|
||||
# Elbrus C compiler does not have lchmod, but there is only linker warning, not compiler error.
|
||||
# So we should explicitly fail at this case.
|
||||
def has_function(self, funcname: str, prefix: str, env: 'Environment', *,
|
||||
def has_function(self, funcname: str, prefix: str, *,
|
||||
extra_args: T.Optional[T.List[str]] = None,
|
||||
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
||||
if funcname == 'lchmod':
|
||||
return False, False
|
||||
else:
|
||||
return super().has_function(funcname, prefix, env,
|
||||
extra_args=extra_args,
|
||||
dependencies=dependencies)
|
||||
return super().has_function(funcname, prefix, extra_args=extra_args, dependencies=dependencies)
|
||||
|
||||
|
||||
class IntelCCompiler(IntelGnuLikeCompiler, CCompiler):
|
||||
|
||||
@@ -742,7 +742,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
|
||||
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[int, bool]:
|
||||
raise EnvironmentException('Language %s does not support alignment checks.' % self.get_display_language())
|
||||
|
||||
def has_function(self, funcname: str, prefix: str, env: 'Environment', *,
|
||||
def has_function(self, funcname: str, prefix: str, *,
|
||||
extra_args: T.Optional[T.List[str]] = None,
|
||||
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
||||
"""See if a function exists.
|
||||
|
||||
@@ -616,15 +616,12 @@ class ElbrusCPPCompiler(ElbrusCompiler, CPPCompiler):
|
||||
|
||||
# Elbrus C++ compiler does not have lchmod, but there is only linker warning, not compiler error.
|
||||
# So we should explicitly fail at this case.
|
||||
def has_function(self, funcname: str, prefix: str, env: 'Environment', *,
|
||||
def has_function(self, funcname: str, prefix: str, *,
|
||||
extra_args: T.Optional[T.List[str]] = None,
|
||||
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
||||
if funcname == 'lchmod':
|
||||
return False, False
|
||||
else:
|
||||
return super().has_function(funcname, prefix, env,
|
||||
extra_args=extra_args,
|
||||
dependencies=dependencies)
|
||||
return super().has_function(funcname, prefix, extra_args=extra_args, dependencies=dependencies)
|
||||
|
||||
# Elbrus C++ compiler does not support RTTI, so don't check for it.
|
||||
def get_option_compile_args(self, target: 'BuildTarget', env: 'Environment', subproject: T.Optional[str] = None) -> T.List[str]:
|
||||
|
||||
@@ -46,7 +46,7 @@ class FortranCompiler(CLikeCompiler, Compiler):
|
||||
full_version=full_version, linker=linker)
|
||||
CLikeCompiler.__init__(self)
|
||||
|
||||
def has_function(self, funcname: str, prefix: str, env: 'Environment', *,
|
||||
def has_function(self, funcname: str, prefix: str, *,
|
||||
extra_args: T.Optional[T.List[str]] = None,
|
||||
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
||||
raise MesonException('Fortran does not have "has_function" capability.\n'
|
||||
|
||||
@@ -19,7 +19,6 @@ from .gnu import GnuLikeCompiler
|
||||
|
||||
if T.TYPE_CHECKING:
|
||||
from ...options import MutableKeyedOptionDictType
|
||||
from ...environment import Environment
|
||||
from ...dependencies import Dependency # noqa: F401
|
||||
from ..compilers import Compiler
|
||||
|
||||
@@ -149,7 +148,7 @@ class ClangCompiler(GnuLikeCompiler):
|
||||
myargs.append('-Werror=ignored-optimization-argument')
|
||||
return super().get_compiler_check_args(mode) + myargs
|
||||
|
||||
def has_function(self, funcname: str, prefix: str, env: 'Environment', *,
|
||||
def has_function(self, funcname: str, prefix: str, *,
|
||||
extra_args: T.Optional[T.List[str]] = None,
|
||||
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
||||
if extra_args is None:
|
||||
@@ -161,7 +160,7 @@ class ClangCompiler(GnuLikeCompiler):
|
||||
# TODO: this really should be communicated by the linker
|
||||
if isinstance(self.linker, AppleDynamicLinker) and mesonlib.version_compare(self.version, '>=8.0'):
|
||||
extra_args.append('-Wl,-no_weak_imports')
|
||||
return super().has_function(funcname, prefix, env, extra_args=extra_args,
|
||||
return super().has_function(funcname, prefix, extra_args=extra_args,
|
||||
dependencies=dependencies)
|
||||
|
||||
def openmp_flags(self) -> T.List[str]:
|
||||
|
||||
@@ -763,7 +763,7 @@ class CLikeCompiler(Compiler):
|
||||
}}'''
|
||||
return head, main
|
||||
|
||||
def has_function(self, funcname: str, prefix: str, env: 'Environment', *,
|
||||
def has_function(self, funcname: str, prefix: str, *,
|
||||
extra_args: T.Optional[T.List[str]] = None,
|
||||
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
||||
"""Determine if a function exists.
|
||||
@@ -781,7 +781,7 @@ class CLikeCompiler(Compiler):
|
||||
varname = 'has function ' + funcname
|
||||
varname = varname.replace(' ', '_')
|
||||
if self.is_cross:
|
||||
val = env.properties.host.get(varname, None)
|
||||
val = self.environment.properties.host.get(varname, None)
|
||||
if val is not None:
|
||||
if isinstance(val, bool):
|
||||
return val, False
|
||||
|
||||
@@ -59,7 +59,7 @@ class AtomicBuiltinDependency(BuiltinDependency):
|
||||
super().__init__(name, env, kwargs)
|
||||
self.feature_since = ('1.7.0', "consider checking for `atomic_flag_clear` with and without `find_library('atomic')`")
|
||||
|
||||
if self.clib_compiler.has_function('atomic_flag_clear', '#include <stdatomic.h>', env)[0]:
|
||||
if self.clib_compiler.has_function('atomic_flag_clear', '#include <stdatomic.h>')[0]:
|
||||
self.is_found = True
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class DlBuiltinDependency(BuiltinDependency):
|
||||
super().__init__(name, env, kwargs)
|
||||
self.feature_since = ('0.62.0', "consider checking for `dlopen` with and without `find_library('dl')`")
|
||||
|
||||
if self.clib_compiler.has_function('dlopen', '#include <dlfcn.h>', env)[0]:
|
||||
if self.clib_compiler.has_function('dlopen', '#include <dlfcn.h>')[0]:
|
||||
self.is_found = True
|
||||
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ class CompilerHolder(ObjectHolder['Compiler']):
|
||||
return False
|
||||
extra_args = self._determine_args(kwargs)
|
||||
deps, msg = self._determine_dependencies(kwargs['dependencies'], compile_only=False)
|
||||
had, cached = self.compiler.has_function(funcname, kwargs['prefix'], self.environment,
|
||||
had, cached = self.compiler.has_function(funcname, kwargs['prefix'],
|
||||
extra_args=extra_args,
|
||||
dependencies=deps)
|
||||
cached_msg = mlog.blue('(cached)') if cached else ''
|
||||
|
||||
Reference in New Issue
Block a user