[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,13 @@
sources:
"2.0.3":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.3.tar.gz"
sha256: "829b6b89eef382409cda6857fd82af84fabb63417b08ede9ea7a553f811cb79e"
"2.0.2":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.2.tar.gz"
sha256: "c9e8630cf9d433f3cead74906a1520d2223f89bcd3fa9254861017440b8eb22f"
"2.0.1":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.1.tar.gz"
sha256: "840133aa9412153894af03b27b03dde1188772442c316a4ce2a24ed70093f271"
"2.0.0":
url: "https://nexus.avroid.tech/repository/all-raw-proxy-sourceforge_net/projects/opencore-amr/files/fdk-aac/fdk-aac-2.0.0.tar.gz"
sha256: "f7d6e60f978ff1db952f7d5c3e96751816f5aef238ecf1d876972697b85fd96c"

View File

@@ -0,0 +1,166 @@
from conan import ConanFile
from conan.tools.apple import fix_apple_shared_install_name
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import chdir, copy, get, rename, replace_in_file, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc, NMakeToolchain
from conan.tools.build import cross_building
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
import os
required_conan_version = ">=1.55.0"
class LibFDKAACConan(ConanFile):
name = "libfdk_aac"
url = "https://github.com/conan-io/conan-center-index"
description = "A standalone library of the Fraunhofer FDK AAC code from Android"
license = "https://github.com/mstorsjo/fdk-aac/blob/master/NOTICE"
homepage = "https://sourceforge.net/projects/opencore-amr/"
topics = ("multimedia", "audio", "fraunhofer", "aac", "decoder", "encoding", "decoding")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
@property
def _settings_build(self):
return getattr(self, "settings_build", self.settings)
@property
def _use_cmake(self):
return Version(self.version) >= "2.0.2"
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 validate_build(self):
if cross_building(self) and self.settings.os == "Android":
# https://github.com/mstorsjo/fdk-aac/issues/124#issuecomment-653473956
# INFO: It's possible to inject a log.h to fix the error, but there is no official support.
raise ConanInvalidConfiguration(f"{self.ref} cross-building for Android is not supported. Please, try native build.")
def layout(self):
if self._use_cmake:
cmake_layout(self, src_folder="src")
else:
basic_layout(self, src_folder="src")
def build_requirements(self):
if not self._use_cmake and not is_msvc(self):
# self.tool_requires("libtool/2.4.7")
if self._settings_build.os == "Windows":
self.win_bash = True
if not self.conf.get("tools.microsoft.bash:path", check_type=str):
self.tool_requires("msys2/cci.latest")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
if self._use_cmake:
tc = CMakeToolchain(self)
tc.variables["BUILD_PROGRAMS"] = False
tc.variables["FDK_AAC_INSTALL_CMAKE_CONFIG_MODULE"] = False
tc.variables["FDK_AAC_INSTALL_PKGCONFIG_MODULE"] = False
tc.generate()
elif is_msvc(self):
tc = NMakeToolchain(self)
tc.generate()
else:
env = VirtualBuildEnv(self)
env.generate()
tc = AutotoolsToolchain(self)
tc.generate()
def build(self):
if self._use_cmake:
cmake = CMake(self)
cmake.configure()
cmake.build()
elif is_msvc(self):
makefile_vc = os.path.join(self.source_folder, "Makefile.vc")
replace_in_file(self, makefile_vc, "CFLAGS = /nologo /W3 /Ox /MT", "CFLAGS = /nologo")
replace_in_file(self, makefile_vc, "MKDIR_FLAGS = -p", "MKDIR_FLAGS =")
# Build either shared or static, and don't build utility (it always depends on static lib)
replace_in_file(self, makefile_vc, "copy $(PROGS) $(bindir)", "")
replace_in_file(self, makefile_vc, "copy $(LIB_DEF) $(libdir)", "")
if self.options.shared:
replace_in_file(
self, makefile_vc,
"all: $(LIB_DEF) $(STATIC_LIB) $(SHARED_LIB) $(IMP_LIB) $(PROGS)",
"all: $(LIB_DEF) $(SHARED_LIB) $(IMP_LIB)",
)
replace_in_file(self, makefile_vc, "copy $(STATIC_LIB) $(libdir)", "")
else:
replace_in_file(
self, makefile_vc,
"all: $(LIB_DEF) $(STATIC_LIB) $(SHARED_LIB) $(IMP_LIB) $(PROGS)",
"all: $(STATIC_LIB)",
)
replace_in_file(self, makefile_vc, "copy $(IMP_LIB) $(libdir)", "")
replace_in_file(self, makefile_vc, "copy $(SHARED_LIB) $(bindir)", "")
with chdir(self, self.source_folder):
self.run("nmake -f Makefile.vc")
else:
autotools = Autotools(self)
autotools.autoreconf()
if self.settings.os == "Android" and self._settings_build.os == "Windows":
# remove escape for quotation marks, to make ndk on windows happy
replace_in_file(
self, os.path.join(self.source_folder, "configure"),
"s/[ `~#$^&*(){}\\\\|;'\\\''\"<>?]/\\\\&/g", "s/[ `~#$^&*(){}\\\\|;<>?]/\\\\&/g",
)
autotools.configure()
autotools.make()
def package(self):
copy(self, "NOTICE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
if self._use_cmake:
cmake = CMake(self)
cmake.install()
elif is_msvc(self):
with chdir(self, self.source_folder):
self.run(f"nmake -f Makefile.vc prefix=\"{self.package_folder}\" install")
if self.options.shared:
rename(self, os.path.join(self.package_folder, "lib", "fdk-aac.dll.lib"),
os.path.join(self.package_folder, "lib", "fdk-aac.lib"))
else:
autotools = Autotools(self)
autotools.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
fix_apple_shared_install_name(self)
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "fdk-aac")
self.cpp_info.set_property("cmake_target_name", "FDK-AAC::fdk-aac")
self.cpp_info.set_property("pkg_config_name", "fdk-aac")
# TODO: back to global scope in conan v2 once cmake_find_package_* generators removed
self.cpp_info.components["fdk-aac"].libs = ["fdk-aac"]
if self.settings.os in ["Linux", "FreeBSD", "Android"]:
self.cpp_info.components["fdk-aac"].system_libs.append("m")
# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.filenames["cmake_find_package"] = "fdk-aac"
self.cpp_info.filenames["cmake_find_package_multi"] = "fdk-aac"
self.cpp_info.names["cmake_find_package"] = "FDK-AAC"
self.cpp_info.names["cmake_find_package_multi"] = "FDK-AAC"
self.cpp_info.components["fdk-aac"].names["cmake_find_package"] = "fdk-aac"
self.cpp_info.components["fdk-aac"].names["cmake_find_package_multi"] = "fdk-aac"
self.cpp_info.components["fdk-aac"].set_property("cmake_target_name", "FDK-AAC::fdk-aac")

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES C)
find_package(fdk-aac REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE FDK-AAC::fdk-aac)
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99)

View 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")

View File

@@ -0,0 +1,33 @@
#include <fdk-aac/aacenc_lib.h>
#include <fdk-aac/aacdecoder_lib.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main()
{
LIB_INFO info[FDK_MODULE_LAST];
memset(&info, 0, sizeof(info));
int ret = aacDecoder_GetLibInfo(info);
if (0 != ret) {
fprintf(stderr, "aacDecoder_GetLibInfo failed with %u\n", ret);
return EXIT_FAILURE;
}
ret = aacEncGetLibInfo(info);
if (0 != ret) {
fprintf(stderr, "aacEncGetLibInfo failed with %u\n", ret);
return EXIT_FAILURE;
}
for (int i = 0; i < FDK_MODULE_LAST; ++i) {
if (FDK_AACDEC == info[i].module_id || FDK_AACENC == info[i].module_id) {
printf("title: %s\n", info[i].title);
printf("build date: %s\n", info[i].build_date);
printf("build time: %s\n", info[i].build_time);
printf("version: %s\n", info[i].versionStr);
printf("========================================\n");
}
}
return EXIT_SUCCESS;
}