diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-11-13 09:26:44 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-11-19 10:48:48 -0800 |
| commit | 15e054e9c3eb685e250f3a472644454375f6d5c0 (patch) | |
| tree | 0eae9f19d0cc2bb5daf3f1aa6ac00ef942fe92e3 | |
| parent | 40b4151f33ea05f1f305f09831c24caa8a920a19 (diff) | |
| download | meson-15e054e9c3eb685e250f3a472644454375f6d5c0.tar.gz | |
compilers: Remove Environment parameter from Compiler.has_header
| -rw-r--r-- | mesonbuild/compilers/compilers.py | 2 | ||||
| -rw-r--r-- | mesonbuild/compilers/cpp.py | 2 | ||||
| -rw-r--r-- | mesonbuild/compilers/d.py | 2 | ||||
| -rw-r--r-- | mesonbuild/compilers/fortran.py | 2 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/clike.py | 2 | ||||
| -rw-r--r-- | mesonbuild/dependencies/dev.py | 2 | ||||
| -rw-r--r-- | mesonbuild/dependencies/misc.py | 16 | ||||
| -rw-r--r-- | mesonbuild/dependencies/python.py | 2 | ||||
| -rw-r--r-- | mesonbuild/dependencies/ui.py | 4 | ||||
| -rw-r--r-- | mesonbuild/interpreter/compiler.py | 2 | ||||
| -rw-r--r-- | mesonbuild/modules/codegen.py | 2 |
11 files changed, 19 insertions, 19 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 01098086b..7f7a41ee7 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -652,7 +652,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): """ raise EnvironmentException('Language %s does not support header checks.' % self.get_display_language()) - def has_header(self, hname: str, prefix: str, env: 'Environment', *, + def has_header(self, hname: str, prefix: str, *, extra_args: T.Union[None, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, disable_cache: bool = False) -> T.Tuple[bool, bool]: diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 27461449d..46c7bf5d8 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -183,7 +183,7 @@ class _StdCPPLibMixin(CompilerMixinBase): def language_stdlib_provider(self, env: Environment) -> str: # https://stackoverflow.com/a/31658120 - header = 'version' if self.has_header('version', '', env)[0] else 'ciso646' + header = 'version' if self.has_header('version', '')[0] else 'ciso646' is_libcxx = self.has_header_symbol(header, '_LIBCPP_VERSION', '')[0] lib = 'c++' if is_libcxx else 'stdc++' return lib diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index b32b43355..dd120947d 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -617,7 +617,7 @@ class DCompiler(Compiler): raise mesonlib.EnvironmentException(f'Could not determine alignment of {typename}. Sorry. You might want to file a bug.') return align, res.cached - def has_header(self, hname: str, prefix: str, env: 'Environment', *, + def has_header(self, hname: str, prefix: str, *, extra_args: T.Union[None, T.List[str], T.Callable[['CompileCheckMode'], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, disable_cache: bool = False) -> T.Tuple[bool, bool]: diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index e22f97f0e..44a05b971 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -308,7 +308,7 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler): search_dirs.append(f'-L{d}') return search_dirs + ['-lgfortran', '-lm'] - def has_header(self, hname: str, prefix: str, env: 'Environment', *, + def has_header(self, hname: str, prefix: str, *, extra_args: T.Union[None, T.List[str], T.Callable[['CompileCheckMode'], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, disable_cache: bool = False) -> T.Tuple[bool, bool]: diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 5f37ce84f..67a3b3863 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -318,7 +318,7 @@ class CLikeCompiler(Compiler): return self.compiles(code, extra_args=extra_args, dependencies=dependencies) - def has_header(self, hname: str, prefix: str, env: 'Environment', *, + def has_header(self, hname: str, prefix: str, *, extra_args: T.Union[None, T.List[str], T.Callable[['CompileCheckMode'], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, disable_cache: bool = False) -> T.Tuple[bool, bool]: diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py index 8da9ad7dc..c5b78c9a5 100644 --- a/mesonbuild/dependencies/dev.py +++ b/mesonbuild/dependencies/dev.py @@ -541,7 +541,7 @@ class ZlibSystemDependency(SystemDependency): libs = ['z'] for lib in libs: l = self.clib_compiler.find_library(lib, [], self.libtype) - h = self.clib_compiler.has_header('zlib.h', '', environment, dependencies=[self]) + h = self.clib_compiler.has_header('zlib.h', '', dependencies=[self]) if l and h[0]: self.is_found = True self.link_args = l diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py index 413bbae33..a0301bef9 100644 --- a/mesonbuild/dependencies/misc.py +++ b/mesonbuild/dependencies/misc.py @@ -68,7 +68,7 @@ class AtomicSystemDependency(SystemDependency): super().__init__(name, env, kwargs) self.feature_since = ('1.7.0', "consider checking for `atomic_flag_clear` with and without `find_library('atomic')`") - h = self.clib_compiler.has_header('stdatomic.h', '', env) + h = self.clib_compiler.has_header('stdatomic.h', '') self.link_args = self.clib_compiler.find_library('atomic', [], self.libtype) if h[0] and self.link_args: @@ -89,7 +89,7 @@ class DlSystemDependency(SystemDependency): super().__init__(name, env, kwargs) self.feature_since = ('0.62.0', "consider checking for `dlopen` with and without `find_library('dl')`") - h = self.clib_compiler.has_header('dlfcn.h', '', env) + h = self.clib_compiler.has_header('dlfcn.h', '') self.link_args = self.clib_compiler.find_library('dl', [], self.libtype) if h[0] and self.link_args: @@ -157,7 +157,7 @@ class OpenMPDependency(SystemDependency): # Flang has omp_lib.h header_names = ('omp.h', 'omp_lib.h') for name in header_names: - if self.clib_compiler.has_header(name, '', self.env, dependencies=[self], disable_cache=True)[0]: + if self.clib_compiler.has_header(name, '', dependencies=[self], disable_cache=True)[0]: self.is_found = True break else: @@ -193,7 +193,7 @@ class BlocksDependency(SystemDependency): self.compile_args = ['-fblocks'] self.link_args = ['-lBlocksRuntime'] - if not self.clib_compiler.has_header('Block.h', '', environment, disable_cache=True) or \ + if not self.clib_compiler.has_header('Block.h', '', disable_cache=True) or \ not self.clib_compiler.find_library('BlocksRuntime', []): mlog.log(mlog.red('ERROR:'), 'BlocksRuntime not found.') return @@ -375,7 +375,7 @@ class CursesSystemDependency(SystemDependency): l = self.clib_compiler.find_library(lib, []) if l: for header in headers: - h = self.clib_compiler.has_header(header, '', env) + h = self.clib_compiler.has_header(header, '') if h[0]: self.is_found = True self.link_args = l @@ -421,7 +421,7 @@ class IconvSystemDependency(SystemDependency): super().__init__(name, env, kwargs) self.feature_since = ('0.60.0', "consider checking for `iconv_open` with and without find_library('iconv')") - h = self.clib_compiler.has_header('iconv.h', '', env) + h = self.clib_compiler.has_header('iconv.h', '') self.link_args = self.clib_compiler.find_library('iconv', [], self.libtype) if h[0] and self.link_args: @@ -443,7 +443,7 @@ class IntlSystemDependency(SystemDependency): super().__init__(name, env, kwargs) self.feature_since = ('0.59.0', "consider checking for `ngettext` with and without `find_library('intl')`") - h = self.clib_compiler.has_header('libintl.h', '', env) + h = self.clib_compiler.has_header('libintl.h', '') self.link_args = self.clib_compiler.find_library('intl', [], self.libtype) if h[0] and self.link_args: @@ -462,7 +462,7 @@ class OpensslSystemDependency(SystemDependency): 'method': DependencyMethods.SYSTEM, 'static': self.static, } - if not self.clib_compiler.has_header('openssl/ssl.h', '', env)[0]: + if not self.clib_compiler.has_header('openssl/ssl.h', '')[0]: return # openssl >= 3 only diff --git a/mesonbuild/dependencies/python.py b/mesonbuild/dependencies/python.py index 93b915014..aa2e22c6f 100644 --- a/mesonbuild/dependencies/python.py +++ b/mesonbuild/dependencies/python.py @@ -556,7 +556,7 @@ class PythonSystemDependency(SystemDependency, _PythonDependencyBase): if mesonlib.is_windows() and self.get_windows_python_arch().endswith('64') and mesonlib.version_compare(self.version, '<3.12'): self.compile_args += ['-DMS_WIN64='] - if not self.clib_compiler.has_header('Python.h', '', environment, extra_args=self.compile_args)[0]: + if not self.clib_compiler.has_header('Python.h', '', extra_args=self.compile_args)[0]: self.is_found = False @staticmethod diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py index 663345ee8..5e5434d69 100644 --- a/mesonbuild/dependencies/ui.py +++ b/mesonbuild/dependencies/ui.py @@ -45,7 +45,7 @@ class GLDependencySystem(SystemDependency): return else: links = self.clib_compiler.find_library('GL', []) - has_header = self.clib_compiler.has_header('GL/gl.h', '', environment)[0] + has_header = self.clib_compiler.has_header('GL/gl.h', '')[0] if links and has_header: self.is_found = True self.link_args = links @@ -216,7 +216,7 @@ class VulkanDependencySystem(SystemDependency): else: # simply try to guess it, usually works on linux libs = self.clib_compiler.find_library('vulkan', []) - if libs is not None and self.clib_compiler.has_header('vulkan/vulkan.h', '', environment, disable_cache=True)[0]: + if libs is not None and self.clib_compiler.has_header('vulkan/vulkan.h', '', disable_cache=True)[0]: self.is_found = True for lib in libs: self.link_args.append(lib) diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py index 02f83d9e2..92281d0a7 100644 --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -610,7 +610,7 @@ class CompilerHolder(ObjectHolder['Compiler']): return False extra_args = functools.partial(self._determine_args, kwargs) deps, msg = self._determine_dependencies(kwargs['dependencies']) - haz, cached = self.compiler.has_header(hname, kwargs['prefix'], self.environment, + haz, cached = self.compiler.has_header(hname, kwargs['prefix'], extra_args=extra_args, dependencies=deps) cached_msg = mlog.blue('(cached)') if cached else '' if required and not haz: diff --git a/mesonbuild/modules/codegen.py b/mesonbuild/modules/codegen.py index c1daa91c5..f37f964c4 100644 --- a/mesonbuild/modules/codegen.py +++ b/mesonbuild/modules/codegen.py @@ -157,7 +157,7 @@ class LexHolder(ObjectHolder[LexGenerator]): comp = self.interpreter.environment.coredata.compilers[for_machine]['cpp'] except KeyError: raise MesonException(f"Could not find a C++ compiler for {for_machine} to search for FlexLexer.h") - found, _ = comp.has_header('FlexLexer.h', '', self.interpreter.environment) + found, _ = comp.has_header('FlexLexer.h', '') if not found: raise MesonException('Could not find FlexLexer.h, which is required for Flex with C++') |
