2 protoc = find_program('protoc')
3 cxx = meson.get_compiler('cpp')
5 embedded_bmusb = get_option('embedded_bmusb')
7 alsadep = dependency('alsa')
8 bmusbdep = dependency('bmusb', required: not embedded_bmusb)
9 dldep = cxx.find_library('dl')
10 epoxydep = dependency('epoxy')
11 libavcodecdep = dependency('libavcodec')
12 libavformatdep = dependency('libavformat')
13 libavresampledep = dependency('libavresample')
14 libavutildep = dependency('libavutil')
15 libjpegdep = dependency('libjpeg')
16 libswscaledep = dependency('libswscale')
17 libusbdep = dependency('libusb-1.0')
18 luajitdep = dependency('luajit')
19 movitdep = dependency('movit')
20 protobufdep = dependency('protobuf')
21 qcustomplotdep = cxx.find_library('qcustomplot')
22 qt5deps = dependency('qt5', modules: ['Core', 'Gui', 'Widgets', 'OpenGLExtensions', 'OpenGL', 'PrintSupport'])
23 threaddep = dependency('threads')
24 vadrmdep = dependency('libva-drm')
25 vax11dep = dependency('libva-x11')
26 x11dep = dependency('x11')
27 x264dep = dependency('x264')
28 zitaresamplerdep = cxx.find_library('zita-resampler')
31 nageru_deps = [shareddep, qt5deps, libjpegdep, movitdep, protobufdep,
32 vax11dep, vadrmdep, x11dep, libavformatdep, libavresampledep, libavcodecdep, libavutildep,
33 libswscaledep, libusbdep, luajitdep, dldep, x264dep, alsadep, zitaresamplerdep,
34 qcustomplotdep, threaddep]
35 nageru_include_dirs = []
37 nageru_build_rpath = ''
38 nageru_install_rpath = ''
44 exe_dir = join_paths(get_option('prefix'), 'lib/nageru')
45 cef_dir = get_option('cef_dir')
46 cef_build_type = get_option('cef_build_type')
47 have_cef = (cef_dir != '')
49 add_project_arguments('-DHAVE_CEF=1', language: 'cpp')
51 system_cef = (cef_build_type == 'system')
54 cef_resource_dir = '/usr/share/cef/Resources'
56 cef_lib_dir = join_paths(cef_dir, cef_build_type)
57 cef_resource_dir = join_paths(cef_dir, 'Resources')
59 nageru_include_dirs += include_directories(cef_dir)
60 nageru_include_dirs += include_directories(join_paths(cef_dir, 'include'))
61 nageru_build_rpath = cef_lib_dir
62 nageru_install_rpath = '$ORIGIN/'
65 cefdep = cxx.find_library('cef')
68 # CEF wrapper library; not built as part of the CEF binary distribution,
69 # but should be if CEF is installed as a system library.
71 cefdlldep = cxx.find_library('cef_dll_wrapper')
72 nageru_deps += cefdlldep
74 cmake = find_program('cmake')
75 cef_compile_script = find_program('scripts/compile_cef_dll_wrapper.sh')
77 cef_dll_target = custom_target('libcef_dll_wrapper',
78 input: join_paths(cef_dir, 'libcef_dll/CMakeLists.txt'),
79 output: ['libcef_dll_wrapper.a', 'cef-stamp'],
80 command: [cef_compile_script, '@BUILD_DIR@', cef_dir, cmake, '@OUTPUT@'])
82 # Putting the .a in sources seemingly hits a bug where the .a files get sorted
83 # in the wrong order. This is a workaround; see
84 # https://github.com/mesonbuild/meson/issues/3613#issuecomment-408276296 .
85 cefdlldep = declare_dependency(sources: cef_dll_target[1], link_args: cef_dll_target.full_path())
86 nageru_deps += cefdlldep
89 cef_libs = ['libEGL.so', 'libGLESv2.so', 'natives_blob.bin', 'snapshot_blob.bin', 'v8_context_snapshot.bin']
90 cef_resources = ['cef.pak', 'cef_100_percent.pak', 'cef_200_percent.pak', 'cef_extensions.pak', 'devtools_resources.pak']
91 if not get_option('cef_no_icudtl')
92 cef_resources += ['icudtl.dat']
94 if cef_build_type != 'system'
95 cef_libs += ['libcef.so']
98 # Symlink the files into the build directory, so that running nageru without ninja install works.
99 run_command('mkdir', join_paths(meson.current_build_dir(), 'locales/'))
100 foreach file : cef_libs
101 run_command('ln', '-s', join_paths(cef_lib_dir, file), meson.current_build_dir())
102 install_data(join_paths(cef_lib_dir, file), install_dir: exe_dir)
104 foreach file : cef_resources
105 run_command('ln', '-s', join_paths(cef_resource_dir, file), meson.current_build_dir())
106 install_data(join_paths(cef_resource_dir, file), install_dir: exe_dir)
108 run_command('ln', '-s', join_paths(cef_resource_dir, 'locales/en-US.pak'), join_paths(meson.current_build_dir(), 'locales/'))
109 install_data(join_paths(cef_resource_dir, 'locales/en-US.pak'), install_dir: join_paths(exe_dir, 'locales'))
114 bmusb_dir = include_directories('bmusb')
115 nageru_include_dirs += bmusb_dir
117 bmusb = static_library('bmusb', 'bmusb/bmusb.cpp', 'bmusb/fake_capture.cpp',
118 dependencies: [libusbdep],
119 include_directories: [bmusb_dir])
120 nageru_link_with += bmusb
121 kaeru_link_with += bmusb
123 nageru_deps += bmusbdep
124 kaeru_extra_deps += bmusbdep
127 # Protobuf compilation.
128 gen = generator(protoc, \
129 output : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
130 arguments : ['--proto_path=@CURRENT_SOURCE_DIR@', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
131 proto_generated = gen.process(['state.proto', 'midi_mapping.proto', 'json.proto'])
132 protobuf_lib = static_library('protobufs', proto_generated, dependencies: nageru_deps, include_directories: nageru_include_dirs)
133 protobuf_hdrs = declare_dependency(sources: proto_generated)
134 nageru_link_with += protobuf_lib
136 # Preprocess Qt as needed.
137 qt_files = qt5.preprocess(
138 moc_headers: ['aboutdialog.h', 'analyzer.h', 'clickable_label.h', 'compression_reduction_meter.h', 'correlation_meter.h',
139 'ellipsis_label.h', 'glwidget.h', 'input_mapping_dialog.h', 'lrameter.h', 'mainwindow.h', 'midi_mapping_dialog.h',
140 'nonlinear_fader.h', 'vumeter.h'],
141 ui_files: ['aboutdialog.ui', 'analyzer.ui', 'audio_expanded_view.ui', 'audio_miniview.ui', 'display.ui',
142 'input_mapping.ui', 'mainwindow.ui', 'midi_mapping.ui'],
143 dependencies: qt5deps)
146 srcs += ['glwidget.cpp', 'mainwindow.cpp', 'vumeter.cpp', 'lrameter.cpp', 'compression_reduction_meter.cpp',
147 'correlation_meter.cpp', 'aboutdialog.cpp', 'analyzer.cpp', 'input_mapping_dialog.cpp', 'midi_mapping_dialog.cpp',
148 'nonlinear_fader.cpp', 'context_menus.cpp', 'vu_common.cpp', 'piecewise_interpolator.cpp', 'midi_mapper.cpp']
150 # Auxiliary objects used for nearly everything.
151 aux_srcs = ['flags.cpp']
152 aux = static_library('aux', aux_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
153 nageru_link_with += aux
156 audio_mixer_srcs = ['audio_mixer.cpp', 'alsa_input.cpp', 'alsa_pool.cpp', 'ebu_r128_proc.cc', 'stereocompressor.cpp',
157 'resampling_queue.cpp', 'flags.cpp', 'correlation_measurer.cpp', 'filter.cpp', 'input_mapping.cpp']
158 audio = static_library('audio', audio_mixer_srcs, dependencies: [nageru_deps, protobuf_hdrs], include_directories: nageru_include_dirs)
159 nageru_link_with += audio
162 srcs += ['chroma_subsampler.cpp', 'v210_converter.cpp', 'mixer.cpp', 'pbo_frame_allocator.cpp',
163 'theme.cpp', 'image_input.cpp', 'alsa_output.cpp',
164 'timecode_renderer.cpp', 'tweaked_inputs.cpp']
166 # Streaming and encoding objects (largely the set that is shared between Nageru and Kaeru).
167 stream_srcs = ['quicksync_encoder.cpp', 'x264_encoder.cpp', 'x264_dynamic.cpp', 'x264_speed_control.cpp', 'video_encoder.cpp',
168 'audio_encoder.cpp', 'ffmpeg_util.cpp', 'ffmpeg_capture.cpp',
169 'print_latency.cpp', 'basic_stats.cpp', 'ref_counted_frame.cpp']
170 stream = static_library('stream', stream_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
171 nageru_link_with += stream
174 srcs += ['decklink_capture.cpp', 'decklink_util.cpp', 'decklink_output.cpp',
175 'decklink/DeckLinkAPIDispatch.cpp']
176 decklink_dir = include_directories('decklink')
177 nageru_include_dirs += decklink_dir
181 srcs += ['nageru_cef_app.cpp', 'cef_capture.cpp']
185 srcs += proto_generated
187 # Shaders needed at runtime.
188 shaders = ['cbcr_subsample.vert', 'cbcr_subsample.frag', 'uyvy_subsample.vert', 'uyvy_subsample.frag', 'v210_subsample.comp', 'timecode.vert', 'timecode.frag', 'timecode_10bit.frag']
189 foreach shader : shaders
190 run_command('ln', '-s', join_paths(meson.current_source_dir(), shader), meson.current_build_dir())
193 shader_srcs = bin2h_gen.process(shaders)
196 # Everything except main.cpp. (We do this because if you specify a .cpp file in
197 # both Nageru and Kaeru, it gets compiled twice. In the older Makefiles, Kaeru
198 # depended on a smaller set of objects.)
199 core = static_library('core', srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
200 nageru_link_with += core
202 # Nageru executable; it goes into /usr/lib/nageru since CEF files go there, too
203 # (we can't put them straight into /usr/bin).
204 executable('nageru', 'main.cpp',
205 dependencies: nageru_deps,
206 include_directories: nageru_include_dirs,
207 link_with: nageru_link_with,
208 build_rpath: nageru_build_rpath,
209 install_rpath: nageru_install_rpath,
213 meson.add_install_script('scripts/setup_nageru_symlink.sh')
216 executable('kaeru', 'kaeru.cpp',
217 dependencies: [nageru_deps, kaeru_extra_deps],
218 include_directories: nageru_include_dirs,
219 link_with: [stream, aux, kaeru_link_with],
222 # Audio mixer microbenchmark.
223 executable('benchmark_audio_mixer', 'benchmark_audio_mixer.cpp', dependencies: nageru_deps, include_directories: nageru_include_dirs, link_with: [audio, aux])
225 # These are needed for a default run.
226 data_files = ['theme.lua', 'simple.lua', 'bg.jpeg', 'akai_midimix.midimapping']
227 install_data(data_files, install_dir: join_paths(get_option('prefix'), 'share/nageru'))
228 foreach file : data_files
229 run_command('ln', '-s', join_paths(meson.current_source_dir(), file), meson.current_build_dir())