Skip to content

Commit

Permalink
libva/2.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ericLemanissier committed Dec 14, 2023
1 parent 04d8063 commit e35522d
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 0 deletions.
4 changes: 4 additions & 0 deletions recipes/libva/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.20.0":
url: "https://github.com/intel/libva/releases/download/2.20.0/libva-2.20.0.tar.bz2"
sha256: "f72bdb4f48dfe71ad01f1cbefe069672a2c949a6abd51cf3c4d4784210badc49"
140 changes: 140 additions & 0 deletions recipes/libva/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
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 copy, get, 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"


class PackageConan(ConanFile):
name = "libva"
description = "Libva is an implementation for VA-API"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/intel/libva"
topics = ("VA-API", "Video", "Acceleration")
provides = "vaapi"
package_type = "shared-library"
settings = "os", "arch", "compiler", "build_type"
options = {
"with_drm": [True, False],
"with_x11": [True, False],
"with_glx": [True, False],
"with_wayland": [True, False],
"with_win32": [True, False],
}
default_options = {
"with_drm": True,
"with_x11": True,
"with_glx": True,
"with_wayland": True,
"with_win32": True,
}

def config_options(self):
if self.settings.os != "Windows":
del self.options.with_win32

if self.settings.os not in ["Linux", "FreeBSD"]:
del self.options.with_x11
del self.options.with_glx
del self.options.with_drm

if self.settings.os != "Linux":
del self.options.with_wayland

def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
if self.options.get_safe("with_x11"):
self.requires("xorg/system")
if self.options.get_safe("with_drm"):
self.requires("libdrm/2.4.114")
if self.options.get_safe("with_wayland"):
self.requires("wayland/1.22.0")
if self.options.get_safe("with_glx"):
self.requires("opengl/system")

def validate(self):
if self.options.get_safe("with_glx") and not self.options.get_safe("with_x11"):
raise ConanInvalidConfiguration(f"{self.ref} needs x11 or glx")
if not self.options.get_safe("with_drm") and not self.options.get_safe("with_x11") and not self.options.get_safe("with_wayland") and not self.options.get_safe("with_win32"):
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.2.3")
if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str):
self.tool_requires("pkgconf/2.0.3")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = MesonToolchain(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.generate()
tc = PkgConfigDeps(self)
tc.generate()
tc = VirtualBuildEnv(self)
tc.generate()

def build(self):
meson = Meson(self)
meson.configure()
meson.build()

def package(self):
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses"))
meson = Meson(self)
meson.install()

rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))

fix_apple_shared_install_name(self)

def package_info(self):
self.cpp_info.components["libva_"].libs = ["va"]
self.cpp_info.components["libva_"].set_property("pkg_config_name", "libva")

if self.options.get_safe("with_drm"):
self.cpp_info.components["libva-drm"].libs = ["va-drm"]
self.cpp_info.components["libva-drm"].set_property("pkg_config_name", "libva-drm")
self.cpp_info.components["libva-drm"].requires = ["libva_", "libdrm::libdrm"]

if self.options.get_safe("with_x11"):
self.cpp_info.components["libva-x11"].libs = ["va-x11"]
self.cpp_info.components["libva-x11"].set_property("pkg_config_name", "libva-x11")
self.cpp_info.components["libva-x11"].requires = ["libva_", "xorg::xorg"]

if self.options.get_safe("with_glx"):
self.cpp_info.components["libva-glx"].libs = ["va-glx"]
self.cpp_info.components["libva-glx"].set_property("pkg_config_name", "libva-glx")
self.cpp_info.components["libva-glx"].requires = ["libva_", "opengl::opengl"]

if self.options.get_safe("with_wayland"):
self.cpp_info.components["libva-wayland"].libs = ["va-wayland"]
self.cpp_info.components["libva-wayland"].set_property("pkg_config_name", "libva-wayland")
self.cpp_info.components["libva-wayland"].requires = ["libva_", "wayland::wayland-client"]

if self.options.get_safe("with_win32"):
self.cpp_info.components["libva-win32"].libs = ["va-win32"]
self.cpp_info.components["libva-win32"].set_property("pkg_config_name", "libva-win32")
self.cpp_info.components["libva-win32"].requires = ["libva_"]
7 changes: 7 additions & 0 deletions recipes/libva/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

find_package(libva REQUIRED CONFIG)

add_executable(test_package test_package.c)
target_link_libraries(test_package PRIVATE libva::libva)
26 changes: 26 additions & 0 deletions recipes/libva/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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 = "CMakeToolchain", "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv"

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 cross_building(self):
cmd = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(cmd, env="conanrun")
10 changes: 10 additions & 0 deletions recipes/libva/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <va/va.h>

#include <stdio.h>

int main()
{
VADisplay va_display;
printf("Display is valid: %d", vaDisplayIsValid(0));
return 0;
}
3 changes: 3 additions & 0 deletions recipes/libva/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.20.0":
folder: all

0 comments on commit e35522d

Please sign in to comment.