From 32af71f85f7eba55781e8404f2742a2c434f8c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 9 Oct 2024 16:37:31 +0200 Subject: [PATCH] pkgconfig: Fix machine selection for is_build_only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Håvard Sørbø --- mesonbuild/dependencies/pkgconfig.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py index 30e3d2896d46..42b0d83011c7 100644 --- a/mesonbuild/dependencies/pkgconfig.py +++ b/mesonbuild/dependencies/pkgconfig.py @@ -33,7 +33,10 @@ class PkgConfigInterface: @staticmethod def instance(env: Environment, for_machine: MachineChoice, silent: bool) -> T.Optional[PkgConfigInterface]: '''Return a pkg-config implementation singleton''' - for_machine = for_machine if env.is_cross_build() else MachineChoice.HOST + if env.coredata.is_build_only: + for_machine = MachineChoice.BUILD + else: + for_machine = for_machine if env.is_cross_build() else MachineChoice.HOST impl = PkgConfigInterface.class_impl[for_machine] if impl is False: impl = PkgConfigCLI(env, for_machine, silent) @@ -50,7 +53,10 @@ def _cli(env: Environment, for_machine: MachineChoice, silent: bool = False) -> Even when we use another implementation internally, external tools might still need the CLI implementation. ''' - for_machine = for_machine if env.is_cross_build() else MachineChoice.HOST + if env.coredata.is_build_only: + for_machine = MachineChoice.BUILD + else: + for_machine = for_machine if env.is_cross_build() else MachineChoice.HOST 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):