summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-11-12 09:53:44 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-11-19 10:48:48 -0800
commite8286ab9a102823cb256bd859de1a9082679e79b (patch)
treedd8d0a28523484878c920b46a891b2440f0b925a
parentcd4293b54a624026dcbc289b22fde9ef37b8c7eb (diff)
downloadmeson-e8286ab9a102823cb256bd859de1a9082679e79b.tar.gz
compilers: Remove Environment parameter from Compiler.get_library_dirs
-rw-r--r--mesonbuild/backend/backends.py2
-rw-r--r--mesonbuild/backend/ninjabackend.py6
-rw-r--r--mesonbuild/build.py2
-rw-r--r--mesonbuild/compilers/compilers.py3
-rw-r--r--mesonbuild/compilers/mixins/clike.py12
-rw-r--r--mesonbuild/compilers/mixins/elbrus.py2
-rw-r--r--mesonbuild/dependencies/boost.py2
7 files changed, 13 insertions, 16 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 7ddf4558b..6ebdbc829 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -1064,7 +1064,7 @@ class Backend:
if isinstance(target, build.BuildTarget):
for cc in target.compilers.values():
paths.update(cc.get_program_dirs(self.environment))
- paths.update(cc.get_library_dirs(self.environment))
+ paths.update(cc.get_library_dirs())
return list(paths)
@staticmethod
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 71bda303e..8ff13a742 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -3448,8 +3448,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
def get_import_filename(self, target) -> str:
return os.path.join(self.get_target_dir(target), target.import_filename)
- def get_target_type_link_args(self, target, linker):
- commands = []
+ def get_target_type_link_args(self, target: build.BuildTarget, linker: Compiler):
+ commands: T.List[str] = []
if isinstance(target, build.Executable):
# Currently only used with the Swift compiler to add '-emit-executable'
commands += linker.get_std_exe_link_args()
@@ -3582,7 +3582,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
try:
static_patterns = linker.get_library_naming(self.environment, LibType.STATIC, strict=True)
shared_patterns = linker.get_library_naming(self.environment, LibType.SHARED, strict=True)
- search_dirs = tuple(search_dirs) + tuple(linker.get_library_dirs(self.environment))
+ search_dirs = tuple(search_dirs) + tuple(linker.get_library_dirs())
for libname in libs:
# be conservative and record most likely shared and static resolution, because we don't know exactly
# which one the linker will prefer
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 0ad679450..7562fea53 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1838,7 +1838,7 @@ class BuildTarget(Target):
system_dirs = set()
if exclude_system:
for cc in self.compilers.values():
- system_dirs.update(cc.get_library_dirs(self.environment))
+ system_dirs.update(cc.get_library_dirs())
external_rpaths = self.get_external_rpath_dirs()
build_to_src = relpath(self.environment.get_source_dir(),
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 5486b5d7e..3ef45de8f 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1171,8 +1171,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
# those features explicitly.
return []
- def get_library_dirs(self, env: 'Environment',
- elf_class: T.Optional[int] = None) -> T.List[str]:
+ def get_library_dirs(self, elf_class: T.Optional[int] = None) -> T.List[str]:
return []
def get_return_value(self,
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 6967362b6..65933a6b5 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -193,10 +193,9 @@ class CLikeCompiler(Compiler):
return []
@functools.lru_cache()
- def _get_library_dirs(self, env: 'Environment',
- elf_class: T.Optional[int] = None) -> 'ImmutableListProtocol[str]':
+ def _get_library_dirs(self, elf_class: T.Optional[int] = None) -> 'ImmutableListProtocol[str]':
# TODO: replace elf_class with enum
- dirs = self.get_compiler_dirs(env, 'libraries')
+ dirs = self.get_compiler_dirs(self.environment, 'libraries')
if elf_class is None or elf_class == 0:
return dirs
@@ -232,12 +231,11 @@ class CLikeCompiler(Compiler):
return retval
- def get_library_dirs(self, env: 'Environment',
- elf_class: T.Optional[int] = None) -> T.List[str]:
+ def get_library_dirs(self, elf_class: T.Optional[int] = None) -> T.List[str]:
"""Wrap the lru_cache so that we return a new copy and don't allow
mutation of the cached value.
"""
- return self._get_library_dirs(env, elf_class).copy()
+ return self._get_library_dirs(elf_class).copy()
@functools.lru_cache()
def _get_program_dirs(self, env: 'Environment') -> 'ImmutableListProtocol[str]':
@@ -1163,7 +1161,7 @@ class CLikeCompiler(Compiler):
# Search in the specified dirs, and then in the system libraries
largs = self.get_linker_always_args() + self.get_allow_undefined_link_args()
lcargs = self.linker_to_compiler_args(largs)
- for d in itertools.chain(extra_dirs, [] if ignore_system_dirs else self.get_library_dirs(env, elf_class)):
+ for d in itertools.chain(extra_dirs, [] if ignore_system_dirs else self.get_library_dirs(elf_class)):
for p in patterns:
trials = self._get_trials_from_pattern(p, d, libname)
if not trials:
diff --git a/mesonbuild/compilers/mixins/elbrus.py b/mesonbuild/compilers/mixins/elbrus.py
index 7037db232..978a565ed 100644
--- a/mesonbuild/compilers/mixins/elbrus.py
+++ b/mesonbuild/compilers/mixins/elbrus.py
@@ -39,7 +39,7 @@ class ElbrusCompiler(GnuLikeCompiler):
# FIXME: use _build_wrapper to call this so that linker flags from the env
# get applied
- def get_library_dirs(self, env: 'Environment', elf_class: T.Optional[int] = None) -> T.List[str]:
+ def get_library_dirs(self, elf_class: T.Optional[int] = None) -> T.List[str]:
os_env = os.environ.copy()
os_env['LC_ALL'] = 'C'
stdo = Popen_safe(self.get_exelist(ccache=False) + ['--print-search-dirs'], env=os_env)[1]
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
index 517d1e832..1aeb451f1 100644
--- a/mesonbuild/dependencies/boost.py
+++ b/mesonbuild/dependencies/boost.py
@@ -557,7 +557,7 @@ class BoostDependency(SystemDependency):
# given root path
if use_system:
- system_dirs_t = self.clib_compiler.get_library_dirs(self.env)
+ system_dirs_t = self.clib_compiler.get_library_dirs()
system_dirs = [Path(x) for x in system_dirs_t]
system_dirs = [x.resolve() for x in system_dirs if x.exists()]
system_dirs = [x for x in system_dirs if mesonlib.path_is_in_root(x, root)]