Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add faac/1.28 #7414

Merged
merged 4 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions recipes/faac/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 8 additions & 0 deletions recipes/faac/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
104 changes: 104 additions & 0 deletions recipes/faac/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest enforcing chmod +x just in case, depending the environment, the user can have a permission error. There is an example here

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)
16 changes: 16 additions & 0 deletions recipes/faac/all/patches/001-use-libtoolize.patch
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions recipes/faac/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions recipes/faac/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 21 additions & 0 deletions recipes/faac/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <faac.h>
#include <stdio.h>

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;
}
3 changes: 3 additions & 0 deletions recipes/faac/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.28":
folder: all