From c7c6e636bd2658b81f8c12a25eaf21ede4bf9f19 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 28 Mar 2024 18:47:27 -0500 Subject: [PATCH] (#23201) libva/2.20.0: Fix discovery of wayland-scanner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * libva/2.20.0: Fix discovery of wayland-scanner Cross-compilation is currently broken for the libva package for Conan V1. It doesn't properly make the wayland package available in the build context through pkg-config. This is necessary for the project to find the wayland-scanner program. I've updated libva to use the same procedure as xkbcommon to incorporate Wayland's pkg-config in the build context. Note that this change is not necessary for Conan version 2.2.1 which works out-of-the-box. * Update recipes/libva/all/conanfile.py Co-authored-by: Rubén Rincón Blanco * Update recipes/libva/all/conanfile.py Co-authored-by: Rubén Rincón Blanco * Update recipes/libva/all/conanfile.py Co-authored-by: Rubén Rincón Blanco * Update recipes/libva/all/conanfile.py Co-authored-by: Martin Valgur --------- Co-authored-by: Rubén Rincón Blanco Co-authored-by: Martin Valgur --- recipes/libva/all/conanfile.py | 39 ++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/recipes/libva/all/conanfile.py b/recipes/libva/all/conanfile.py index 4020db9e7c63e..d92edb9da1d88 100644 --- a/recipes/libva/all/conanfile.py +++ b/recipes/libva/all/conanfile.py @@ -1,15 +1,16 @@ +import os + from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.apple import fix_apple_shared_install_name from conan.tools.env import VirtualBuildEnv -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain -import os -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.60.0 <2 || >=2.0.6" class PackageConan(ConanFile): @@ -37,6 +38,10 @@ class PackageConan(ConanFile): "with_win32": True, } + @property + def _has_build_profile(self): + return hasattr(self, "settings_build") + def export_sources(self): export_conandata_patches(self) @@ -76,9 +81,9 @@ def validate(self): raise ConanInvalidConfiguration(f"{self.ref} can not be built without at least one backend dev files.") def build_requirements(self): - if self.options.get_safe("with_wayland"): - self.tool_requires("wayland/1.22.0") - self.tool_requires("meson/1.3.1") + if self.options.get_safe("with_wayland") and self._has_build_profile: + self.tool_requires("wayland/") + self.tool_requires("meson/1.3.2") if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): self.tool_requires("pkgconf/2.1.0") @@ -90,14 +95,30 @@ def generate(self): tc.project_options["disable_drm"] = not self.options.get_safe("with_drm") for opt in ['with_x11', 'with_glx', 'with_wayland', 'with_win32']: tc.project_options[opt] = "yes" if self.options.get_safe(opt) else "no" + tc.project_options["build.pkg_config_path"] = self.generators_folder tc.generate() - tc = PkgConfigDeps(self) - tc.generate() + pkg_config_deps = PkgConfigDeps(self) + if self.options.get_safe("with_wayland") and self._has_build_profile: + pkg_config_deps.build_context_activated = ["wayland"] + pkg_config_deps.build_context_suffix = {"wayland": "_BUILD"} + pkg_config_deps.generate() tc = VirtualBuildEnv(self) tc.generate() - def build(self): + def _patch_sources(self): apply_conandata_patches(self) + if self.options.get_safe("with_wayland") and self._has_build_profile: + # Patch the build system to use the pkg-config files generated for the build context. + meson_build_file = os.path.join(self.source_folder, "meson.build") + replace_in_file( + self, + meson_build_file, + "wayland_scanner_dep = dependency('wayland-scanner',", + "wayland_scanner_dep = dependency('wayland-scanner_BUILD',", + ) + + def build(self): + self._patch_sources() meson = Meson(self) meson.configure() meson.build()