-
Notifications
You must be signed in to change notification settings - Fork 62
/
meson.build
153 lines (127 loc) · 4.85 KB
/
meson.build
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
project(
'wf-recorder',
'c',
'cpp',
version: '0.5.0',
license: 'MIT',
meson_version: '>=0.54.0',
default_options: [
'cpp_std=c++17',
'c_std=c11',
'warning_level=2',
'werror=false',
],
)
conf_data = configuration_data()
conf_data.set('default_codec', get_option('default_codec'))
conf_data.set('default_pix_fmt', get_option('default_pixel_format'))
conf_data.set('default_audio_codec', get_option('default_audio_codec'))
conf_data.set('default_audio_sample_rate', get_option('default_audio_sample_rate'))
conf_data.set('default_container_format', get_option('default_container_format'))
conf_data.set('fallback_audio_sample_fmt', get_option('fallback_audio_sample_fmt'))
version = '"@0@"'.format(meson.project_version())
git = find_program('git', native: true, required: false)
if git.found()
git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'], check: false)
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false)
if git_commit.returncode() == 0 and git_branch.returncode() == 0
version = '"@0@-@1@ (" __DATE__ ", branch \'@2@\')"'.format(
meson.project_version(),
git_commit.stdout().strip(),
git_branch.stdout().strip(),
)
endif
endif
add_project_arguments('-DWFRECORDER_VERSION=@0@'.format(version), language: 'cpp')
include_directories(['.'])
add_project_arguments(['-Wno-deprecated-declarations'], language: 'cpp')
project_sources = ['src/frame-writer.cpp', 'src/main.cpp', 'src/averr.c']
wayland_client = dependency('wayland-client', version: '>=1.20')
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
audio_backends = {
'pulse': {
'dependency': dependency('libpulse-simple', required: false),
'sources': ['src/pulse.cpp'],
'define': 'HAVE_PULSE'
},
'pipewire': {
'dependency': dependency('libpipewire-0.3', version: '>=1.0.5', required: false),
'sources': ['src/pipewire.cpp'],
'define': 'HAVE_PIPEWIRE'
}
}
default_audio_backend = get_option('default_audio_backend')
message('Using default audio backend: @0@'.format(default_audio_backend))
have_audio = false
audio_deps = []
foreach backend_name, backend_data : audio_backends
if default_audio_backend == backend_name and not backend_data['dependency'].found()
error('Default audio backend set to @0@, but @1@ dependency was not found!'.format(backend_name, backend_data['dependency'].name()))
endif
if default_audio_backend == backend_name and get_option(backend_name).disabled()
error('Default audio backend set to @0@, but @1@ support is disabled!'.format(backend_name, backend_name))
endif
if get_option(backend_name).enabled() and not backend_data['dependency'].found()
error('@0@ support is enabled, but @1@ dependency was not found!'.format(backend_name, backend_data['dependency'].name()))
endif
if backend_data['dependency'].found() and not get_option(backend_name).disabled()
conf_data.set(backend_data['define'], true)
project_sources += backend_data['sources']
audio_deps += backend_data['dependency']
have_audio = true
else
conf_data.set(backend_data['define'], false)
endif
endforeach
if have_audio
conf_data.set('HAVE_AUDIO', true)
project_sources += 'src/audio.cpp'
if default_audio_backend == 'auto'
if conf_data.get('HAVE_PULSE')
default_audio_backend = 'pulse'
else
foreach backend_name, backend_data : audio_backends
if conf_data.get(backend_data['define'])
default_audio_backend = backend_name
break
endif
endforeach
endif
endif
endif
conf_data.set('default_audio_backend', default_audio_backend)
libavutil = dependency('libavutil')
libavcodec = dependency('libavcodec')
libavformat = dependency('libavformat')
libavdevice = dependency('libavdevice', required: false)
libavfilter = dependency('libavfilter')
swr = dependency('libswresample')
threads = dependency('threads')
gbm = dependency('gbm')
drm = dependency('libdrm')
conf_data.set('HAVE_LIBAVDEVICE', libavdevice.found())
configure_file(input: 'config.h.in',
output: 'config.h',
configuration: conf_data)
install_data('manpage/wf-recorder.1', install_dir :
join_paths(get_option('prefix'), get_option('mandir'), 'man1'))
subdir('proto')
dependencies = [
wayland_client, wayland_protos,
libavutil, libavcodec, libavformat, libavdevice, libavfilter,
wf_protos, threads, swr, gbm, drm
] + audio_deps
executable('wf-recorder', project_sources,
dependencies: dependencies,
install: true)
summary = [
'',
'----------------',
'wf-recorder @0@'.format(meson.project_version()),
'----------------',
'Default audio backend: @0@'.format(default_audio_backend),
]
foreach backend_name, backend_data : audio_backends
summary += [' - @0@: @1@'.format(backend_name, conf_data.get(backend_data['define']))]
endforeach
message('\n'.join(summary))