From 2b4ca8ab23cd400728ab208d56fdf48992890b39 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Mon, 27 Sep 2021 12:02:19 -0700 Subject: [PATCH] (#7414) add faac/1.28 * add faac/1.28 * remove non-existing options * use libtoolize everywhere * use cmake_find_pacakge --- recipes/faac/all/CMakeLists.txt | 11 ++ recipes/faac/all/conandata.yml | 8 ++ recipes/faac/all/conanfile.py | 104 ++++++++++++++++++ .../faac/all/patches/001-use-libtoolize.patch | 16 +++ recipes/faac/all/test_package/CMakeLists.txt | 10 ++ recipes/faac/all/test_package/conanfile.py | 17 +++ recipes/faac/all/test_package/test_package.c | 21 ++++ recipes/faac/config.yml | 3 + 8 files changed, 190 insertions(+) create mode 100644 recipes/faac/all/CMakeLists.txt create mode 100644 recipes/faac/all/conandata.yml create mode 100644 recipes/faac/all/conanfile.py create mode 100644 recipes/faac/all/patches/001-use-libtoolize.patch create mode 100644 recipes/faac/all/test_package/CMakeLists.txt create mode 100644 recipes/faac/all/test_package/conanfile.py create mode 100644 recipes/faac/all/test_package/test_package.c create mode 100644 recipes/faac/config.yml diff --git a/recipes/faac/all/CMakeLists.txt b/recipes/faac/all/CMakeLists.txt new file mode 100644 index 0000000000000..6bcd7021e337d --- /dev/null +++ b/recipes/faac/all/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1.0) +project(cmake_wrapper) + +if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") + include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +else() + include(conanbuildinfo.cmake) +endif() +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/faac/all/conandata.yml b/recipes/faac/all/conandata.yml new file mode 100644 index 0000000000000..99791ca87595d --- /dev/null +++ b/recipes/faac/all/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.28": + url: "https://github.com/knik0/faac/archive/refs/tags/faac1_28.tar.gz" + sha256: "fec821797a541e8359f086fef454b947a7f7246fe8ec6207668968b86606a7dd" +patches: + "1.28": + - patch_file: "patches/001-use-libtoolize.patch" + base_path: "source_subfolder" diff --git a/recipes/faac/all/conanfile.py b/recipes/faac/all/conanfile.py new file mode 100644 index 0000000000000..cc3e652c61d3b --- /dev/null +++ b/recipes/faac/all/conanfile.py @@ -0,0 +1,104 @@ +from conans import ConanFile, tools, AutoToolsBuildEnvironment +import os +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class FaacConan(ConanFile): + name = "faac" + description = "Freeware Advanced Audio Coder" + topics = ("audio", "mp4", "encoder", "aac", "m4a", "faac") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://sourceforge.net/projects/faac" + license = "LGPL-2.0-only" + exports_sources = "patches/*" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_mp4": [True, False], + "drm": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_mp4": False, + "drm": False + } + + _source_subfolder = "source_subfolder" + _autotools = None + + @property + def _is_mingw(self): + return self.settings.os == "Windows" and self.settings.compiler != "Visual Studio" + + def validate(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("libfaac doesn't support builing with Visual Studio") + if self.options.with_mp4: + # TODO: as mpv4v2 as a conan package + raise ConanInvalidConfiguration("building with mp4v2 is not supported currently") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + + def _configure_autotools(self): + if self._autotools: + return self._autotools + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) + with tools.chdir(os.path.join(self.build_folder, self._source_subfolder)): + self.run("./bootstrap", win_bash=tools.os_info.is_windows) + args = [] + if self.options.shared: + args.append("--enable-shared") + else: + args.append("--enable-static") + args.append("--{}-mp4v2".format("with" if self.options.with_mp4 else "without")) + args.append("--{}-drm".format("enable" if self.options.drm else "disable")) + self._autotools.configure(args=args) + return self._autotools + + def build_requirements(self): + self.build_requires("libtool/2.4.6") + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + autotools = self._configure_autotools() + if self._is_mingw and self.options.shared: + tools.replace_in_file(os.path.join(self._source_subfolder, "libfaac", "Makefile"), + "\nlibfaac_la_LIBADD = ", "\nlibfaac_la_LIBADD = -no-undefined ") + if self.settings.os == "Macos": + tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), r"-install_name \$rpath/", "-install_name ") + with tools.chdir(os.path.join(self.build_folder, self._source_subfolder)): + autotools.make() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + autotools = self._configure_autotools() + with tools.chdir(os.path.join(self.build_folder, self._source_subfolder)): + autotools.make(target="install") + + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + if self.options.shared: + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "lib{}.a".format(self.name)) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) diff --git a/recipes/faac/all/patches/001-use-libtoolize.patch b/recipes/faac/all/patches/001-use-libtoolize.patch new file mode 100644 index 0000000000000..d8c66a53960e1 --- /dev/null +++ b/recipes/faac/all/patches/001-use-libtoolize.patch @@ -0,0 +1,16 @@ +diff --git a/bootstrap b/bootstrap +--- bootstrap ++++ bootstrap +@@ -1,11 +1,7 @@ + #! /bin/sh + + aclocal -I . + autoheader +-if test "`uname -s`" = Darwin; then +- glibtoolize --automake +-else +- libtoolize --automake +-fi ++libtoolize --automake + automake --add-missing + autoconf diff --git a/recipes/faac/all/test_package/CMakeLists.txt b/recipes/faac/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3d574f10279dc --- /dev/null +++ b/recipes/faac/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1.0) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(faac REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} faac::faac) diff --git a/recipes/faac/all/test_package/conanfile.py b/recipes/faac/all/test_package/conanfile.py new file mode 100644 index 0000000000000..1d0bdd3779793 --- /dev/null +++ b/recipes/faac/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/faac/all/test_package/test_package.c b/recipes/faac/all/test_package/test_package.c new file mode 100644 index 0000000000000..91e3f9bf61bbb --- /dev/null +++ b/recipes/faac/all/test_package/test_package.c @@ -0,0 +1,21 @@ +#include +#include + +int main() +{ + char *faac_id_string; + char *faac_copyright_string; + // get faac version + if (faacEncGetVersion(&faac_id_string, &faac_copyright_string) == + FAAC_CFG_VERSION) + { + fprintf(stderr, "Freeware Advanced Audio Coder\nFAAC %s\n", + faac_id_string); + } + else + { + fprintf(stderr, __FILE__ "(%d): wrong libfaac version\n", __LINE__); + return 1; + } + return 0; +} diff --git a/recipes/faac/config.yml b/recipes/faac/config.yml new file mode 100644 index 0000000000000..0653c48b8514a --- /dev/null +++ b/recipes/faac/config.yml @@ -0,0 +1,3 @@ +versions: + "1.28": + folder: all