summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-11-12 14:38:24 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-11-19 10:48:48 -0800
commit252faf5be8ffb23b5f335ebf10c7f1c3d3717ec5 (patch)
tree38a529c3e1f96f3c88d7e01cbe84af1e14727a5c
parent52d77090cbabd109f24b46cf13f51543bda08a3f (diff)
downloadmeson-252faf5be8ffb23b5f335ebf10c7f1c3d3717ec5.tar.gz
compilers: Remove Environment parameter from Compiler.find_library
-rw-r--r--mesonbuild/cmake/tracetargets.py2
-rw-r--r--mesonbuild/compilers/compilers.py4
-rw-r--r--mesonbuild/compilers/cpp.py2
-rw-r--r--mesonbuild/compilers/cuda.py6
-rw-r--r--mesonbuild/compilers/fortran.py6
-rw-r--r--mesonbuild/compilers/mixins/apple.py2
-rw-r--r--mesonbuild/compilers/mixins/clike.py17
-rw-r--r--mesonbuild/compilers/mixins/emscripten.py7
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py2
-rw-r--r--mesonbuild/compilers/vala.py8
-rw-r--r--mesonbuild/dependencies/__init__.py2
-rw-r--r--mesonbuild/dependencies/cuda.py2
-rw-r--r--mesonbuild/dependencies/dev.py14
-rw-r--r--mesonbuild/dependencies/misc.py18
-rw-r--r--mesonbuild/dependencies/pkgconfig.py5
-rw-r--r--mesonbuild/dependencies/python.py2
-rw-r--r--mesonbuild/dependencies/qt.py4
-rw-r--r--mesonbuild/dependencies/ui.py6
-rw-r--r--mesonbuild/interpreter/compiler.py2
-rw-r--r--unittests/internaltests.py26
-rw-r--r--unittests/linuxliketests.py2
21 files changed, 69 insertions, 70 deletions
diff --git a/mesonbuild/cmake/tracetargets.py b/mesonbuild/cmake/tracetargets.py
index 2b2b93de7..b1ecabd40 100644
--- a/mesonbuild/cmake/tracetargets.py
+++ b/mesonbuild/cmake/tracetargets.py
@@ -96,7 +96,7 @@ def resolve_cmake_trace_targets(target_name: str,
# CMake brute-forces a combination of prefix/suffix combinations to find the
# right library. Assume any bare argument passed which is not also a CMake
# target must be a system library we should try to link against.
- flib = clib_compiler.find_library(curr, env, [])
+ flib = clib_compiler.find_library(curr, [])
if flib is not None:
res.libraries += flib
else:
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 4fbc5d764..2e66343a7 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -766,8 +766,8 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
"Always returns a copy that can be independently mutated"
return args.copy()
- def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
- libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
+ def find_library(self, libname: str, extra_dirs: T.List[str], libtype: LibType = LibType.PREFER_SHARED,
+ lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
raise EnvironmentException(f'Language {self.get_display_language()} does not support library finding.')
def get_library_naming(self, libtype: LibType, strict: bool = False) -> T.Optional[T.Tuple[str, ...]]:
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 233a28b63..bd80f3974 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -206,7 +206,7 @@ class _StdCPPLibMixin(CompilerMixinBase):
search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(self.environment, 'libraries')]
lib = self.language_stdlib_provider(self.environment)
- if self.find_library(lib, self.environment, []) is not None:
+ if self.find_library(lib, []) is not None:
return search_dirs + [f'-l{lib}']
# TODO: maybe a bug exception?
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py
index 551b8d690..3565b068c 100644
--- a/mesonbuild/compilers/cuda.py
+++ b/mesonbuild/compilers/cuda.py
@@ -760,9 +760,9 @@ class CudaCompiler(Compiler):
def get_std_exe_link_args(self) -> T.List[str]:
return self._to_host_flags(self.host_compiler.get_std_exe_link_args(), Phase.LINKER)
- def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
- libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
- return self.host_compiler.find_library(libname, env, extra_dirs, libtype, lib_prefix_warning, ignore_system_dirs)
+ def find_library(self, libname: str, extra_dirs: T.List[str], libtype: LibType = LibType.PREFER_SHARED,
+ lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
+ return self.host_compiler.find_library(libname, extra_dirs, libtype, lib_prefix_warning, ignore_system_dirs)
def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]:
return self._to_host_flags(self.host_compiler.get_crt_compile_args(crt_val, buildtype))
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index fdd452144..ee88bc7df 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -101,10 +101,10 @@ class FortranCompiler(CLikeCompiler, Compiler):
return filename
- def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
- libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
+ def find_library(self, libname: str, extra_dirs: T.List[str], libtype: LibType = LibType.PREFER_SHARED,
+ lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
code = 'stop; end program'
- return self._find_library_impl(libname, env, extra_dirs, code, libtype, lib_prefix_warning, ignore_system_dirs)
+ return self._find_library_impl(libname, extra_dirs, code, libtype, lib_prefix_warning, ignore_system_dirs)
def has_multi_arguments(self, args: T.List[str]) -> T.Tuple[bool, bool]:
return self._has_multi_arguments(args, 'stop; end program')
diff --git a/mesonbuild/compilers/mixins/apple.py b/mesonbuild/compilers/mixins/apple.py
index 02aab0d12..4ed2561b1 100644
--- a/mesonbuild/compilers/mixins/apple.py
+++ b/mesonbuild/compilers/mixins/apple.py
@@ -51,7 +51,7 @@ class AppleCompilerMixin(Compiler):
else:
root = '/opt/homebrew'
- link = self.find_library('omp', self.environment, [f'{root}/opt/libomp/lib'])
+ link = self.find_library('omp', [f'{root}/opt/libomp/lib'])
if not link:
raise MesonException("Couldn't find libomp")
return self.__BASE_OMP_FLAGS + link
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index f9989106f..fc7c86ecf 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -1128,7 +1128,8 @@ class CLikeCompiler(Compiler):
'''
return self.sizeof('void *', '', env)[0] == 8
- def _find_library_real(self, libname: str, env: 'Environment', extra_dirs: T.List[str], code: str, libtype: LibType, lib_prefix_warning: bool, ignore_system_dirs: bool) -> T.Optional[T.List[str]]:
+ def _find_library_real(self, libname: str, extra_dirs: T.List[str], code: str, libtype: LibType,
+ lib_prefix_warning: bool, ignore_system_dirs: bool) -> T.Optional[T.List[str]]:
# First try if we can just add the library as -l.
# Gcc + co seem to prefer builtin lib dirs to -L dirs.
# Only try to find std libs if no extra dirs specified.
@@ -1152,7 +1153,7 @@ class CLikeCompiler(Compiler):
# detect, we will just skip path validity checks done in
# get_library_dirs() call
try:
- if self.output_is_64bit(env):
+ if self.output_is_64bit(self.environment):
elf_class = 2
else:
elf_class = 1
@@ -1183,8 +1184,8 @@ class CLikeCompiler(Compiler):
return [Path(trial_result).as_posix()]
return None
- def _find_library_impl(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
- code: str, libtype: LibType, lib_prefix_warning: bool, ignore_system_dirs: bool) -> T.Optional[T.List[str]]:
+ def _find_library_impl(self, libname: str, extra_dirs: T.List[str], code: str, libtype: LibType,
+ lib_prefix_warning: bool, ignore_system_dirs: bool) -> T.Optional[T.List[str]]:
# These libraries are either built-in or invalid
if libname in self.ignore_libs:
return []
@@ -1192,7 +1193,7 @@ class CLikeCompiler(Compiler):
extra_dirs = [extra_dirs]
key = (tuple(self.exelist), libname, tuple(extra_dirs), code, libtype, ignore_system_dirs)
if key not in self.find_library_cache:
- value = self._find_library_real(libname, env, extra_dirs, code, libtype, lib_prefix_warning, ignore_system_dirs)
+ value = self._find_library_real(libname, extra_dirs, code, libtype, lib_prefix_warning, ignore_system_dirs)
self.find_library_cache[key] = value
else:
value = self.find_library_cache[key]
@@ -1200,10 +1201,10 @@ class CLikeCompiler(Compiler):
return None
return value.copy()
- def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
- libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
+ def find_library(self, libname: str, extra_dirs: T.List[str], libtype: LibType = LibType.PREFER_SHARED,
+ lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
code = 'int main(void) { return 0; }\n'
- return self._find_library_impl(libname, env, extra_dirs, code, libtype, lib_prefix_warning, ignore_system_dirs)
+ return self._find_library_impl(libname, extra_dirs, code, libtype, lib_prefix_warning, ignore_system_dirs)
def find_framework_paths(self) -> T.List[str]:
'''
diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py
index 5698ebef3..ca7779ae0 100644
--- a/mesonbuild/compilers/mixins/emscripten.py
+++ b/mesonbuild/compilers/mixins/emscripten.py
@@ -15,7 +15,6 @@ from ...mesonlib import LibType
from mesonbuild.compilers.compilers import CompileCheckMode
if T.TYPE_CHECKING:
- from ...environment import Environment
from ...compilers.compilers import Compiler
from ...dependencies import Dependency
else:
@@ -75,10 +74,10 @@ class EmscriptenMixin(Compiler):
def get_dependency_link_args(self, dep: 'Dependency') -> T.List[str]:
return wrap_js_includes(super().get_dependency_link_args(dep))
- def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
- libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
+ def find_library(self, libname: str, extra_dirs: T.List[str], libtype: LibType = LibType.PREFER_SHARED,
+ lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
if not libname.endswith('.js'):
- return super().find_library(libname, env, extra_dirs, libtype, lib_prefix_warning)
+ return super().find_library(libname, extra_dirs, libtype, lib_prefix_warning)
if os.path.isabs(libname):
if os.path.exists(libname):
return [libname]
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index db9a76dd9..d5c8ffeb3 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -495,7 +495,7 @@ class ClangClCompiler(VisualStudioLikeCompiler):
def openmp_link_flags(self) -> T.List[str]:
# see https://github.com/mesonbuild/meson/issues/5298
- libs = self.find_library('libomp', self.environment, [])
+ libs = self.find_library('libomp', [])
if libs is None:
raise mesonlib.MesonBugException('Could not find libomp')
return super().openmp_link_flags() + libs
diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py
index 046ea8c4b..c9b415326 100644
--- a/mesonbuild/compilers/vala.py
+++ b/mesonbuild/compilers/vala.py
@@ -119,8 +119,8 @@ class ValaCompiler(Compiler):
msg = f'Vala compiler {self.name_string()!r} cannot compile programs'
raise EnvironmentException(msg)
- def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
- libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
+ def find_library(self, libname: str, extra_dirs: T.List[str], libtype: LibType = LibType.PREFER_SHARED,
+ lib_prefix_warning: bool = True, ignore_system_dirs: bool = False) -> T.Optional[T.List[str]]:
if extra_dirs and isinstance(extra_dirs, str):
extra_dirs = [extra_dirs]
# Valac always looks in the default vapi dir, so only search there if
@@ -128,10 +128,10 @@ class ValaCompiler(Compiler):
if not extra_dirs:
code = 'class MesonFindLibrary : Object { }'
args: T.List[str] = []
- args += env.coredata.get_external_args(self.for_machine, self.language)
+ args += self.environment.coredata.get_external_args(self.for_machine, self.language)
vapi_args = ['--pkg', libname]
args += vapi_args
- with self.cached_compile(code, env.coredata, extra_args=args, mode=CompileCheckMode.COMPILE) as p:
+ with self.cached_compile(code, self.environment.coredata, extra_args=args, mode=CompileCheckMode.COMPILE) as p:
if p.returncode == 0:
return vapi_args
# Not found? Try to find the vapi file itself.
diff --git a/mesonbuild/dependencies/__init__.py b/mesonbuild/dependencies/__init__.py
index 00548e3ae..abe83351e 100644
--- a/mesonbuild/dependencies/__init__.py
+++ b/mesonbuild/dependencies/__init__.py
@@ -78,7 +78,7 @@ class FooSystemDependency(ExternalDependency):
self.is_found = False
return
- lib = self.clib_compiler.find_library('foo', environment, [os.path.join(root, 'lib')])
+ lib = self.clib_compiler.find_library('foo', [os.path.join(root, 'lib')])
if lib is None:
mlog.debug('Could not find lib.')
self.is_found = False
diff --git a/mesonbuild/dependencies/cuda.py b/mesonbuild/dependencies/cuda.py
index b09a4378f..d80c62d8d 100644
--- a/mesonbuild/dependencies/cuda.py
+++ b/mesonbuild/dependencies/cuda.py
@@ -280,7 +280,7 @@ class CudaDependency(SystemDependency):
# - libnvidia-ml.so in /usr/lib/ that is provided by the nvidia drivers
#
# Users should never link to the latter, since its ABI may change.
- args = self.clib_compiler.find_library(module, self.env, [self.libdir, os.path.join(self.libdir, 'stubs')], self.libtype, ignore_system_dirs=True)
+ args = self.clib_compiler.find_library(module, [self.libdir, os.path.join(self.libdir, 'stubs')], self.libtype, ignore_system_dirs=True)
if args is None:
self._report_dependency_error(f'Couldn\'t find requested CUDA module \'{module}\'')
diff --git a/mesonbuild/dependencies/dev.py b/mesonbuild/dependencies/dev.py
index aa7c4686b..8da9ad7dc 100644
--- a/mesonbuild/dependencies/dev.py
+++ b/mesonbuild/dependencies/dev.py
@@ -59,8 +59,8 @@ class GTestDependencySystem(SystemDependency):
self.detect()
def detect(self) -> None:
- gtest_detect = self.clib_compiler.find_library("gtest", self.env, [])
- gtest_main_detect = self.clib_compiler.find_library("gtest_main", self.env, [])
+ gtest_detect = self.clib_compiler.find_library("gtest", [])
+ gtest_main_detect = self.clib_compiler.find_library("gtest_main", [])
if gtest_detect and (not self.main or gtest_main_detect):
self.is_found = True
self.compile_args = []
@@ -135,8 +135,8 @@ class GMockDependencySystem(SystemDependency):
# GMock may be a library or just source.
# Work with both.
- gmock_detect = self.clib_compiler.find_library("gmock", self.env, [])
- gmock_main_detect = self.clib_compiler.find_library("gmock_main", self.env, [])
+ gmock_detect = self.clib_compiler.find_library("gmock", [])
+ gmock_main_detect = self.clib_compiler.find_library("gmock_main", [])
if gmock_detect and (not self.main or gmock_main_detect):
self.is_found = True
self.link_args += gmock_detect
@@ -540,7 +540,7 @@ class ZlibSystemDependency(SystemDependency):
else:
libs = ['z']
for lib in libs:
- l = self.clib_compiler.find_library(lib, environment, [], self.libtype)
+ l = self.clib_compiler.find_library(lib, [], self.libtype)
h = self.clib_compiler.has_header('zlib.h', '', environment, dependencies=[self])
if l and h[0]:
self.is_found = True
@@ -623,14 +623,14 @@ class JNISystemDependency(SystemDependency):
java_home_lib_server = java_home_lib / 'server'
if 'jvm' in modules:
- jvm = self.clib_compiler.find_library('jvm', environment, extra_dirs=[str(java_home_lib_server)])
+ jvm = self.clib_compiler.find_library('jvm', extra_dirs=[str(java_home_lib_server)])
if jvm is None:
mlog.debug('jvm library not found.')
self.is_found = False
else:
self.link_args.extend(jvm)
if 'awt' in modules:
- jawt = self.clib_compiler.find_library('jawt', environment, extra_dirs=[str(java_home_lib)])
+ jawt = self.clib_compiler.find_library('jawt', extra_dirs=[str(java_home_lib)])
if jawt is None:
mlog.debug('jawt library not found.')
self.is_found = False
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index cae00844d..4b5d23b03 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -69,7 +69,7 @@ class AtomicSystemDependency(SystemDependency):
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)
- self.link_args = self.clib_compiler.find_library('atomic', env, [], self.libtype)
+ self.link_args = self.clib_compiler.find_library('atomic', [], self.libtype)
if h[0] and self.link_args:
self.is_found = True
@@ -90,7 +90,7 @@ class DlSystemDependency(SystemDependency):
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)
- self.link_args = self.clib_compiler.find_library('dl', env, [], self.libtype)
+ self.link_args = self.clib_compiler.find_library('dl', [], self.libtype)
if h[0] and self.link_args:
self.is_found = True
@@ -194,7 +194,7 @@ class BlocksDependency(SystemDependency):
self.link_args = ['-lBlocksRuntime']
if not self.clib_compiler.has_header('Block.h', '', environment, disable_cache=True) or \
- not self.clib_compiler.find_library('BlocksRuntime', environment, []):
+ not self.clib_compiler.find_library('BlocksRuntime', []):
mlog.log(mlog.red('ERROR:'), 'BlocksRuntime not found.')
return
@@ -317,7 +317,7 @@ class ShadercDependency(SystemDependency):
cc = self.get_compiler()
for lib in libs:
- self.link_args = cc.find_library(lib, environment, [])
+ self.link_args = cc.find_library(lib, [])
if self.link_args is not None:
self.is_found = True
@@ -372,7 +372,7 @@ class CursesSystemDependency(SystemDependency):
# Not sure how else to elegantly break out of both loops
for lib, headers in candidates:
- l = self.clib_compiler.find_library(lib, env, [])
+ l = self.clib_compiler.find_library(lib, [])
if l:
for header in headers:
h = self.clib_compiler.has_header(header, '', env)
@@ -422,7 +422,7 @@ class IconvSystemDependency(SystemDependency):
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)
- self.link_args = self.clib_compiler.find_library('iconv', env, [], self.libtype)
+ self.link_args = self.clib_compiler.find_library('iconv', [], self.libtype)
if h[0] and self.link_args:
self.is_found = True
@@ -444,7 +444,7 @@ class IntlSystemDependency(SystemDependency):
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)
- self.link_args = self.clib_compiler.find_library('intl', env, [], self.libtype)
+ self.link_args = self.clib_compiler.find_library('intl', [], self.libtype)
if h[0] and self.link_args:
self.is_found = True
@@ -483,7 +483,7 @@ class OpensslSystemDependency(SystemDependency):
self.is_found = True
return
else:
- self.link_args = self.clib_compiler.find_library(name.lstrip('lib'), env, [], self.libtype)
+ self.link_args = self.clib_compiler.find_library(name.lstrip('lib'), [], self.libtype)
if not self.link_args:
return
@@ -498,7 +498,7 @@ class OpensslSystemDependency(SystemDependency):
if not use_threads or self._add_sub_dependency(threads_factory(env, self.for_machine, {})):
self.is_found = True
# only relevant on platforms where it is distributed with the libc, in which case it always succeeds
- sublib = self.clib_compiler.find_library('dl', env, [], self.libtype)
+ sublib = self.clib_compiler.find_library('dl', [], self.libtype)
if sublib:
self.link_args.extend(sublib)
diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py
index 326ecb1b4..b628e005b 100644
--- a/mesonbuild/dependencies/pkgconfig.py
+++ b/mesonbuild/dependencies/pkgconfig.py
@@ -488,9 +488,8 @@ class PkgConfigDependency(ExternalDependency):
if lib in libs_found:
continue
if self.clib_compiler:
- args = self.clib_compiler.find_library(lib[2:], self.env,
- libpaths, self.libtype,
- lib_prefix_warning=False)
+ args = self.clib_compiler.find_library(
+ lib[2:], libpaths, self.libtype, lib_prefix_warning=False)
# If the project only uses a non-clib language such as D, Rust,
# C#, Python, etc, all we can do is limp along by adding the
# arguments as-is and then adding the libpaths at the end.
diff --git a/mesonbuild/dependencies/python.py b/mesonbuild/dependencies/python.py
index c204a5197..93b915014 100644
--- a/mesonbuild/dependencies/python.py
+++ b/mesonbuild/dependencies/python.py
@@ -325,7 +325,7 @@ class _PythonDependencyBase(_Base):
libname += self.variables['ABIFLAGS']
libdirs = []
- largs = self.clib_compiler.find_library(libname, environment, libdirs)
+ largs = self.clib_compiler.find_library(libname, libdirs)
if largs is not None:
self.link_args = largs
self.is_found = True
diff --git a/mesonbuild/dependencies/qt.py b/mesonbuild/dependencies/qt.py
index 18e476338..c245e5c8c 100644
--- a/mesonbuild/dependencies/qt.py
+++ b/mesonbuild/dependencies/qt.py
@@ -146,7 +146,7 @@ class _QtBase:
def _link_with_qt_winmain(self, is_debug: bool, libdir: T.Union[str, T.List[str]]) -> bool:
libdir = mesonlib.listify(libdir) # TODO: shouldn't be necessary
base_name = self.get_qt_winmain_base_name(is_debug)
- qt_winmain = self.clib_compiler.find_library(base_name, self.env, libdir)
+ qt_winmain = self.clib_compiler.find_library(base_name, libdir)
if qt_winmain:
self.link_args.append(qt_winmain[0])
return True
@@ -321,7 +321,7 @@ class QmakeQtDependency(_QtBase, ConfigToolDependency, metaclass=abc.ABCMeta):
for directory in priv_inc:
self.compile_args.append('-I' + directory)
libfiles = self.clib_compiler.find_library(
- self.qtpkgname + module + modules_lib_suffix, self.env,
+ self.qtpkgname + module + modules_lib_suffix,
mesonlib.listify(libdir)) # TODO: shouldn't be necessary
if libfiles:
libfile = libfiles[0]
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
index de2a4cf36..663345ee8 100644
--- a/mesonbuild/dependencies/ui.py
+++ b/mesonbuild/dependencies/ui.py
@@ -44,7 +44,7 @@ class GLDependencySystem(SystemDependency):
# FIXME: Detect version using self.clib_compiler
return
else:
- links = self.clib_compiler.find_library('GL', environment, [])
+ links = self.clib_compiler.find_library('GL', [])
has_header = self.clib_compiler.has_header('GL/gl.h', '', environment)[0]
if links and has_header:
self.is_found = True
@@ -199,7 +199,7 @@ class VulkanDependencySystem(SystemDependency):
inc_path = os.path.join(self.vulkan_sdk, inc_dir)
header = os.path.join(inc_path, 'vulkan', 'vulkan.h')
lib_path = os.path.join(self.vulkan_sdk, lib_dir)
- find_lib = self.clib_compiler.find_library(lib_name, environment, [lib_path])
+ find_lib = self.clib_compiler.find_library(lib_name, [lib_path])
if not find_lib:
raise DependencyException('VULKAN_SDK point to invalid directory (no lib)')
@@ -215,7 +215,7 @@ class VulkanDependencySystem(SystemDependency):
self.link_args.append('-l' + lib_name)
else:
# simply try to guess it, usually works on linux
- libs = self.clib_compiler.find_library('vulkan', environment, [])
+ 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]:
self.is_found = True
for lib in libs:
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py
index 5a7a88422..ee9caa2b2 100644
--- a/mesonbuild/interpreter/compiler.py
+++ b/mesonbuild/interpreter/compiler.py
@@ -708,7 +708,7 @@ class CompilerHolder(ObjectHolder['Compiler']):
libtype = mesonlib.LibType.PREFER_STATIC
else:
libtype = mesonlib.LibType.PREFER_SHARED
- linkargs = self.compiler.find_library(libname, self.environment, search_dirs, libtype)
+ linkargs = self.compiler.find_library(libname, search_dirs, libtype)
if required and not linkargs:
if libtype == mesonlib.LibType.PREFER_SHARED:
libtype_s = 'shared or static'
diff --git a/unittests/internaltests.py b/unittests/internaltests.py
index 2a9cc781e..74b36a83e 100644
--- a/unittests/internaltests.py
+++ b/unittests/internaltests.py
@@ -534,7 +534,7 @@ class InternalTests(unittest.TestCase):
kwargs = {'sources': [1, [2, [3]]]}
self.assertEqual([1, 2, 3], extract(kwargs, 'sources'))
- def _test_all_naming(self, cc, env, patterns, platform):
+ def _test_all_naming(self, cc, patterns, platform):
shr = patterns[platform]['shared']
stc = patterns[platform]['static']
shrstc = shr + tuple(x for x in stc if x not in shr)
@@ -559,9 +559,9 @@ class InternalTests(unittest.TestCase):
f.write('int meson_foobar (void) { return 0; }')
subprocess.check_call(['gcc', str(src), '-o', str(libpath), '-shared'])
- found = cc._find_library_real('foo', env, [tmpdir], 'int main(void) { return 0; }', LibType.PREFER_SHARED, lib_prefix_warning=True, ignore_system_dirs=False)
+ found = cc._find_library_real('foo', [tmpdir], 'int main(void) { return 0; }', LibType.PREFER_SHARED, lib_prefix_warning=True, ignore_system_dirs=False)
self.assertEqual(os.path.basename(found[0]), 'libfoo.so.54.0')
- found = cc._find_library_real('bar', env, [tmpdir], 'int main(void) { return 0; }', LibType.PREFER_SHARED, lib_prefix_warning=True, ignore_system_dirs=False)
+ found = cc._find_library_real('bar', [tmpdir], 'int main(void) { return 0; }', LibType.PREFER_SHARED, lib_prefix_warning=True, ignore_system_dirs=False)
self.assertEqual(os.path.basename(found[0]), 'libbar.so.7.10')
def test_find_library_patterns(self):
@@ -588,26 +588,26 @@ class InternalTests(unittest.TestCase):
env = get_fake_env()
cc = detect_c_compiler(env, MachineChoice.HOST)
if is_osx():
- self._test_all_naming(cc, env, patterns, 'darwin')
+ self._test_all_naming(cc, patterns, 'darwin')
elif is_cygwin():
- self._test_all_naming(cc, env, patterns, 'cygwin')
+ self._test_all_naming(cc, patterns, 'cygwin')
elif is_windows():
if cc.get_argument_syntax() == 'msvc':
- self._test_all_naming(cc, env, patterns, 'windows-msvc')
+ self._test_all_naming(cc, patterns, 'windows-msvc')
else:
- self._test_all_naming(cc, env, patterns, 'windows-mingw')
+ self._test_all_naming(cc, patterns, 'windows-mingw')
elif is_openbsd():
- self._test_all_naming(cc, env, patterns, 'openbsd')
+ self._test_all_naming(cc, patterns, 'openbsd')
else:
- self._test_all_naming(cc, env, patterns, 'linux')
+ self._test_all_naming(cc, patterns, 'linux')
env.machines.host.system = 'openbsd'
- self._test_all_naming(cc, env, patterns, 'openbsd')
+ self._test_all_naming(cc, patterns, 'openbsd')
env.machines.host.system = 'darwin'
- self._test_all_naming(cc, env, patterns, 'darwin')
+ self._test_all_naming(cc, patterns, 'darwin')
env.machines.host.system = 'cygwin'
- self._test_all_naming(cc, env, patterns, 'cygwin')
+ self._test_all_naming(cc, patterns, 'cygwin')
env.machines.host.system = 'windows'
- self._test_all_naming(cc, env, patterns, 'windows-mingw')
+ self._test_all_naming(cc, patterns, 'windows-mingw')
@skipIfNoPkgconfig
def test_pkgconfig_parse_libs(self):
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py
index 8ab99d936..15bb36b91 100644
--- a/unittests/linuxliketests.py
+++ b/unittests/linuxliketests.py
@@ -1977,7 +1977,7 @@ class LinuxlikeTests(BasePlatformTests):
env = get_fake_env(testdir, self.builddir, self.prefix)
cpp = detect_cpp_compiler(env, MachineChoice.HOST)
- if cpp.find_library('ubsan', env, []):
+ if cpp.find_library('ubsan', []):
tests += ['address,undefined']
for value in tests: