[DO-971] ffmpeg recipe with requirements (!9)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech> Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/9
This commit is contained in:
13
recipes/dav1d/all/conandata.yml
Normal file
13
recipes/dav1d/all/conandata.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
sources:
|
||||
"1.4.3":
|
||||
url: "http://code.videolan.org/videolan/dav1d/-/archive/1.4.3/dav1d-1.4.3.tar.gz"
|
||||
sha256: "88a023e58d955e0886faf49c72940e0e90914a948a8e60c1326ce3e09e7a6099"
|
||||
"1.4.1":
|
||||
url: "http://code.videolan.org/videolan/dav1d/-/archive/1.4.1/dav1d-1.4.1.tar.gz"
|
||||
sha256: "8d407dd5fe7986413c937b14e67f36aebd06e1fa5cfec679d10e548476f2d5f8"
|
||||
"1.3.0":
|
||||
url: "http://code.videolan.org/videolan/dav1d/-/archive/1.3.0/dav1d-1.3.0.tar.gz"
|
||||
sha256: "6d8be2741c505c47f8f1ced3c9cc427759243436553d01d1acce201f87b39e71"
|
||||
"1.2.1":
|
||||
url: "http://code.videolan.org/videolan/dav1d/-/archive/1.2.1/dav1d-1.2.1.tar.gz"
|
||||
sha256: "4e33eb61ec54c768a16da0cf8fa0928b4c4593f5f804a3c887d4a21c318340b2"
|
||||
128
recipes/dav1d/all/conanfile.py
Normal file
128
recipes/dav1d/all/conanfile.py
Normal file
@@ -0,0 +1,128 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.apple import fix_apple_shared_install_name
|
||||
from conan.tools.env import VirtualBuildEnv
|
||||
from conan.tools.files import copy, get, replace_in_file, rm, rmdir
|
||||
from conan.tools.layout import basic_layout
|
||||
from conan.tools.meson import Meson, MesonToolchain
|
||||
from conan.tools.microsoft import is_msvc
|
||||
import os
|
||||
|
||||
required_conan_version = ">=1.53.0"
|
||||
|
||||
|
||||
class Dav1dConan(ConanFile):
|
||||
name = "dav1d"
|
||||
description = "dav1d is a new AV1 cross-platform decoder, open-source, and focused on speed, size and correctness."
|
||||
homepage = "https://www.videolan.org/projects/dav1d.html"
|
||||
topics = ("av1", "codec", "video", "decoding")
|
||||
license = "BSD-2-Clause"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"bit_depth": ["all", 8, 16],
|
||||
"with_tools": [True, False],
|
||||
"assembly": [True, False],
|
||||
"with_avx512": ["deprecated", True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"bit_depth": "all",
|
||||
"with_tools": True,
|
||||
"assembly": True,
|
||||
"with_avx512": "deprecated",
|
||||
}
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
if is_msvc(self) and self.settings.build_type == "Debug":
|
||||
# debug builds with assembly often causes linker hangs or LNK1000
|
||||
self.options.assembly = False
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
|
||||
def layout(self):
|
||||
basic_layout(self, src_folder="src")
|
||||
|
||||
def package_id(self):
|
||||
del self.info.options.with_avx512
|
||||
|
||||
def validate(self):
|
||||
if self.options.with_avx512 != "deprecated":
|
||||
self.output.warning("The 'with_avx512' option is deprecated and has no effect")
|
||||
|
||||
def build_requirements(self):
|
||||
# self.tool_requires("meson/1.4.0")
|
||||
if self.options.assembly:
|
||||
self.tool_requires("nasm/2.16.01")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
env = VirtualBuildEnv(self)
|
||||
env.generate()
|
||||
|
||||
tc = MesonToolchain(self)
|
||||
tc.project_options["enable_tests"] = False
|
||||
tc.project_options["enable_asm"] = self.options.assembly
|
||||
tc.project_options["enable_tools"] = self.options.with_tools
|
||||
if self.options.bit_depth == "all":
|
||||
tc.project_options["bitdepths"] = "8,16"
|
||||
else:
|
||||
tc.project_options["bitdepths"] = str(self.options.bit_depth)
|
||||
tc.generate()
|
||||
|
||||
def _patch_sources(self):
|
||||
replace_in_file(self, os.path.join(self.source_folder, "meson.build"),
|
||||
"subdir('doc')", "")
|
||||
|
||||
def build(self):
|
||||
self._patch_sources()
|
||||
meson = Meson(self)
|
||||
meson.configure()
|
||||
meson.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
meson = Meson(self)
|
||||
meson.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
|
||||
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
|
||||
fix_apple_shared_install_name(self)
|
||||
fix_msvc_libname(self)
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("pkg_config_name", "dav1d")
|
||||
self.cpp_info.libs = ["dav1d"]
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.system_libs.extend(["dl", "pthread"])
|
||||
|
||||
# TODO: to remove in conan v2
|
||||
if self.options.with_tools:
|
||||
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
|
||||
|
||||
def fix_msvc_libname(conanfile, remove_lib_prefix=True):
|
||||
"""remove lib prefix & change extension to .lib in case of cl like compiler"""
|
||||
from conan.tools.files import rename
|
||||
import glob
|
||||
if not conanfile.settings.get_safe("compiler.runtime"):
|
||||
return
|
||||
libdirs = getattr(conanfile.cpp.package, "libdirs")
|
||||
for libdir in libdirs:
|
||||
for ext in [".dll.a", ".dll.lib", ".a"]:
|
||||
full_folder = os.path.join(conanfile.package_folder, libdir)
|
||||
for filepath in glob.glob(os.path.join(full_folder, f"*{ext}")):
|
||||
libname = os.path.basename(filepath)[0:-len(ext)]
|
||||
if remove_lib_prefix and libname[0:3] == "lib":
|
||||
libname = libname[3:]
|
||||
rename(conanfile, filepath, os.path.join(os.path.dirname(filepath), f"{libname}.lib"))
|
||||
7
recipes/dav1d/all/test_package/CMakeLists.txt
Normal file
7
recipes/dav1d/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C)
|
||||
|
||||
find_package(dav1d REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE dav1d::dav1d)
|
||||
26
recipes/dav1d/all/test_package/conanfile.py
Normal file
26
recipes/dav1d/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from conan import ConanFile
|
||||
from conan.tools.build import can_run
|
||||
from conan.tools.cmake import CMake, cmake_layout
|
||||
import os
|
||||
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
|
||||
test_type = "explicit"
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
|
||||
self.run(bin_path, env="conanrun")
|
||||
9
recipes/dav1d/all/test_package/test_package.c
Normal file
9
recipes/dav1d/all/test_package/test_package.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "dav1d/dav1d.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("dav1d version: %s\n", dav1d_version());
|
||||
return 0;
|
||||
}
|
||||
9
recipes/dav1d/config.yml
Normal file
9
recipes/dav1d/config.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
versions:
|
||||
"1.4.3":
|
||||
folder: "all"
|
||||
"1.4.1":
|
||||
folder: "all"
|
||||
"1.3.0":
|
||||
folder: "all"
|
||||
"1.2.1":
|
||||
folder: "all"
|
||||
Reference in New Issue
Block a user