]> git.sesse.net Git - nageru/blob - meson.build
When exporting interpolated files, make sure they are seekable.
[nageru] / meson.build
1 project('nageru', 'cpp', default_options: ['buildtype=debugoptimized'], version: '1.8.0')
2
3 cxx = meson.get_compiler('cpp')
4 qt5 = import('qt5')
5 protoc = find_program('protoc')
6
7 embedded_bmusb = get_option('embedded_bmusb')
8
9 alsadep = dependency('alsa')
10 bmusbdep = dependency('bmusb', required: not embedded_bmusb)
11 dldep = cxx.find_library('dl')
12 epoxydep = dependency('epoxy')
13 libavcodecdep = dependency('libavcodec')
14 libavformatdep = dependency('libavformat')
15 libswresampledep = dependency('libswresample')
16 libavutildep = dependency('libavutil')
17 libjpegdep = dependency('libjpeg')
18 libswscaledep = dependency('libswscale')
19 libusbdep = dependency('libusb-1.0')
20 luajitdep = dependency('luajit')
21 movitdep = dependency('movit')
22 protobufdep = dependency('protobuf')
23 qcustomplotdep = cxx.find_library('qcustomplot')
24 qt5deps = dependency('qt5', modules: ['Core', 'Gui', 'Widgets', 'OpenGLExtensions', 'OpenGL', 'Network'])
25 sdl2_imagedep = dependency('SDL2_image', required: false)
26 sdl2dep = dependency('sdl2', required: false)
27 sqlite3dep = dependency('sqlite3')
28 threaddep = dependency('threads')
29 vadrmdep = dependency('libva-drm')
30 vax11dep = dependency('libva-x11')
31 x11dep = dependency('x11')
32 x264dep = dependency('x264')
33 zitaresamplerdep = cxx.find_library('zita-resampler')
34
35 # Use lld if we can; it links a lot faster than ld.bfd or gold.
36 code = '''#include <stdio.h>
37 int main() { printf("Hello, world!\n"); return 0; }
38 '''
39 if cxx.links(code, args: '-fuse-ld=lld', name: 'check for LLD')
40         add_project_link_arguments('-fuse-ld=lld', language: 'cpp')
41 endif
42
43 # Add the right MOVIT_SHADER_DIR definition.
44 movit_shader_dir = movitdep.get_pkgconfig_variable('shaderdir')
45 add_project_arguments('-DMOVIT_SHADER_DIR="' + movit_shader_dir + '"', language: 'cpp')
46
47 # Make the Nageru version available as a #define.
48 add_project_arguments('-DNAGERU_VERSION="' + meson.project_version() + '"', language: 'cpp')
49
50 # DeckLink has these issues, and we include it from various places.
51 if cxx.has_argument('-Wno-non-virtual-dtor')
52         add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp')
53 endif
54
55 # This needs to be done before declaring any build targets.
56 if get_option('cef_dir') != ''
57         add_project_arguments('-DHAVE_CEF=1', language: 'cpp')
58 endif
59
60 top_include = include_directories('.')
61
62 subdir('shared')
63
64 # Nageru. (Not a subdir() because we don't want the output in nageru/nageru.)
65
66 nageru_srcs = []
67 nageru_deps = [shareddep, qt5deps, libjpegdep, movitdep, protobufdep,
68         vax11dep, vadrmdep, x11dep, libavformatdep, libswresampledep, libavcodecdep, libavutildep,
69         libswscaledep, libusbdep, luajitdep, dldep, x264dep, alsadep, zitaresamplerdep,
70         qcustomplotdep, threaddep]
71 nageru_include_dirs = [include_directories('nageru')]
72 nageru_link_with = []
73 nageru_build_rpath = ''
74 nageru_install_rpath = ''
75
76 kaeru_link_with = []
77 kaeru_extra_deps = []
78
79 # CEF.
80 exe_dir = join_paths(get_option('prefix'), 'lib/nageru')
81 cef_dir = get_option('cef_dir')
82 cef_build_type = get_option('cef_build_type')
83 have_cef = (cef_dir != '')
84 if have_cef
85         # This is done in the top-level file; just kept here for reference.
86         # add_project_arguments('-DHAVE_CEF=1', language: 'cpp')
87
88         system_cef = (cef_build_type == 'system')
89         if system_cef
90                 cef_lib_dir = cef_dir
91                 cef_resource_dir = '/usr/share/cef/Resources'
92         else
93                 cef_lib_dir = join_paths(cef_dir, cef_build_type)
94                 cef_resource_dir = join_paths(cef_dir, 'Resources')
95
96                 nageru_include_dirs += include_directories(cef_dir)
97                 nageru_include_dirs += include_directories(join_paths(cef_dir, 'include'))
98                 nageru_build_rpath = cef_lib_dir
99                 nageru_install_rpath = '$ORIGIN/'
100         endif
101
102         cefdep = cxx.find_library('cef')
103         nageru_deps += cefdep
104
105         # CEF wrapper library; not built as part of the CEF binary distribution,
106         # but should be if CEF is installed as a system library.
107         if system_cef
108                 cefdlldep = cxx.find_library('cef_dll_wrapper')
109                 nageru_deps += cefdlldep
110         else
111                 cmake = find_program('cmake')
112                 cef_compile_script = find_program('scripts/compile_cef_dll_wrapper.sh')
113
114                 cef_dll_target = custom_target('libcef_dll_wrapper',
115                         input: join_paths(cef_dir, 'libcef_dll/CMakeLists.txt'),
116                         output: ['libcef_dll_wrapper.a', 'cef-stamp'],
117                         command: [cef_compile_script, '@BUILD_DIR@', cef_dir, cmake, '@OUTPUT@'])
118
119                 # Putting the .a in sources seemingly hits a bug where the .a files get sorted
120                 # in the wrong order. This is a workaround; see
121                 # https://github.com/mesonbuild/meson/issues/3613#issuecomment-408276296 .
122                 cefdlldep = declare_dependency(sources: cef_dll_target[1], link_args: cef_dll_target.full_path())
123                 nageru_deps += cefdlldep
124         endif
125
126         cef_libs = ['libEGL.so', 'libGLESv2.so', 'natives_blob.bin', 'snapshot_blob.bin', 'v8_context_snapshot.bin']
127         cef_resources = ['cef.pak', 'cef_100_percent.pak', 'cef_200_percent.pak', 'cef_extensions.pak', 'devtools_resources.pak']
128         if not get_option('cef_no_icudtl')
129                 cef_resources += ['icudtl.dat']
130         endif
131         if cef_build_type != 'system'
132                 cef_libs += ['libcef.so']
133         endif
134
135         # Symlink the files into the build directory, so that running nageru without ninja install works.
136         run_command('mkdir', join_paths(meson.current_build_dir(), 'locales/'))
137         foreach file : cef_libs
138                 run_command('ln', '-s', join_paths(cef_lib_dir, file), meson.current_build_dir())
139                 install_data(join_paths(cef_lib_dir, file), install_dir: exe_dir)
140         endforeach
141         foreach file : cef_resources
142                 run_command('ln', '-s', join_paths(cef_resource_dir, file), meson.current_build_dir())
143                 install_data(join_paths(cef_resource_dir, file), install_dir: exe_dir)
144         endforeach
145         run_command('ln', '-s', join_paths(cef_resource_dir, 'locales/en-US.pak'), join_paths(meson.current_build_dir(), 'locales/'))
146         install_data(join_paths(cef_resource_dir, 'locales/en-US.pak'), install_dir: join_paths(exe_dir, 'locales'))
147 endif
148
149 # bmusb.
150 if embedded_bmusb
151         bmusb_dir = include_directories('nageru/bmusb')
152         nageru_include_dirs += bmusb_dir
153
154         bmusb = static_library('bmusb', 'nageru/bmusb/bmusb.cpp', 'nageru/bmusb/fake_capture.cpp',
155                 dependencies: [libusbdep],
156                 include_directories: [bmusb_dir])
157         nageru_link_with += bmusb
158         kaeru_link_with += bmusb
159 else
160         nageru_deps += bmusbdep
161         kaeru_extra_deps += bmusbdep
162 endif
163
164 # Protobuf compilation.
165 gen = generator(protoc, \
166         output    : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
167         arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/nageru', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
168 proto_generated = gen.process(['nageru/state.proto', 'nageru/midi_mapping.proto', 'nageru/json.proto'])
169 protobuf_lib = static_library('protobufs', proto_generated, dependencies: nageru_deps, include_directories: nageru_include_dirs)
170 protobuf_hdrs = declare_dependency(sources: proto_generated)
171 nageru_link_with += protobuf_lib
172
173 # Preprocess Qt as needed.
174 qt_files = qt5.preprocess(
175         moc_headers: ['nageru/analyzer.h', 'nageru/clickable_label.h', 'nageru/compression_reduction_meter.h', 'nageru/correlation_meter.h',
176                 'nageru/ellipsis_label.h', 'nageru/glwidget.h', 'nageru/input_mapping_dialog.h', 'nageru/lrameter.h', 'nageru/mainwindow.h', 'nageru/midi_mapping_dialog.h',
177                 'nageru/nonlinear_fader.h', 'nageru/vumeter.h'],
178         ui_files: ['nageru/analyzer.ui', 'nageru/audio_expanded_view.ui', 'nageru/audio_miniview.ui', 'nageru/display.ui',
179                 'nageru/input_mapping.ui', 'nageru/mainwindow.ui', 'nageru/midi_mapping.ui'],
180         dependencies: qt5deps)
181
182 # Qt objects.
183 nageru_srcs += ['nageru/glwidget.cpp', 'nageru/mainwindow.cpp', 'nageru/vumeter.cpp', 'nageru/lrameter.cpp', 'nageru/compression_reduction_meter.cpp',
184         'nageru/correlation_meter.cpp', 'nageru/analyzer.cpp', 'nageru/input_mapping_dialog.cpp', 'nageru/midi_mapping_dialog.cpp',
185         'nageru/nonlinear_fader.cpp', 'nageru/context_menus.cpp', 'nageru/vu_common.cpp', 'nageru/piecewise_interpolator.cpp', 'nageru/midi_mapper.cpp']
186
187 # Auxiliary objects used for nearly everything.
188 aux_srcs = ['nageru/flags.cpp']
189 aux = static_library('aux', aux_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
190 nageru_link_with += aux
191
192 # Audio objects.
193 audio_mixer_srcs = ['nageru/audio_mixer.cpp', 'nageru/alsa_input.cpp', 'nageru/alsa_pool.cpp', 'nageru/ebu_r128_proc.cc', 'nageru/stereocompressor.cpp',
194         'nageru/resampling_queue.cpp', 'nageru/flags.cpp', 'nageru/correlation_measurer.cpp', 'nageru/filter.cpp', 'nageru/input_mapping.cpp']
195 audio = static_library('audio', audio_mixer_srcs, dependencies: [nageru_deps, protobuf_hdrs], include_directories: nageru_include_dirs)
196 nageru_link_with += audio
197
198 # Mixer objects.
199 nageru_srcs += ['nageru/chroma_subsampler.cpp', 'nageru/v210_converter.cpp', 'nageru/mixer.cpp', 'nageru/pbo_frame_allocator.cpp',
200         'nageru/theme.cpp', 'nageru/image_input.cpp', 'nageru/alsa_output.cpp',
201         'nageru/timecode_renderer.cpp', 'nageru/tweaked_inputs.cpp', 'nageru/mjpeg_encoder.cpp']
202
203 # Streaming and encoding objects (largely the set that is shared between Nageru and Kaeru).
204 stream_srcs = ['nageru/quicksync_encoder.cpp', 'nageru/x264_encoder.cpp', 'nageru/x264_dynamic.cpp', 'nageru/x264_speed_control.cpp', 'nageru/video_encoder.cpp',
205         'nageru/audio_encoder.cpp', 'nageru/ffmpeg_util.cpp', 'nageru/ffmpeg_capture.cpp',
206         'nageru/print_latency.cpp', 'nageru/basic_stats.cpp', 'nageru/ref_counted_frame.cpp']
207 stream = static_library('stream', stream_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
208 nageru_link_with += stream
209
210 # DeckLink.
211 nageru_srcs += ['nageru/decklink_capture.cpp', 'nageru/decklink_util.cpp', 'nageru/decklink_output.cpp',
212         'nageru/decklink/DeckLinkAPIDispatch.cpp']
213 decklink_dir = include_directories('nageru/decklink')
214 nageru_include_dirs += decklink_dir
215
216 # CEF input.
217 if have_cef
218         nageru_srcs += ['nageru/nageru_cef_app.cpp', 'nageru/cef_capture.cpp']
219 endif
220
221 nageru_srcs += qt_files
222 nageru_srcs += proto_generated
223
224 # Shaders needed at runtime.
225 shaders = ['nageru/cbcr_subsample.vert', 'nageru/cbcr_subsample.frag', 'nageru/uyvy_subsample.vert', 'nageru/uyvy_subsample.frag', 'nageru/v210_subsample.comp', 'nageru/timecode.vert', 'nageru/timecode.frag', 'nageru/timecode_10bit.frag']
226 foreach shader : shaders
227         run_command('ln', '-s', join_paths(meson.current_source_dir(), shader), meson.current_build_dir())
228 endforeach
229
230 nageru_shader_srcs = bin2h_gen.process(shaders)
231 nageru_srcs += nageru_shader_srcs
232
233 # Everything except main.cpp. (We do this because if you specify a .cpp file in
234 # both Nageru and Kaeru, it gets compiled twice. In the older Makefiles, Kaeru
235 # depended on a smaller set of objects.)
236 core = static_library('core', nageru_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
237 nageru_link_with += core
238
239 # Nageru executable; it goes into /usr/lib/nageru since CEF files go there, too
240 # (we can't put them straight into /usr/bin).
241 executable('nageru', 'nageru/main.cpp',
242         dependencies: nageru_deps,
243         include_directories: nageru_include_dirs,
244         link_with: nageru_link_with,
245         build_rpath: nageru_build_rpath,
246         install_rpath: nageru_install_rpath,
247         install: true,
248         install_dir: exe_dir
249 )
250 meson.add_install_script('nageru/scripts/setup_nageru_symlink.sh')
251
252 # Kaeru executable.
253 executable('kaeru', 'nageru/kaeru.cpp',
254         dependencies: [nageru_deps, kaeru_extra_deps],
255         include_directories: nageru_include_dirs,
256         link_with: [stream, aux, kaeru_link_with],
257         install: true)
258
259 # Audio mixer microbenchmark.
260 executable('benchmark_audio_mixer', 'nageru/benchmark_audio_mixer.cpp', dependencies: nageru_deps, include_directories: nageru_include_dirs, link_with: [audio, aux])
261
262 # These are needed for a default run.
263 data_files = ['nageru/theme.lua', 'nageru/simple.lua', 'nageru/bg.jpeg', 'nageru/akai_midimix.midimapping']
264 install_data(data_files, install_dir: join_paths(get_option('prefix'), 'share/nageru'))
265 foreach file : data_files
266         run_command('ln', '-s', join_paths(meson.current_source_dir(), file), meson.current_build_dir())
267 endforeach
268
269 # Futatabi. (Not a subdir() because we don't want the output in nageru/nageru.)
270
271 # Protobuf compilation.
272 gen = generator(protoc, \
273         output    : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
274         arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/futatabi', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
275 proto_generated = gen.process('futatabi/state.proto', 'futatabi/frame.proto')
276
277 # Preprocess Qt as needed.
278 moc_files = qt5.preprocess(
279         moc_headers: ['futatabi/mainwindow.h', 'futatabi/jpeg_frame_view.h', 'futatabi/clip_list.h'],
280         ui_files: ['futatabi/mainwindow.ui'],
281         dependencies: qt5deps)
282
283 # Flow objects.
284 futatabi_srcs = ['futatabi/flow.cpp', 'futatabi/gpu_timers.cpp']
285
286 # All the other files.
287 futatabi_srcs += ['futatabi/main.cpp', 'futatabi/player.cpp', 'futatabi/video_stream.cpp', 'futatabi/chroma_subsampler.cpp']
288 futatabi_srcs += ['futatabi/vaapi_jpeg_decoder.cpp', 'futatabi/db.cpp', 'futatabi/ycbcr_converter.cpp', 'futatabi/flags.cpp']
289 futatabi_srcs += ['futatabi/mainwindow.cpp', 'futatabi/jpeg_frame_view.cpp', 'futatabi/clip_list.cpp', 'futatabi/frame_on_disk.cpp']
290 futatabi_srcs += ['futatabi/export.cpp']
291 futatabi_srcs += moc_files
292 futatabi_srcs += proto_generated
293
294 # Shaders needed at runtime.
295 shaders = ['futatabi/chroma_subsample.vert', 'futatabi/densify.vert', 'futatabi/equations.vert', 'futatabi/hole_fill.vert', 'futatabi/motion_search.vert', 'futatabi/sor.vert', 'futatabi/splat.vert', 'futatabi/vs.vert']
296 shaders += ['futatabi/add_base_flow.frag', 'futatabi/blend.frag', 'futatabi/chroma_subsample.frag', 'futatabi/densify.frag', 'futatabi/derivatives.frag', 'futatabi/diffusivity.frag',
297         'futatabi/equations.frag', 'futatabi/gray.frag', 'futatabi/hole_blend.frag', 'futatabi/hole_fill.frag', 'futatabi/motion_search.frag', 'futatabi/prewarp.frag', 'futatabi/resize_flow.frag',
298         'futatabi/sobel.frag', 'futatabi/sor.frag', 'futatabi/splat.frag']
299
300 foreach shader : shaders
301         run_command('ln', '-s', join_paths(meson.current_source_dir(), shader), meson.current_build_dir())
302 endforeach
303
304 futatabi_shader_srcs = bin2h_gen.process(shaders)
305 futatabi_srcs += futatabi_shader_srcs
306
307 executable('futatabi', futatabi_srcs,
308         dependencies: [shareddep, qt5deps, libjpegdep, movitdep, libmicrohttpddep, protobufdep, sqlite3dep, vax11dep, vadrmdep, x11dep, libavformatdep, libavcodecdep, libavutildep, libswscaledep],
309         link_with: shared,
310         include_directories: [include_directories('futatabi')],
311         install: true)
312
313 # Test binaries for the optical flow code.
314 if sdl2dep.found() and sdl2_imagedep.found()
315         executable('flow', 'futatabi/flow_main.cpp', 'futatabi/flow.cpp', 'futatabi/gpu_timers.cpp', futatabi_shader_srcs, dependencies: [shareddep, epoxydep, sdl2dep, sdl2_imagedep])
316 endif
317 executable('eval', 'futatabi/eval.cpp', 'futatabi/util.cpp')
318 executable('vis', 'futatabi/vis.cpp', 'futatabi/util.cpp')