xref: /aosp_15_r20/external/libdav1d/examples/meson.build (revision c09093415860a1c2373dacd84c4fde00c507cdfd)
1# Copyright © 2018, VideoLAN and dav1d authors
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice, this
8#    list of conditions and the following disclaimer.
9#
10# 2. Redistributions in binary form must reproduce the above copyright notice,
11#    this list of conditions and the following disclaimer in the documentation
12#    and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25#
26# Build definition for the dav1d examples
27#
28
29# Leave subdir if examples are disabled
30if not get_option('enable_examples')
31    subdir_done()
32endif
33
34
35# dav1d player sources
36dav1dplay_sources = files(
37    'dav1dplay.c',
38    'dp_fifo.c',
39    'dp_renderer_placebo.c',
40    'dp_renderer_sdl.c',
41)
42
43sdl2_dependency = dependency('sdl2', version: '>= 2.0.1', required: true)
44
45if sdl2_dependency.found()
46    dav1dplay_deps = [sdl2_dependency, libm_dependency]
47    dav1dplay_cflags = []
48
49    placebo_dependency = dependency('libplacebo', version: '>= 4.160.0', required: false)
50
51    have_vulkan = false
52    have_placebo = placebo_dependency.found()
53    if have_placebo
54        dav1dplay_deps += placebo_dependency
55
56        # If libplacebo is found, we might be able to use Vulkan
57        # with it, in which case we need the Vulkan library too.
58        vulkan_dependency = dependency('vulkan', required: false)
59        if vulkan_dependency.found()
60            dav1dplay_deps += vulkan_dependency
61            have_vulkan = true
62        endif
63    endif
64
65    dav1dplay_cflags += '-DHAVE_PLACEBO=' + (have_placebo ? '1' : '0')
66    dav1dplay_cflags += '-DHAVE_VULKAN=' + (have_vulkan ? '1' : '0')
67
68    dav1dplay = executable('dav1dplay',
69        dav1dplay_sources,
70        rev_target,
71
72        link_with : [libdav1d, dav1d_input_objs],
73        include_directories : [dav1d_inc_dirs],
74        dependencies : [getopt_dependency, dav1dplay_deps],
75        install : true,
76        c_args : dav1dplay_cflags,
77    )
78endif
79