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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from cerbero.errors import FatalError
from cerbero.utils import shell
from cerbero.utils import messages as m
from cerbero.tools.libtool import LibtoolLibrary
import shutil
class Recipe(recipe.Recipe):
name = 'libvpx'
version = 'v1.7.0'
stype = SourceType.TARBALL
url = 'https://github.com/webmproject/libvpx/archive/%(version)s.tar.gz'
tarball_dirname = 'libvpx-' + version[1:]
tarball_checksum = '1fec931eb5c94279ad219a5b6e0202358e94a93a90cfb1603578c326abfc1238'
licenses = [{License.BSD: ['LICENSE'], License.Misc: ['PATENTS']}]
btype = BuildType.MAKEFILE
configure_tpl = "./configure --disable-dependency-tracking --prefix=%(prefix)s " \
"--libdir=%(libdir)s %(options)s"
configure_options = "--enable-pic --as=yasm --disable-unit-tests --size-limit=16384x16384 " \
"--enable-postproc --enable-multi-res-encoding --enable-temporal-denoising " \
"--enable-vp9-temporal-denoising --enable-vp9-postproc --disable-tools " \
"--disable-examples --disable-docs "
add_host_build_target = False
supports_cache_variables = False
can_use_configure_cache = False
make = 'make HAVE_GNU_STRIP=no'
# The shell-based build system magically supports Visual Studio with the
# power of awesome hacks
can_msvc = True
patches = ['libvpx/0001-build-Fix-the-min-version-flag-for-iOS-simulator-bui.patch',
'libvpx/0002-Include-Android-cpu-features.c-instead-of-.h.patch',
'libvpx/0003-configure-Add-back-the-armv5te-android-gcc-target.patch',
'libvpx/0004-build-Remove-broken-custom-android-toolchain-usage.patch',
# Taken from AOSP: https://android.googlesource.com/platform/external/libvpx/+/android-o-mr1-iot-release-1.0.3/
'libvpx/0005-Add-visibility-protected-attribute-for-global-variab.patch',
'libvpx/0006-Fix-pkg-config-file-library-list.patch',
'libvpx/0007-Always-generate-a-pkg-config-file-and-don-t-require-.patch',
'libvpx/0001-gen_msvs_vcxproj.sh-Select-current-Windows-SDK-if-av.patch',
]
files_libs = ['libvpx']
files_devel = ['include/vpx', 'lib/pkgconfig/vpx.pc']
# libvpx does not have check target
make_check = None
def vpx_using_msvc(self):
if not self.using_msvc():
return False
# libvpx supports VS 2015 and VS 2017
if self.config.msvc_version not in ('vs14', 'vs15'):
# If we're not going to be using MSVC, remove its flags
for cflag in self.config.msvc_toolchain_env['CFLAGS']:
if cflag:
self.remove_env('CFLAGS', cflag)
return False
return True
def prepare(self):
compiler = 'gcc'
if self.config.target_arch == Architecture.X86_64:
arch = 'x86_64'
elif self.config.target_arch == Architecture.X86:
arch = 'x86'
elif self.config.target_arch == Architecture.ARM:
arch = 'arm'
elif self.config.target_arch == Architecture.ARMv7:
arch = 'armv7'
elif self.config.target_arch == Architecture.ARMv7S:
arch = 'armv7s'
elif self.config.target_arch == Architecture.ARM64:
arch = 'arm64'
if self.config.target_platform in [Platform.DARWIN, Platform.IOS]:
# make sure the linker uses the correct stdlib when building with
# 10.13 which makes the usage of libstdc++ a hard error.
self.append_env('LDFLAGS', '-stdlib=libc++')
if self.config.target_platform == Platform.DARWIN:
self.configure_options += '--enable-shared '
platform = 'darwin12'
elif self.config.target_platform == Platform.IOS:
if self.config.target_arch == Architecture.X86 or self.config.target_arch == Architecture.X86_64:
platform = 'iphonesimulator'
else:
platform = 'darwin'
if self.config.target_arch == Architecture.ARM:
arch = 'armv6'
elif self.config.target_platform == Platform.WINDOWS:
if self.config.target_arch == Architecture.X86_64:
platform = 'win64'
else:
platform = 'win32'
if not self.using_msvc():
self.append_env('CFLAGS', '-mstackrealign')
if self.vpx_using_msvc():
compiler = self.config.msvc_version
self.library_type = LibraryType.STATIC
# FIXME:
elif self.config.target_platform == Platform.ANDROID:
platform = 'android'
self.library_type = LibraryType.STATIC
self.append_env('CFLAGS', '-Dandroid_getCpuFamily=vpx_android_getCpuFamily',
'-Dandroid_getCpuFeatures=vpx_android_getCpuFeatures',
'-Dandroid_getCpuCount=vpx_android_getCpuCount',
'-Dandroid_cpuInit=vpx_android_cpuInit',
'-Dandroid_cpuInitDummy=vpx_android_cpuInitDummy',
'-Dandroid_getCpuIdArm=vpx_android_getCpuIdArm',
'-Dandroid_setCpu=vpx_android_setCpu',
'-Dandroid_setCpuArm=vpx_android_setCpuArm')
if self.config.target_arch == Architecture.X86:
self.append_env('ASFLAGS', '-D__ANDROID__')
self.append_env('CFLAGS', '-D__ANDROID__')
if self.config.target_arch == Architecture.ARM:
arch = 'armv5te'
elif self.config.target_arch not in [Architecture.ARMv7, Architecture.X86, Architecture.ARM64, Architecture.X86_64]:
raise FatalError("Unsupported Android architecture %s" % self.config.target_arch)
self.config_sh = 'LD=$CC ./configure'
self.configure_options.replace('--as=yasm', '')
self.configure_options += ' --sdk-path=%s ' % self.config.toolchain_prefix
else:
self.configure_options += '--enable-shared '
platform = 'linux'
self.configure_options += ' --disable-examples '
self.configure_options += '--target=%s-%s-%s ' % (arch, platform, compiler)
async def configure(self):
if self.config.target_platform == Platform.ANDROID:
cpufeatures_path = os.path.join(self.config.toolchain_prefix, 'sources', 'android', 'cpufeatures')
o = os.path.join(cpufeatures_path, 'cpu-features.h')
f = os.path.join(self.make_dir, 'vpx_ports')
m.action("copying %s to %s" % (o, f))
shutil.copy(o, f)
f = self.make_dir
m.action("copying %s to %s" % (o, f))
shutil.copy(o, f)
o = os.path.join(cpufeatures_path, 'cpu-features.c')
f = os.path.join(self.make_dir, 'vpx_ports')
m.action("copying %s to %s" % (o, f))
shutil.copy(o, f)
await super().configure()
def install(self):
if self.config.target_platform in [Platform.DARWIN, Platform.IOS]:
shell.touch(os.path.join(self.build_dir, 'libvpx.a'))
super().install()
def post_install(self):
if self.vpx_using_msvc():
if self.config.target_arch == Architecture.X86_64:
subdir = 'x64'
else:
subdir = 'Win32'
os.replace(os.path.join(self.config.prefix, 'lib', subdir, 'vpxmd.lib'),
os.path.join(self.config.prefix, 'lib', 'libvpx.a'))
LibtoolLibrary('vpx', None, None, None,
self.config.libdir, self.config.target_platform,
static_only=self.library_type == LibraryType.STATIC).save()
if self.config.target_platform == Platform.DARWIN:
# Fixup the id of the dylib
vpx_lib_with_ver = os.path.join(self.config.libdir, 'libvpx.5.dylib')
vpx_lib = os.path.join(self.config.libdir, 'libvpx.dylib')
shell.call(' '.join(['install_name_tool', '-id', vpx_lib_with_ver, vpx_lib]))
shell.call(' '.join(['install_name_tool', '-id', vpx_lib_with_ver, vpx_lib_with_ver]))
super().post_install()
|