This repository has been archived by the owner on May 5, 2020. It is now read-only.
generated from bincrafters/template-default
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
96 lines (85 loc) · 3.65 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from conans import ConanFile, tools, AutoToolsBuildEnvironment, RunEnvironment
from conans.errors import ConanInvalidConfiguration
import os
import shutil
import glob
class LibnameConan(ConanFile):
name = "libsndfile"
description = "Libsndfile is a library of C routines for reading and writing files containing sampled audio data."
topics = ("conan", "libsndfile", "sound")
url = "https://github.com/bincrafters/conan-libsndfile"
homepage = "http://www.mega-nerd.com/libsndfile"
license = "LGPL-2.1"
generators = 'pkg_config'
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_alsa": [True, False],
"with_sqlite": [True, False],
"with_external_libs": [True, False]}
default_options = {
"shared": False,
"fPIC": True,
"with_alsa": True,
"with_sqlite": True,
"with_external_libs": True,}
_autotools = None
@property
def _source_subfolder(self):
return "source_subfolder"
def requirements(self):
if self.options.with_alsa:
self.requires("libalsa/1.1.9")
if self.options.with_sqlite:
self.requires("sqlite3/3.29.0")
if self.options.with_external_libs:
self.requires("flac/1.3.3")
self.requires("ogg/1.3.4")
self.requires("vorbis/1.3.6")
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
def configure(self):
if self.settings.compiler == "Visual Studio":
raise ConanInvalidConfiguration("The project libsndfile can not be built by Visual Studio.")
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
def _configure_autotools(self):
if not self._autotools:
self._autotools = AutoToolsBuildEnvironment(self)
args = [
"--without-caps",
"--enable-alsa" if self.options.with_alsa else "--disable-alsa",
"--enable-sqlite" if self.options.with_sqlite else "--disable-sqlite",
"--enable-external-libs" if self.options.with_external_libs else "--disable-external-libs",
]
if self.options.shared:
args.extend(['--enable-shared=yes', '--enable-static=no'])
else:
args.extend(['--enable-shared=no', '--enable-static=yes'])
self._autotools.configure(args=args, configure_dir=self._source_subfolder)
return self._autotools
def build(self):
if self.options.with_external_libs:
shutil.copyfile('vorbis.pc', 'vorbisenc.pc')
with tools.environment_append(RunEnvironment(self).vars):
autotools = self._configure_autotools()
autotools.make()
def package(self):
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
autotools = self._configure_autotools()
autotools.install()
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
for f in glob.glob(os.path.join(self.package_folder, "lib", "*.la")):
os.remove(f)
def package_info(self):
self.cpp_info.names['pkg_config'] = 'sndfile'
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["m", "dl", "pthread", "rt"]