summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorMichał Górny <mgorny@quansight.com>2025-09-04 15:26:33 +0200
committerDylan Baker <dylan@pnwbakers.com>2025-09-19 08:34:34 -0700
commit5f3d12abc814b9ea99e56ea31b79a4cb3e8411fc (patch)
tree1ab509bb414306a5a3233a4a1e793a7b6bc00d46 /mesonbuild
parent8bba5d0a80ece5c14f5e56468dcf50752fe5d46d (diff)
downloadmeson-5f3d12abc814b9ea99e56ea31b79a4cb3e8411fc.tar.gz
pkgconfig: Fix class cached to be keyed on extra_paths
Add `extra_paths` to cache keys for `PkgConfigInterface` and `PkgConfigCLI` instances, to avoid incorrectly reusing an instance with a different `extra_paths` value, see: https://github.com/mesonbuild/meson/pull/14657#discussion_r2320623799 Signed-off-by: Michał Górny <mgorny@quansight.com>
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/dependencies/pkgconfig.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py
index a0727f60f..012b716f6 100644
--- a/mesonbuild/dependencies/pkgconfig.py
+++ b/mesonbuild/dependencies/pkgconfig.py
@@ -29,8 +29,9 @@ if T.TYPE_CHECKING:
class PkgConfigInterface:
'''Base class wrapping a pkg-config implementation'''
- class_impl: PerMachine[T.Union[Literal[False], T.Optional[PkgConfigInterface]]] = PerMachine(False, False)
- class_cli_impl: PerMachine[T.Union[Literal[False], T.Optional[PkgConfigCLI]]] = PerMachine(False, False)
+ # keyed on machine and extra_paths
+ class_impl: PerMachine[T.Dict[T.Optional[T.Tuple[str, ...]], T.Union[Literal[False], T.Optional[PkgConfigInterface]]]] = PerMachine({}, {})
+ class_cli_impl: PerMachine[T.Dict[T.Optional[T.Tuple[str, ...]], T.Union[Literal[False], T.Optional[PkgConfigCLI]]]] = PerMachine({}, {})
pkg_bin_per_machine: PerMachine[T.Optional[ExternalProgram]] = PerMachine(None, None)
@staticmethod
@@ -45,14 +46,15 @@ class PkgConfigInterface:
extra_paths: T.Optional[T.List[str]] = None) -> T.Optional[PkgConfigInterface]:
'''Return a pkg-config implementation singleton'''
for_machine = for_machine if env.is_cross_build() else MachineChoice.HOST
- impl = PkgConfigInterface.class_impl[for_machine]
+ extra_paths_key = tuple(extra_paths) if extra_paths is not None else None
+ impl = PkgConfigInterface.class_impl[for_machine].get(extra_paths_key, False)
if impl is False:
impl = PkgConfigCLI(env, for_machine, silent, PkgConfigInterface.pkg_bin_per_machine[for_machine], extra_paths)
if not impl.found():
impl = None
if not impl and not silent:
mlog.log('Found pkg-config:', mlog.red('NO'))
- PkgConfigInterface.class_impl[for_machine] = impl
+ PkgConfigInterface.class_impl[for_machine][extra_paths_key] = impl
return impl
@staticmethod
@@ -67,12 +69,13 @@ class PkgConfigInterface:
impl: T.Union[Literal[False], T.Optional[PkgConfigInterface]] # Help confused mypy
impl = PkgConfigInterface.instance(env, for_machine, silent)
if impl and not isinstance(impl, PkgConfigCLI):
- impl = PkgConfigInterface.class_cli_impl[for_machine]
+ extra_paths_key = tuple(extra_paths) if extra_paths is not None else None
+ impl = PkgConfigInterface.class_cli_impl[for_machine].get(extra_paths_key, False)
if impl is False:
impl = PkgConfigCLI(env, for_machine, silent, PkgConfigInterface.pkg_bin_per_machine[for_machine], extra_paths)
if not impl.found():
impl = None
- PkgConfigInterface.class_cli_impl[for_machine] = impl
+ PkgConfigInterface.class_cli_impl[for_machine][extra_paths_key] = impl
return T.cast('T.Optional[PkgConfigCLI]', impl) # Trust me, mypy
@staticmethod