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