summaryrefslogtreecommitdiff
path: root/recipes/wavpack.recipe
blob: e6a01d06ad50f4735e38563046b827a1b3153728 (plain)
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
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from pathlib import Path
from cerbero.tools.libtool import LibtoolLibrary

class Recipe(recipe.Recipe):
    name = 'wavpack'
    version = '5.4.0'
    stype = SourceType.TARBALL
    url = 'https://github.com/dbry/WavPack/archive/%(version)s.tar.gz'
    tarball_dirname = 'WavPack-%(version)s'
    tarball_checksum = 'abbe5ca3fc918fdd64ef216200a5c896243ea803a059a0662cd362d0fa827cd2'
    licenses = [{License.BSD_like: ['COPYING']}]

    btype = BuildType.CMAKE
    configure_options = '-DWAVPACK_INSTALL_CMAKE_MODULE=OFF \
        -DWAVPACK_ENABLE_LIBCRYPTO=OFF \
        -DWAVPACK_INSTALL_DOCS=OFF \
        -DWAVPACK_BUILD_DOCS=OFF \
        -DWAVPACK_BUILD_PROGRAMS=OFF \
        -DWAVPACK_BUILD_COOLEDIT_PLUGIN=OFF \
        -DWAVPACK_BUILD_WINAMP_PLUGIN=OFF'
    can_msvc = True
    cmake_generator = 'ninja'

    patches = [
        name + '/0001-cmake-Don-t-name-MSVC-DLL-wavpackdll.dll.patch',
        name + '/0001-cmake-Set-SOVERSION-to-match-Autotools.patch',
    ]

    files_libs = ['libwavpack']
    files_devel = ['include/wavpack', '%(libdir)s/pkgconfig/wavpack.pc']

    def prepare(self):
        if self.config.target_arch not in [Architecture.X86, Architecture.X86_64, Architecture.ARMv7, Architecture.ARMv7S] or self.config.target_platform == Platform.IOS:
            self.configure_options += ' -DWAVPACK_ENABLE_ASM=OFF '
        # We only want static libs on iOS and Android
        if self.config.target_platform not in (Platform.IOS, Platform.ANDROID):
            self.configure_options += ' -DBUILD_SHARED_LIBS=ON '
            self.library_type = LibraryType.SHARED
        else:
            self.library_type = LibraryType.STATIC
        if self.config.cross_compiling() and self.config.target_platform not in [Platform.WINDOWS, Platform.DARWIN]:
            self.configure_options += ' -DCOMPILER_SUPPORTS_SYMBOL_MAPS_EXITCODE=0'
        if self.config.target_platform == Platform.ANDROID:
            self.configure_options += ' -DCOMPILER_SUPPORTS_SYMBOL_MAPS=TRUE'

    async def extract(self):
        await super().extract()
        # afxres.h is provided by the component "Visual C++ MFC" in the Visual
        # Studio 2019 installer, but the component is not selected by default,
        # and this header not actually needed by the resource file. Everything
        # works fine with just windows.h
        shell.replace(os.path.join(self.config_src_dir, 'wavpackdll/wavpackdll.rc'),
                      {'afxres.h': 'windows.h'})
        # CMake can only build shared or static libs, and we need the static
        # libs on Android and iOS. This means we need to link to -lm, which
        # will only get pulled in with pkg-config --libs --static, which is not
        # what the gst-plugins-good dependency() call does. So let's add it to
        # the Libs: line.
        if self.config.target_platform in (Platform.IOS, Platform.ANDROID):
            shell.replace(os.path.join(self.config_src_dir, 'wavpack.pc.in'),
                          {'-lwavpack': '-lwavpack @LIBM@'})

    async def install(self):
        await super().install()
        # CMake build system installs include/wavpack.h but we want
        # include/wavpack/wavpack.h
        incdir = Path(self.config.prefix) / 'include'
        todir = incdir / 'wavpack'
        todir.mkdir(exist_ok=True)
        (incdir / 'wavpack.h').replace(todir / 'wavpack.h')

    def post_install(self):
        deps = ['-lm']
        libtool_la = LibtoolLibrary('wavpack', None, None, None, self.config.libdir,
                self.config.target_platform, deps)
        libtool_la.save()
        super().post_install()