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

from pathlib import Path
import shutil


class LcevcdecBase:
    version = '4.0.4'
    stype = SourceType.TARBALL
    btype = BuildType.CMAKE
    url = 'https://github.com/v-novaltd/LCEVCdec/archive/refs/tags/%(version)s.tar.gz'
    tarball_checksum = '513f71531c66f226ec258289fd6c889844570029faf00ba2d7ebe501008c7db1'
    tarball_dirname = 'LCEVCdec-%(version)s'
    library_type = LibraryType.STATIC
    can_msvc = True

    deps = ['fmt']

    configure_options = [
        '-DVN_SDK_FFMPEG_LIBS_PACKAGE=""',
        '-DVN_SDK_JSON_CONFIG=OFF',
        '-DVN_SDK_EXECUTABLES=OFF',
        '-DVN_SDK_UNIT_TESTS=OFF',
        '-DVN_MSVC_RUNTIME_STATIC=OFF',
    ]

    def prepare(self):
        if self.config.target_platform == Platform.ANDROID:
            self.remove_env('CXXFLAGS', '-fno-exceptions')


class LcevcdecStaticRecipe(LcevcdecBase, recipe.Recipe):
    name = 'lcevcdec-static'
    files_libs = [
        'liblcevc_dec_api', 'liblcevc_dec_pipeline_cpu',
        'liblcevc_dec_pipeline_legacy', 'liblcevc_dec_legacy',
        'liblcevc_dec_api_utility',
        'liblcevc_dec_extract', 'liblcevc_dec_enhancement',
        'liblcevc_dec_pixel_processing', 'liblcevc_dec_common',
        'liblcevc_dec_sequencer', 'liblcevc_dec_pipeline',
    ]

    def prepare(self):
        super().prepare()

    async def install(self):
        for lib in self.files_libs:
            name = f"{lib.removeprefix('lib')}.lib" if self.using_msvc() else f'{lib}.a'
            src = Path(self.build_dir) / 'lib' / name
            dest = Path(self.config.libdir) / f'{lib}.a'
            shutil.copy(src, dest)

class LcevcdecRecipe(LcevcdecBase, recipe.Recipe):
    name = 'lcevcdec'
    # CMake will ignore the BUILD_STATIC_LIBS bit, which has been completed
    # by the recipe above
    library_type = LibraryType.BOTH
    # Complete the licenses with the BOTH recipe
    licenses = [{License.BSD_3_Clause_Clear: ['COPYING']}]
    deps = []

    files_libs = [
        'liblcevc_dec_api', 'liblcevc_dec_pipeline_cpu',
        'liblcevc_dec_pipeline_legacy', 'liblcevc_dec_legacy',
    ]
    files_devel = ['include/LCEVC', '%(libdir)s/pkgconfig/lcevc_dec.pc']

    def prepare(self):
        super().prepare()

        # We only want static libs on iOS and Android. The
        # static recipe won't work for this because it doesn't
        # generate the pkg-config payloads etc.
        if Platform.is_app_platform(self.config.target_platform):
            self.library_type = LibraryType.STATIC
            self.files_libs += ['liblcevc_dec_api_utility',
                'liblcevc_dec_extract', 'liblcevc_dec_enhancement',
                'liblcevc_dec_pixel_processing', 'liblcevc_dec_common',
                'liblcevc_dec_sequencer', 'liblcevc_dec_pipeline',
            ]
        else:
            self.deps += ['lcevcdec-static']

    def post_install(self):
        # CMake does not generate la files
        if self.config.target_platform == Platform.ANDROID:
            deps = ['c++', 'm', 'log']
        elif Platform.is_apple_app_platform(self.config.target_platform):
            deps = ['c++', 'm']
        else:
            deps = None

        if deps:
            deps += [
                'lcevc_dec_pipeline_cpu', 'lcevc_dec_pipeline_legacy',
                'lcevc_dec_legacy', 'liblcevc_dec_api_utility',
                'liblcevc_dec_extract', 'liblcevc_dec_enhancement',
                'liblcevc_dec_pixel_processing', 'liblcevc_dec_common',
                'liblcevc_dec_sequencer', 'liblcevc_dec_pipeline',
            ]


        libtool_la = LibtoolLibrary('liblcevc_dec_api', None, None, None,
                                    self.config.libdir, self.config.target_platform,
                                    deps=deps)
        libtool_la.save()
        super().post_install()