[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:
33
recipes/libsndfile/all/conandata.yml
Normal file
33
recipes/libsndfile/all/conandata.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
sources:
|
||||
"1.2.2":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libsndfile/libsndfile/releases/download/1.2.2/libsndfile-1.2.2.tar.xz"
|
||||
sha256: "3799ca9924d3125038880367bf1468e53a1b7e3686a934f098b7e1d286cdb80e"
|
||||
"1.2.0":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libsndfile/libsndfile/releases/download/1.2.0/libsndfile-1.2.0.tar.xz"
|
||||
sha256: "0e30e7072f83dc84863e2e55f299175c7e04a5902ae79cfb99d4249ee8f6d60a"
|
||||
"1.0.31":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libsndfile/libsndfile/releases/download/1.0.31/libsndfile-1.0.31.tar.bz2"
|
||||
sha256: "a8cfb1c09ea6e90eff4ca87322d4168cdbe5035cb48717b40bf77e751cc02163"
|
||||
"1.0.30":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libsndfile/libsndfile/releases/download/v1.0.30/libsndfile-1.0.30.tar.bz2"
|
||||
sha256: "9df273302c4fa160567f412e10cc4f76666b66281e7ba48370fb544e87e4611a"
|
||||
"1.0.29":
|
||||
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/libsndfile/libsndfile/releases/download/v1.0.29/libsndfile-1.0.29.tar.bz2"
|
||||
sha256: "2ba20d44817c8176f097ab25eff44ef0aeec9e00973def5a7174c5ae0764b22f"
|
||||
patches:
|
||||
"1.2.2":
|
||||
- patch_file: "patches/1.0.31-0001-fix-msvc-runtime-logic.patch"
|
||||
patch_description: "always set CMP0091"
|
||||
patch_type: "portability"
|
||||
"1.2.0":
|
||||
- patch_file: "patches/1.0.31-0001-fix-msvc-runtime-logic.patch"
|
||||
patch_description: "always set CMP0091"
|
||||
patch_type: "portability"
|
||||
"1.0.31":
|
||||
- patch_file: "patches/1.0.31-0001-fix-msvc-runtime-logic.patch"
|
||||
patch_description: "always set CMP0091"
|
||||
patch_type: "portability"
|
||||
"1.0.30":
|
||||
- patch_file: "patches/1.0.30-0001-disable-static-libgcc-mingw.patch"
|
||||
patch_description: "disable link libgcc statically on MINGW"
|
||||
patch_type: "portability"
|
||||
151
recipes/libsndfile/all/conanfile.py
Normal file
151
recipes/libsndfile/all/conanfile.py
Normal file
@@ -0,0 +1,151 @@
|
||||
from conan import ConanFile
|
||||
from conan.errors import ConanInvalidConfiguration
|
||||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
|
||||
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
|
||||
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
|
||||
from conan.tools.scm import Version
|
||||
import os
|
||||
|
||||
required_conan_version = ">=1.54.0"
|
||||
|
||||
|
||||
class LibsndfileConan(ConanFile):
|
||||
name = "libsndfile"
|
||||
license = "LGPL-2.1"
|
||||
url = "https://github.com/conan-io/conan-center-index"
|
||||
homepage = "http://www.mega-nerd.com/libsndfile"
|
||||
description = (
|
||||
"Libsndfile is a library of C routines for reading and writing files "
|
||||
"containing sampled audio data."
|
||||
)
|
||||
topics = ("audio",)
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"programs": [True, False],
|
||||
"experimental": [True, False],
|
||||
"with_alsa": [True, False],
|
||||
"with_external_libs": [True, False],
|
||||
"with_mpeg": [True, False],
|
||||
"with_sndio": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"programs": True,
|
||||
"experimental": False,
|
||||
"with_alsa": False,
|
||||
"with_external_libs": True,
|
||||
"with_mpeg": True,
|
||||
"with_sndio": False,
|
||||
}
|
||||
|
||||
def export_sources(self):
|
||||
export_conandata_patches(self)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
del self.options.with_alsa
|
||||
if Version(self.version) < "1.1.0":
|
||||
del self.options.with_mpeg
|
||||
|
||||
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 validate(self):
|
||||
if self.options.with_sndio:
|
||||
if self.dependencies["libsndio"].options.get_safe("with_alsa") and not self.options.get_safe("with_alsa"):
|
||||
raise ConanInvalidConfiguration(f"{self.ref} 'with_alsa' option should be True when the libsndio 'with_alsa' one is True")
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def requirements(self):
|
||||
if self.options.with_sndio:
|
||||
self.requires("libsndio/1.9.0", options={"with_alsa": self.options.get_safe("with_alsa")})
|
||||
if self.options.get_safe("with_alsa"):
|
||||
self.requires("libalsa/1.2.10")
|
||||
if self.options.with_external_libs:
|
||||
self.requires("ogg/1.3.5")
|
||||
self.requires("vorbis/1.3.7")
|
||||
self.requires("flac/1.4.2")
|
||||
self.requires("opus/1.4")
|
||||
if self.options.get_safe("with_mpeg"):
|
||||
self.requires("mpg123/1.31.2")
|
||||
self.requires("libmp3lame/3.100")
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing speex cci recipe (check whether it is really required)
|
||||
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_SQLite3"] = True # only used for regtest
|
||||
tc.variables["ENABLE_EXTERNAL_LIBS"] = self.options.with_external_libs
|
||||
if not self.options.with_external_libs:
|
||||
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Ogg"] = True
|
||||
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Vorbis"] = True
|
||||
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_FLAC"] = True
|
||||
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Opus"] = True
|
||||
if not self.options.get_safe("with_alsa", False):
|
||||
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_ALSA"] = True
|
||||
tc.variables["BUILD_PROGRAMS"] = self.options.programs
|
||||
tc.variables["BUILD_EXAMPLES"] = False
|
||||
tc.variables["BUILD_TESTING"] = False
|
||||
tc.variables["ENABLE_CPACK"] = False
|
||||
tc.variables["ENABLE_EXPERIMENTAL"] = self.options.experimental
|
||||
if is_msvc(self) and Version(self.version) < "1.0.30":
|
||||
tc.variables["ENABLE_STATIC_RUNTIME"] = is_msvc_static_runtime(self)
|
||||
tc.variables["BUILD_REGTEST"] = False
|
||||
# https://github.com/libsndfile/libsndfile/commit/663a59aa6ea5e24cf5159b8e1c2b0735712ea74e#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20a
|
||||
if Version(self.version) >= "1.1.0":
|
||||
tc.variables["ENABLE_MPEG"] = self.options.with_mpeg
|
||||
# Fix iOS/tvOS/watchOS
|
||||
tc.variables["CMAKE_MACOSX_BUNDLE"] = False
|
||||
tc.generate()
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
|
||||
def build(self):
|
||||
apply_conandata_patches(self)
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
|
||||
rmdir(self, os.path.join(self.package_folder, "cmake"))
|
||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
|
||||
rmdir(self, os.path.join(self.package_folder, "share"))
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.set_property("cmake_file_name", "SndFile")
|
||||
self.cpp_info.set_property("cmake_target_name", "SndFile::sndfile")
|
||||
self.cpp_info.set_property("pkg_config_name", "sndfile")
|
||||
self.cpp_info.libs = ["sndfile"]
|
||||
if self.options.with_sndio:
|
||||
self.cpp_info.requires.append("libsndio::libsndio")
|
||||
if self.options.with_external_libs:
|
||||
self.cpp_info.requires.extend([
|
||||
"ogg::ogg", "vorbis::vorbismain", "vorbis::vorbisenc",
|
||||
"flac::flac", "opus::opus",
|
||||
])
|
||||
if self.options.get_safe("with_mpeg", False):
|
||||
self.cpp_info.requires.append("mpg123::mpg123")
|
||||
self.cpp_info.requires.append("libmp3lame::libmp3lame")
|
||||
if self.options.get_safe("with_alsa"):
|
||||
self.cpp_info.requires.append("libalsa::libalsa")
|
||||
if not self.options.shared:
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.system_libs = ["m", "dl", "pthread", "rt"]
|
||||
elif self.settings.os == "Windows":
|
||||
self.cpp_info.system_libs.append("winmm")
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/cmake/SndFileChecks.cmake
|
||||
+++ b/cmake/SndFileChecks.cmake
|
||||
@@ -213,7 +213,7 @@ if (MSVC)
|
||||
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
endif (MSVC)
|
||||
|
||||
-if (MINGW)
|
||||
+if (FALSE)
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL GNU)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s")
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -8,7 +8,7 @@ if (POLICY CMP0091)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
- if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||
+ if (1)
|
||||
cmake_policy (SET CMP0091 NEW)
|
||||
else ()
|
||||
cmake_policy (SET CMP0091 OLD)
|
||||
10
recipes/libsndfile/all/test_package/CMakeLists.txt
Normal file
10
recipes/libsndfile/all/test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(test_package LANGUAGES C CXX)
|
||||
|
||||
find_package(SndFile REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME}_c test_package.c)
|
||||
target_link_libraries(${PROJECT_NAME}_c PRIVATE SndFile::sndfile)
|
||||
|
||||
add_executable(${PROJECT_NAME}_cxx test_package.cpp)
|
||||
target_link_libraries(${PROJECT_NAME}_cxx PRIVATE SndFile::sndfile)
|
||||
28
recipes/libsndfile/all/test_package/conanfile.py
Normal file
28
recipes/libsndfile/all/test_package/conanfile.py
Normal file
@@ -0,0 +1,28 @@
|
||||
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.bindir, "test_package_c")
|
||||
self.run(bin_path, env="conanrun")
|
||||
bin_path = os.path.join(self.cpp.build.bindir, "test_package_cxx")
|
||||
self.run(bin_path, env="conanrun")
|
||||
14
recipes/libsndfile/all/test_package/test_package.c
Normal file
14
recipes/libsndfile/all/test_package/test_package.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "sndfile.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 2) {
|
||||
puts("Usage: example <file.wav>\n");
|
||||
return 0;
|
||||
}
|
||||
SF_INFO sfinfo;
|
||||
SNDFILE *infile = sf_open (argv[1], SFM_READ, &sfinfo);
|
||||
printf("Sample rate: %d\n", sfinfo.samplerate);
|
||||
return 0;
|
||||
}
|
||||
17
recipes/libsndfile/all/test_package/test_package.cpp
Normal file
17
recipes/libsndfile/all/test_package/test_package.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "sndfile.hh"
|
||||
|
||||
#if __cplusplus < 201100 && defined(_MSC_VER)
|
||||
#undef nullptr
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 2) {
|
||||
std::cout << "Usage: example <file.wav>\n";
|
||||
return 0;
|
||||
}
|
||||
SndfileHandle handle(argv[1]);
|
||||
std::cout << "Sample rate: " << handle.samplerate() << "\n";
|
||||
return 0;
|
||||
}
|
||||
11
recipes/libsndfile/config.yml
Normal file
11
recipes/libsndfile/config.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
versions:
|
||||
"1.2.2":
|
||||
folder: "all"
|
||||
"1.2.0":
|
||||
folder: "all"
|
||||
"1.0.31":
|
||||
folder: "all"
|
||||
"1.0.30":
|
||||
folder: "all"
|
||||
"1.0.29":
|
||||
folder: "all"
|
||||
Reference in New Issue
Block a user