From 4d283fec6ed857f924e9274e138f50871b43108a Mon Sep 17 00:00:00 2001 From: ericLemanissier Date: Tue, 14 Mar 2023 09:16:53 +0100 Subject: [PATCH] (#16464) vaapi: conan V2 compatibility * vaapi: conan V2 compatibility * Update conanfile.py * fix conan V2 test --- recipes/vaapi/all/conanfile.py | 35 +++++-------------- recipes/vaapi/all/test_package/CMakeLists.txt | 12 +++---- recipes/vaapi/all/test_package/conanfile.py | 19 +++++++--- .../vaapi/all/test_v1_package/CMakeLists.txt | 10 ++++++ .../vaapi/all/test_v1_package/conanfile.py | 18 ++++++++++ 5 files changed, 56 insertions(+), 38 deletions(-) create mode 100644 recipes/vaapi/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/vaapi/all/test_v1_package/conanfile.py diff --git a/recipes/vaapi/all/conanfile.py b/recipes/vaapi/all/conanfile.py index 756d5ef4595be..957b4cfa16911 100644 --- a/recipes/vaapi/all/conanfile.py +++ b/recipes/vaapi/all/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile -from conan.errors import ConanInvalidConfiguration, ConanException +from conan.errors import ConanInvalidConfiguration +from conan.tools.gnu import PkgConfig from conan.tools.system import package_manager -from conans import tools required_conan_version = ">=1.47" @@ -21,27 +21,9 @@ def validate(self): raise ConanInvalidConfiguration("This recipe supports only Linux and FreeBSD") def package_id(self): - self.info.header_only() - - def _fill_cppinfo_from_pkgconfig(self, name): - pkg_config = tools.PkgConfig(name) - if not pkg_config.provides: - raise ConanException("VAAPI development files aren't available, give up") - libs = [lib[2:] for lib in pkg_config.libs_only_l] - lib_dirs = [lib[2:] for lib in pkg_config.libs_only_L] - ldflags = [flag for flag in pkg_config.libs_only_other] - include_dirs = [include[2:] for include in pkg_config.cflags_only_I] - cflags = [flag for flag in pkg_config.cflags_only_other if not flag.startswith("-D")] - defines = [flag[2:] for flag in pkg_config.cflags_only_other if flag.startswith("-D")] - - self.cpp_info.system_libs.extend(libs) - self.cpp_info.libdirs.extend(lib_dirs) - self.cpp_info.sharedlinkflags.extend(ldflags) - self.cpp_info.exelinkflags.extend(ldflags) - self.cpp_info.defines.extend(defines) - self.cpp_info.includedirs.extend(include_dirs) - self.cpp_info.cflags.extend(cflags) - self.cpp_info.cxxflags.extend(cflags) + del self.info.settings.compiler + del self.info.settings.arch + del self.info.settings.build_type def system_requirements(self): dnf = package_manager.Dnf(self) @@ -63,8 +45,9 @@ def system_requirements(self): pkg.install(["libva"], update=True, check=True) def package_info(self): - self.cpp_info.includedirs = [] - self.cpp_info.libdirs = [] if self.settings.os in ["Linux", "FreeBSD"]: for name in ['libva', 'libva-x11', 'libva-drm']: - self._fill_cppinfo_from_pkgconfig(name) + pkg_config = PkgConfig(self, name) + self.cpp_info.components[name].includedirs = [] + self.cpp_info.components[name].libdirs = [] + pkg_config.fill_cpp_info(self.cpp_info.components[name]) diff --git a/recipes/vaapi/all/test_package/CMakeLists.txt b/recipes/vaapi/all/test_package/CMakeLists.txt index 950b4165b7aa4..1cc7d1fad52a6 100644 --- a/recipes/vaapi/all/test_package/CMakeLists.txt +++ b/recipes/vaapi/all/test_package/CMakeLists.txt @@ -1,10 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package) +project(test_package LANGUAGES C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(xorg REQUIRED CONFIG) +find_package(vaapi REQUIRED CONFIG) -set(SOURCES test_package.c) - -add_executable(${PROJECT_NAME} ${SOURCES}) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_executable(test_package test_package.c) +target_link_libraries(test_package PRIVATE vaapi::vaapi xorg::xorg) diff --git a/recipes/vaapi/all/test_package/conanfile.py b/recipes/vaapi/all/test_package/conanfile.py index 1b482d65b9b4e..e81d71833c5a3 100644 --- a/recipes/vaapi/all/test_package/conanfile.py +++ b/recipes/vaapi/all/test_package/conanfile.py @@ -1,18 +1,27 @@ -from conans import ConanFile, CMake, tools import os +from conan import ConanFile +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, cmake_layout + class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" requires = ("xorg/system",) + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + def build(self): cmake = CMake(self) cmake.configure() cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if not cross_building(self): + cmd = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(cmd, env="conanrun") diff --git a/recipes/vaapi/all/test_v1_package/CMakeLists.txt b/recipes/vaapi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..2f5bce0e6460d --- /dev/null +++ b/recipes/vaapi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +set(SOURCES ../test_package/test_package.c) + +add_executable(${PROJECT_NAME} ${SOURCES}) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/vaapi/all/test_v1_package/conanfile.py b/recipes/vaapi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..1b482d65b9b4e --- /dev/null +++ b/recipes/vaapi/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + requires = ("xorg/system",) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True)