1 project('nageru', 'cpp', default_options: ['buildtype=debugoptimized'])
3 protoc = find_program('protoc')
4 cxx = meson.get_compiler('cpp')
6 # Use lld if we can; it links a lot faster than ld.bfd or gold.
8 code = '''#include <stdio.h>
9 int main() { printf("Hello, world!\n"); return 0; }
11 if cxx.links(code, args: '-fuse-ld=lld', name: 'check for LLD')
12 nageru_link_args += '-fuse-ld=lld'
15 embedded_bmusb = get_option('embedded_bmusb')
17 alsadep = dependency('alsa')
18 bmusbdep = dependency('bmusb', required: not embedded_bmusb)
19 dldep = cxx.find_library('dl')
20 epoxydep = dependency('epoxy')
21 libavcodecdep = dependency('libavcodec')
22 libavformatdep = dependency('libavformat')
23 libavresampledep = dependency('libavresample')
24 libavutildep = dependency('libavutil')
25 libjpegdep = dependency('libjpeg')
26 libmicrohttpddep = dependency('libmicrohttpd')
27 libswscaledep = dependency('libswscale')
28 libusbdep = dependency('libusb-1.0')
29 luajitdep = dependency('luajit')
30 movitdep = dependency('movit')
31 protobufdep = dependency('protobuf')
32 qcustomplotdep = cxx.find_library('qcustomplot')
33 qt5deps = dependency('qt5', modules: ['Core', 'Gui', 'Widgets', 'OpenGLExtensions', 'OpenGL', 'PrintSupport'])
34 threaddep = dependency('threads')
35 vadrmdep = dependency('libva-drm')
36 vax11dep = dependency('libva-x11')
37 x11dep = dependency('x11')
38 x264dep = dependency('x264')
39 zitaresamplerdep = cxx.find_library('zita-resampler')
42 nageru_deps = [qt5deps, libjpegdep, movitdep, libmicrohttpddep, protobufdep,
43 vax11dep, vadrmdep, x11dep, libavformatdep, libavresampledep, libavcodecdep, libavutildep,
44 libswscaledep, libusbdep, luajitdep, dldep, x264dep, alsadep, zitaresamplerdep,
45 qcustomplotdep, threaddep]
46 nageru_include_dirs = []
48 nageru_build_rpath = ''
49 nageru_install_rpath = ''
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 # Add the right MOVIT_SHADER_DIR definition.
66 r = run_command('pkg-config', '--variable=shaderdir', 'movit')
67 if r.returncode() != 0
68 error('Movit pkg-config installation is broken.')
70 add_project_arguments('-DMOVIT_SHADER_DIR="' + r.stdout().strip() + '"', language: 'cpp')
73 exe_dir = join_paths(get_option('prefix'), 'lib/nageru')
74 cef_dir = get_option('cef_dir')
75 cef_build_type = get_option('cef_build_type')
76 have_cef = (cef_dir != '')
78 add_project_arguments('-DHAVE_CEF=1', language: 'cpp')
80 system_cef = (cef_build_type == 'system')
83 cef_resource_dir = '/usr/share/cef/Resources'
85 cef_lib_dir = join_paths(cef_dir, cef_build_type)
86 cef_resource_dir = join_paths(cef_dir, 'Resources')
88 nageru_include_dirs += include_directories(cef_dir)
89 nageru_include_dirs += include_directories(join_paths(cef_dir, 'include'))
90 nageru_build_rpath = cef_lib_dir
91 nageru_install_rpath = '$ORIGIN/'
94 cefdep = cxx.find_library('cef')
97 # CEF wrapper library; not built as part of the CEF binary distribution,
98 # but should be if CEF is installed as a system library.
100 cefdlldep = cxx.find_library('cef_dll_wrapper')
101 nageru_deps += cefdlldep
103 cmake = find_program('cmake')
104 cef_compile_script = find_program('scripts/compile_cef_dll_wrapper.sh')
106 cef_dll_target = custom_target('libcef_dll_wrapper',
107 input: join_paths(cef_dir, 'libcef_dll/CMakeLists.txt'),
108 output: ['libcef_dll_wrapper.a', 'cef-stamp'],
109 command: [cef_compile_script, '@BUILD_DIR@', cef_dir, cmake, '@OUTPUT@'])
111 # Putting the .a in sources seemingly hits a bug where the .a files get sorted
112 # in the wrong order. This is a workaround; see
113 # https://github.com/mesonbuild/meson/issues/3613#issuecomment-408276296 .
114 cefdlldep = declare_dependency(sources: cef_dll_target[1], link_args: cef_dll_target.full_path())
115 nageru_deps += cefdlldep
118 cef_libs = ['libEGL.so', 'libGLESv2.so', 'natives_blob.bin', 'snapshot_blob.bin', 'v8_context_snapshot.bin']
119 cef_resources = ['cef.pak', 'cef_100_percent.pak', 'cef_200_percent.pak', 'cef_extensions.pak', 'devtools_resources.pak']
120 if not get_option('cef_no_icudtl')
121 cef_resources += ['icudtl.dat']
123 if cef_build_type != 'system'
124 cef_libs += ['libcef.so']
127 # Symlink the files into the build directory, so that running nageru without ninja install works.
128 run_command('mkdir', join_paths(meson.current_build_dir(), 'locales/'))
129 foreach file : cef_libs
130 run_command('ln', '-s', join_paths(cef_lib_dir, file), meson.current_build_dir())
131 install_data(join_paths(cef_lib_dir, file), install_dir: exe_dir)
133 foreach file : cef_resources
134 run_command('ln', '-s', join_paths(cef_resource_dir, file), meson.current_build_dir())
135 install_data(join_paths(cef_resource_dir, file), install_dir: exe_dir)
137 run_command('ln', '-s', join_paths(cef_resource_dir, 'locales/en-US.pak'), join_paths(meson.current_build_dir(), 'locales/'))
138 install_data(join_paths(cef_resource_dir, 'locales/en-US.pak'), install_dir: join_paths(exe_dir, 'locales'))
143 bmusb_dir = include_directories('bmusb')
144 nageru_include_dirs += bmusb_dir
146 bmusb = static_library('bmusb', 'bmusb/bmusb.cpp', 'bmusb/fake_capture.cpp',
147 dependencies: [libusbdep],
148 include_directories: [bmusb_dir])
149 nageru_link_with += bmusb
150 kaeru_link_with += bmusb
152 nageru_deps += bmusbdep
153 kaeru_extra_deps += bmusbdep
156 # Protobuf compilation.
157 gen = generator(protoc, \
158 output : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
159 arguments : ['--proto_path=@CURRENT_SOURCE_DIR@', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
160 proto_generated = gen.process(['state.proto', 'midi_mapping.proto', 'json.proto'])
161 protobuf_lib = static_library('protobufs', proto_generated, dependencies: nageru_deps, include_directories: nageru_include_dirs)
162 protobuf_hdrs = declare_dependency(sources: proto_generated)
163 nageru_link_with += protobuf_lib
165 # Preprocess Qt as needed.
166 qt_files = qt5.preprocess(
167 moc_headers: ['aboutdialog.h', 'analyzer.h', 'clickable_label.h', 'compression_reduction_meter.h', 'correlation_meter.h',
168 'ellipsis_label.h', 'glwidget.h', 'input_mapping_dialog.h', 'lrameter.h', 'mainwindow.h', 'midi_mapping_dialog.h',
169 'nonlinear_fader.h', 'vumeter.h'],
170 ui_files: ['aboutdialog.ui', 'analyzer.ui', 'audio_expanded_view.ui', 'audio_miniview.ui', 'display.ui',
171 'input_mapping.ui', 'mainwindow.ui', 'midi_mapping.ui'],
172 dependencies: qt5deps)
175 srcs += ['glwidget.cpp', 'mainwindow.cpp', 'vumeter.cpp', 'lrameter.cpp', 'compression_reduction_meter.cpp',
176 'correlation_meter.cpp', 'aboutdialog.cpp', 'analyzer.cpp', 'input_mapping_dialog.cpp', 'midi_mapping_dialog.cpp',
177 'nonlinear_fader.cpp', 'context_menus.cpp', 'vu_common.cpp', 'piecewise_interpolator.cpp', 'midi_mapper.cpp']
179 # Auxiliary objects used for nearly everything.
180 aux_srcs = ['metrics.cpp', 'flags.cpp']
181 aux = static_library('aux', aux_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
182 nageru_link_with += aux
185 audio_mixer_srcs = ['audio_mixer.cpp', 'alsa_input.cpp', 'alsa_pool.cpp', 'ebu_r128_proc.cc', 'stereocompressor.cpp',
186 'resampling_queue.cpp', 'flags.cpp', 'correlation_measurer.cpp', 'filter.cpp', 'input_mapping.cpp']
187 audio = static_library('audio', audio_mixer_srcs, dependencies: [nageru_deps, protobuf_hdrs], include_directories: nageru_include_dirs)
188 nageru_link_with += audio
191 srcs += ['chroma_subsampler.cpp', 'v210_converter.cpp', 'mixer.cpp', 'pbo_frame_allocator.cpp',
192 'context.cpp', 'theme.cpp', 'image_input.cpp', 'alsa_output.cpp',
193 'disk_space_estimator.cpp', 'timecode_renderer.cpp', 'tweaked_inputs.cpp', 'mjpeg_encoder.cpp']
195 # Streaming and encoding objects (largely the set that is shared between Nageru and Kaeru).
196 stream_srcs = ['quicksync_encoder.cpp', 'x264_encoder.cpp', 'x264_dynamic.cpp', 'x264_speed_control.cpp', 'video_encoder.cpp',
197 'metacube2.cpp', 'mux.cpp', 'audio_encoder.cpp', 'ffmpeg_raii.cpp', 'ffmpeg_util.cpp', 'httpd.cpp', 'ffmpeg_capture.cpp',
198 'print_latency.cpp', 'basic_stats.cpp', 'ref_counted_frame.cpp']
199 stream = static_library('stream', stream_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
200 nageru_link_with += stream
203 srcs += ['decklink_capture.cpp', 'decklink_util.cpp', 'decklink_output.cpp', 'memcpy_interleaved.cpp',
204 'decklink/DeckLinkAPIDispatch.cpp']
205 decklink_dir = include_directories('decklink')
206 nageru_include_dirs += decklink_dir
210 srcs += ['nageru_cef_app.cpp', 'cef_capture.cpp']
214 srcs += proto_generated
216 # Everything except main.cpp. (We do this because if you specify a .cpp file in
217 # both Nageru and Kaeru, it gets compiled twice. In the older Makefiles, Kaeru
218 # depended on a smaller set of objects.)
219 core = static_library('core', srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
220 nageru_link_with += core
222 # Nageru executable; it goes into /usr/lib/nageru since CEF files go there, too
223 # (we can't put them straight into /usr/bin).
224 executable('nageru', 'main.cpp',
225 dependencies: nageru_deps,
226 include_directories: nageru_include_dirs,
227 link_with: nageru_link_with,
228 link_args: nageru_link_args,
229 build_rpath: nageru_build_rpath,
230 install_rpath: nageru_install_rpath,
234 meson.add_install_script('scripts/setup_nageru_symlink.sh')
237 executable('kaeru', 'kaeru.cpp',
238 dependencies: [nageru_deps, kaeru_extra_deps],
239 include_directories: nageru_include_dirs,
240 link_with: [stream, aux, kaeru_link_with],
241 link_args: nageru_link_args,
244 # Audio mixer microbenchmark.
245 executable('benchmark_audio_mixer', 'benchmark_audio_mixer.cpp', dependencies: nageru_deps, include_directories: nageru_include_dirs, link_args: nageru_link_args, link_with: [audio, aux])
247 # These are needed for a default run.
248 data_files = ['theme.lua', 'simple.lua', 'bg.jpeg', 'akai_midimix.midimapping']
249 install_data(data_files, install_dir: join_paths(get_option('prefix'), 'share/nageru'))
250 foreach file : data_files
251 run_command('ln', '-s', join_paths(meson.current_source_dir(), file), meson.current_build_dir())