[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:
Aleksandr Vodyanov
2024-12-25 17:47:28 +03:00
parent e58f90de0e
commit 39afe6a1dd
212 changed files with 9263 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
sources:
"1.4.3":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/flac/releases/download/1.4.3/flac-1.4.3.tar.xz"
sha256: "6c58e69cd22348f441b861092b825e591d0b822e106de6eb0ee4d05d27205b70"
"1.4.2":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/flac/releases/download/1.4.2/flac-1.4.2.tar.xz"
sha256: "e322d58a1f48d23d9dd38f432672865f6f79e73a6f9cc5a5f57fcaa83eb5a8e4"
"1.3.3":
url: "https://nexus.avroid.tech/repository/devops-raw-proxy-github/xiph/flac/archive/1.3.3.tar.gz"
sha256: "668cdeab898a7dd43cf84739f7e1f3ed6b35ece2ef9968a5c7079fe9adfe1689"
patches:
"1.4.3":
- patch_file: "patches/1.4.2-002-ignore-dll_export-define.patch"
patch_description: "Ignore autotools-specific DLL_EXPORT define in export.h"
patch_type: "conan"
"1.4.2":
- patch_file: "patches/1.4.2-002-ignore-dll_export-define.patch"
patch_description: "Ignore autotools-specific DLL_EXPORT define in export.h"
patch_type: "conan"
"1.3.3":
- patch_file: "patches/fix-cmake-1.3.3.patch"
patch_description: "Various adaptations in CMakeLists.txt files to improve compatibility with Conan."
patch_type: "conan"

View File

@@ -0,0 +1,121 @@
from conan import ConanFile
from conan.tools.apple import is_apple_os
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, rmdir, replace_in_file
from conan.tools.scm import Version
import os
required_conan_version = ">=1.54.0"
class FlacConan(ConanFile):
name = "flac"
description = "Free Lossless Audio Codec"
topics = ("flac", "codec", "audio", )
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/xiph/flac"
license = ("BSD-3-Clause", "GPL-2.0-or-later", "LPGL-2.1-or-later", "GFDL-1.2")
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def requirements(self):
self.requires("ogg/1.3.5")
def build_requirements(self):
if Version(self.version) < "1.4.2" and self.settings.arch in ["x86", "x86_64"]:
self.tool_requires("nasm/2.15.05")
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_EXAMPLES"] = False
tc.variables["BUILD_DOCS"] = False
tc.variables["BUILD_PROGRAMS"] = not is_apple_os(self) or self.settings.os == "Macos"
tc.variables["BUILD_TESTING"] = False
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()
cd = CMakeDeps(self)
cd.generate()
if self.settings.arch in ["x86", "x86_64"]:
envbuild = VirtualBuildEnv(self)
envbuild.generate(scope="build")
def _patch_sources(self):
apply_conandata_patches(self)
replace_in_file(self, os.path.join(self.source_folder, "src", "share", "getopt", "CMakeLists.txt"),
"find_package(Intl)", "")
def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "COPYING.*", src=self.source_folder,
dst=os.path.join(self.package_folder, "licenses"), keep_path=False)
copy(self, "*.h", src=os.path.join(self.source_folder, "include", "share"),
dst=os.path.join(self.package_folder, "include", "share"), keep_path=False)
copy(self, "*.h", src=os.path.join(self.source_folder, "include", "share", "grabbag"),
dst=os.path.join(self.package_folder, "include", "share", "grabbag"), keep_path=False)
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "flac")
self.cpp_info.components["libflac"].set_property("cmake_target_name", "FLAC::FLAC")
self.cpp_info.components["libflac"].set_property("pkg_config_name", "flac")
self.cpp_info.components["libflac"].libs = ["FLAC"]
self.cpp_info.components["libflac"].requires = ["ogg::ogg"]
self.cpp_info.components["libflac++"].set_property("cmake_target_name", "FLAC::FLAC++")
self.cpp_info.components["libflac++"].set_property("pkg_config_name", "flac++")
self.cpp_info.components["libflac++"].libs = ["FLAC++"]
self.cpp_info.components["libflac++"].requires = ["libflac"]
if not self.options.shared:
self.cpp_info.components["libflac"].defines = ["FLAC__NO_DLL"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libflac"].system_libs += ["m"]
bin_path = os.path.join(self.package_folder, "bin")
self.env_info.PATH.append(bin_path)
# TODO: to remove in conan v2
self.cpp_info.filenames["cmake_find_package"] = "flac"
self.cpp_info.filenames["cmake_find_package_multi"] = "flac"
self.cpp_info.names["cmake_find_package"] = "FLAC"
self.cpp_info.names["cmake_find_package_multi"] = "FLAC"
self.cpp_info.components["libflac"].names["cmake_find_package"] = "FLAC"
self.cpp_info.components["libflac"].names["cmake_find_package_multi"] = "FLAC"
self.cpp_info.components["libflac++"].names["cmake_find_package"] = "FLAC++"
self.cpp_info.components["libflac++"].names["cmake_find_package_multi"] = "FLAC++"

View File

@@ -0,0 +1,22 @@
--- include/FLAC/export.h
+++ include/FLAC/export.h
@@ -74,7 +74,7 @@
*/
#if defined(_WIN32)
-#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT))
+#if defined(FLAC__NO_DLL)
#define FLAC_API
#else
#ifdef FLAC_API_EXPORTS
--- include/FLAC++/export.h
+++ include/FLAC++/export.h
@@ -73,7 +73,7 @@
* by libtool, must override FLAC__NO_DLL on building shared components
*/
#if defined(_WIN32)
-#if defined(FLAC__NO_DLL) && !(defined(DLL_EXPORT))
+#if defined(FLAC__NO_DLL)
#define FLACPP_API
#else
#ifdef FLACPP_API_EXPORTS

View File

@@ -0,0 +1,48 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,9 +25,6 @@ endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wsign-promo -Wundef")
endif()
-if(CMAKE_C_COMPILER_ID MATCHES "GNU")
- set(CMAKE_EXE_LINKER_FLAGS -no-pie)
-endif()
include(CMakePackageConfigHelpers)
include(CPack)
@@ -76,7 +73,7 @@ add_compile_options(
$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${HAVE_DECL_AFTER_STMT_FLAG}>>:-Wdeclaration-after-statement>)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND HAVE_STACKREALIGN_FLAG)
- add_compile_options(-mstackrealign)
+ add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-mstackrealign>)
endif()
include_directories("include")
--- a/src/flac/CMakeLists.txt
+++ b/src/flac/CMakeLists.txt
@@ -21,4 +21,4 @@ if(TARGET win_utf8_io)
endif()
install(TARGETS flacapp EXPORT targets
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")
--- a/src/libFLAC/CMakeLists.txt
+++ b/src/libFLAC/CMakeLists.txt
@@ -102,7 +102,7 @@ target_compile_definitions(FLAC
target_include_directories(FLAC INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
-target_link_libraries(FLAC PRIVATE $<$<BOOL:${HAVE_LROUND}>:m>)
+target_link_libraries(FLAC PUBLIC $<$<BOOL:${HAVE_LROUND}>:m>)
if(TARGET Ogg::ogg)
target_link_libraries(FLAC PUBLIC Ogg::ogg)
endif()
--- a/src/metaflac/CMakeLists.txt
+++ b/src/metaflac/CMakeLists.txt
@@ -15,4 +15,4 @@ if(TARGET win_utf8_io)
endif()
install(TARGETS metaflac EXPORT targets
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")

View File

@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)
find_package(flac REQUIRED FLAC++ CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE FLAC::FLAC++)

View File

@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import cross_building
from conan.tools.cmake import CMake, cmake_layout
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "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):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,21 @@
#include <cstdlib>
#include <iostream>
#include "FLAC++/encoder.h"
class OurEncoder: public FLAC::Encoder::File {
public:
OurEncoder(): FLAC::Encoder::File() {}
protected:
virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, uint32_t frames_written, uint32_t total_frames_estimate)
{}
};
int main()
{
OurEncoder encoder;
if(!encoder) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}

7
recipes/flac/config.yml Normal file
View File

@@ -0,0 +1,7 @@
versions:
"1.4.3":
folder: all
"1.4.2":
folder: all
"1.3.3":
folder: all