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