]> git.sesse.net Git - nageru/blobdiff - meson.build
Set CEF autoplay policy to be more lenient.
[nageru] / meson.build
index b537dd3cb26cba7e6a677a1b01ab1485a8f0cbda..b190b4ab757126b82294bc0f340492c1a9b73a37 100644 (file)
@@ -1,4 +1,6 @@
-project('nageru', 'cpp', default_options: ['buildtype=debugoptimized'], version: '1.8.0-pre')
+project('nageru', 'cpp', default_options: ['buildtype=debugoptimized'], version: '2.3.1-pre')
+
+add_project_arguments('-Wno-unqualified-std-cast-call', language: 'cpp')
 
 cxx = meson.get_compiler('cpp')
 qt5 = import('qt5')
@@ -9,21 +11,24 @@ embedded_bmusb = get_option('embedded_bmusb')
 alsadep = dependency('alsa')
 bmusbdep = dependency('bmusb', required: not embedded_bmusb)
 dldep = cxx.find_library('dl')
+eigendep = dependency('eigen3')
 epoxydep = dependency('epoxy')
 libavcodecdep = dependency('libavcodec')
 libavformatdep = dependency('libavformat')
-libavresampledep = dependency('libavresample')
+libswresampledep = dependency('libswresample')
 libavutildep = dependency('libavutil')
+libdrmdep = dependency('libdrm')
 libjpegdep = dependency('libjpeg')
 libswscaledep = dependency('libswscale')
 libusbdep = dependency('libusb-1.0')
 luajitdep = dependency('luajit')
 movitdep = dependency('movit')
 protobufdep = dependency('protobuf')
-qcustomplotdep = cxx.find_library('qcustomplot')
 qt5deps = dependency('qt5', modules: ['Core', 'Gui', 'Widgets', 'OpenGLExtensions', 'OpenGL', 'Network'])
-sdl2_imagedep = dependency('SDL2_image')
-sdl2dep = dependency('sdl2')
+sdl2_imagedep = dependency('SDL2_image', required: false)
+sdl2dep = dependency('sdl2', required: false)
+srtdep = dependency('srt', required: false)
+svtav1dep = dependency('SvtAv1Enc', required: false, version: '>=1.5.0')
 sqlite3dep = dependency('sqlite3')
 threaddep = dependency('threads')
 vadrmdep = dependency('libva-drm')
@@ -41,31 +46,29 @@ if cxx.links(code, args: '-fuse-ld=lld', name: 'check for LLD')
 endif
 
 # Add the right MOVIT_SHADER_DIR definition.
-r = run_command('pkg-config', '--variable=shaderdir', 'movit')
-if r.returncode() != 0
-       error('Movit pkg-config installation is broken.')
-endif
-add_project_arguments('-DMOVIT_SHADER_DIR="' + r.stdout().strip() + '"', language: 'cpp')
+movit_shader_dir = movitdep.get_pkgconfig_variable('shaderdir')
+add_project_arguments('-DMOVIT_SHADER_DIR="' + movit_shader_dir + '"', language: 'cpp')
 
 # Make the Nageru version available as a #define.
 add_project_arguments('-DNAGERU_VERSION="' + meson.project_version() + '"', language: 'cpp')
 
-# DeckLink has these issues, and we include it from various places.
-if cxx.has_argument('-Wno-non-virtual-dtor')
-       add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp')
-endif
-
-# FFmpeg has a lot of deprecated APIs whose replacements are not available
-# in Debian stable, so we suppress these warnings.
-if cxx.has_argument('-Wno-deprecated-declarations')
-       add_project_arguments('-Wno-deprecated-declarations', language: 'cpp')
-endif
+# Make the prefix (e.g. /usr/local) available as a #define.
+add_project_arguments('-DPREFIX="' + get_option('prefix') + '"', language: 'cpp')
 
 # This needs to be done before declaring any build targets.
 if get_option('cef_dir') != ''
        add_project_arguments('-DHAVE_CEF=1', language: 'cpp')
 endif
 
+if srtdep.found()
+       # NOTE: Seemingly there's no way to figure out if we have OpenSSL libsrt
+       # or gnutls libsrt, so we cannot check license compatibility here.
+       add_project_arguments('-DHAVE_SRT=1', language: 'cpp')
+endif
+if svtav1dep.found()
+       add_project_arguments('-DHAVE_AV1=1', language: 'cpp')
+endif
+
 top_include = include_directories('.')
 
 subdir('shared')
@@ -74,9 +77,9 @@ subdir('shared')
 
 nageru_srcs = []
 nageru_deps = [shareddep, qt5deps, libjpegdep, movitdep, protobufdep,
-       vax11dep, vadrmdep, x11dep, libavformatdep, libavresampledep, libavcodecdep, libavutildep,
-       libswscaledep, libusbdep, luajitdep, dldep, x264dep, alsadep, zitaresamplerdep,
-       qcustomplotdep, threaddep]
+       vax11dep, vadrmdep, x11dep, libavformatdep, libswresampledep, libavcodecdep, libavutildep,
+       libswscaledep, libusbdep, luajitdep, dldep, x264dep, svtav1dep, alsadep, zitaresamplerdep,
+       threaddep, eigendep, srtdep, libdrmdep]
 nageru_include_dirs = [include_directories('nageru')]
 nageru_link_with = []
 nageru_build_rpath = ''
@@ -97,7 +100,7 @@ if have_cef
        system_cef = (cef_build_type == 'system')
        if system_cef
                cef_lib_dir = cef_dir
-               cef_resource_dir = '/usr/share/cef/Resources'
+               cef_resource_dir = cef_dir
        else
                cef_lib_dir = join_paths(cef_dir, cef_build_type)
                cef_resource_dir = join_paths(cef_dir, 'Resources')
@@ -108,9 +111,6 @@ if have_cef
                nageru_install_rpath = '$ORIGIN/'
        endif
 
-       cefdep = cxx.find_library('cef')
-       nageru_deps += cefdep
-
        # CEF wrapper library; not built as part of the CEF binary distribution,
        # but should be if CEF is installed as a system library.
        if system_cef
@@ -118,49 +118,53 @@ if have_cef
                nageru_deps += cefdlldep
        else
                cmake = find_program('cmake')
-               cef_compile_script = find_program('scripts/compile_cef_dll_wrapper.sh')
+               cef_compile_script = find_program('nageru/scripts/compile_cef_dll_wrapper.sh')
 
                cef_dll_target = custom_target('libcef_dll_wrapper',
                        input: join_paths(cef_dir, 'libcef_dll/CMakeLists.txt'),
-                       output: ['libcef_dll_wrapper.a', 'cef-stamp'],
+                       output: ['libcef_dll_wrapper.a'],
                        command: [cef_compile_script, '@BUILD_DIR@', cef_dir, cmake, '@OUTPUT@'])
 
-               # Putting the .a in sources seemingly hits a bug where the .a files get sorted
-               # in the wrong order. This is a workaround; see
-               # https://github.com/mesonbuild/meson/issues/3613#issuecomment-408276296 .
-               cefdlldep = declare_dependency(sources: cef_dll_target[1], link_args: cef_dll_target.full_path())
+               cefdlldep = declare_dependency(link_with: cef_dll_target)
                nageru_deps += cefdlldep
        endif
 
-       cef_libs = ['libEGL.so', 'libGLESv2.so', 'natives_blob.bin', 'snapshot_blob.bin', 'v8_context_snapshot.bin']
-       cef_resources = ['cef.pak', 'cef_100_percent.pak', 'cef_200_percent.pak', 'cef_extensions.pak', 'devtools_resources.pak']
+       cef_libs = ['libEGL.so', 'libGLESv2.so', 'snapshot_blob.bin', 'v8_context_snapshot.bin']
+       cef_resources = ['resources.pak', 'chrome_100_percent.pak', 'chrome_200_percent.pak']
        if not get_option('cef_no_icudtl')
                cef_resources += ['icudtl.dat']
        endif
        if cef_build_type != 'system'
-               cef_libs += ['libcef.so']
+               cef_libs += ['libcef.so', 'libEGL.so', 'libGLESv2.so', 'libvk_swiftshader.so', 'libvulkan.so.1', 'vk_swiftshader_icd.json']
        endif
 
        # Symlink the files into the build directory, so that running nageru without ninja install works.
-       run_command('mkdir', join_paths(meson.current_build_dir(), 'locales/'))
+       run_command('mkdir', '-p', join_paths(meson.current_build_dir(), 'locales/'), check: true)
        foreach file : cef_libs
-               run_command('ln', '-s', join_paths(cef_lib_dir, file), meson.current_build_dir())
+               run_command('ln', '-sf', join_paths(cef_lib_dir, file), meson.current_build_dir(), check: true)
                install_data(join_paths(cef_lib_dir, file), install_dir: exe_dir)
        endforeach
        foreach file : cef_resources
-               run_command('ln', '-s', join_paths(cef_resource_dir, file), meson.current_build_dir())
+               run_command('ln', '-sf', join_paths(cef_resource_dir, file), meson.current_build_dir(), check: true)
                install_data(join_paths(cef_resource_dir, file), install_dir: exe_dir)
        endforeach
-       run_command('ln', '-s', join_paths(cef_resource_dir, 'locales/en-US.pak'), join_paths(meson.current_build_dir(), 'locales/'))
+       run_command('ln', '-sf', join_paths(cef_resource_dir, 'locales/en-US.pak'), join_paths(meson.current_build_dir(), 'locales/'), check: true)
        install_data(join_paths(cef_resource_dir, 'locales/en-US.pak'), install_dir: join_paths(exe_dir, 'locales'))
+
+       # NOTE: We link against libcef.so in the local directory, _not_ in the CEF directory,
+       # since upstream CEF searches for icudtl.dat in whatever path dladdr() says libcef.so
+       # comes from, and the upstream CEF tarballs have libcef.so and icudtl.dat in different
+       # directories. Thus, get both from the local symlinks we just created.
+       cefdep = cxx.find_library('cef', dirs: meson.current_build_dir())
+       nageru_deps += cefdep
 endif
 
 # bmusb.
 if embedded_bmusb
-       bmusb_dir = include_directories('bmusb')
+       bmusb_dir = include_directories('nageru/bmusb')
        nageru_include_dirs += bmusb_dir
 
-       bmusb = static_library('bmusb', 'bmusb/bmusb.cpp', 'bmusb/fake_capture.cpp',
+       bmusb = static_library('bmusb', 'nageru/bmusb/bmusb.cpp', 'nageru/bmusb/fake_capture.cpp',
                dependencies: [libusbdep],
                include_directories: [bmusb_dir])
        nageru_link_with += bmusb
@@ -173,9 +177,9 @@ endif
 # Protobuf compilation.
 gen = generator(protoc, \
        output    : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
-       arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/nageru', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
-proto_generated = gen.process(['nageru/state.proto', 'nageru/midi_mapping.proto', 'nageru/json.proto'])
-protobuf_lib = static_library('protobufs', proto_generated, dependencies: nageru_deps, include_directories: nageru_include_dirs)
+       arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/nageru', '--cpp_out=@BUILD_DIR@', '-I@CURRENT_SOURCE_DIR@/shared', '@INPUT@'])
+proto_generated = gen.process(['nageru/state.proto', 'nageru/json.proto', 'nageru/nageru_midi_mapping.proto'])
+protobuf_lib = static_library('nageru_protobufs', proto_generated, dependencies: nageru_deps, include_directories: nageru_include_dirs)
 protobuf_hdrs = declare_dependency(sources: proto_generated)
 nageru_link_with += protobuf_lib
 
@@ -183,7 +187,7 @@ nageru_link_with += protobuf_lib
 qt_files = qt5.preprocess(
        moc_headers: ['nageru/analyzer.h', 'nageru/clickable_label.h', 'nageru/compression_reduction_meter.h', 'nageru/correlation_meter.h',
                'nageru/ellipsis_label.h', 'nageru/glwidget.h', 'nageru/input_mapping_dialog.h', 'nageru/lrameter.h', 'nageru/mainwindow.h', 'nageru/midi_mapping_dialog.h',
-               'nageru/nonlinear_fader.h', 'nageru/vumeter.h'],
+               'nageru/nonlinear_fader.h', 'nageru/vumeter.h', 'nageru/rgb_histogram.h'],
        ui_files: ['nageru/analyzer.ui', 'nageru/audio_expanded_view.ui', 'nageru/audio_miniview.ui', 'nageru/display.ui',
                'nageru/input_mapping.ui', 'nageru/mainwindow.ui', 'nageru/midi_mapping.ui'],
        dependencies: qt5deps)
@@ -191,7 +195,7 @@ qt_files = qt5.preprocess(
 # Qt objects.
 nageru_srcs += ['nageru/glwidget.cpp', 'nageru/mainwindow.cpp', 'nageru/vumeter.cpp', 'nageru/lrameter.cpp', 'nageru/compression_reduction_meter.cpp',
        'nageru/correlation_meter.cpp', 'nageru/analyzer.cpp', 'nageru/input_mapping_dialog.cpp', 'nageru/midi_mapping_dialog.cpp',
-       'nageru/nonlinear_fader.cpp', 'nageru/context_menus.cpp', 'nageru/vu_common.cpp', 'nageru/piecewise_interpolator.cpp', 'nageru/midi_mapper.cpp']
+       'nageru/nonlinear_fader.cpp', 'nageru/context_menus.cpp', 'nageru/vu_common.cpp', 'nageru/piecewise_interpolator.cpp', 'nageru/midi_mapper.cpp', 'nageru/rgb_histogram.cpp']
 
 # Auxiliary objects used for nearly everything.
 aux_srcs = ['nageru/flags.cpp']
@@ -206,20 +210,27 @@ nageru_link_with += audio
 
 # Mixer objects.
 nageru_srcs += ['nageru/chroma_subsampler.cpp', 'nageru/v210_converter.cpp', 'nageru/mixer.cpp', 'nageru/pbo_frame_allocator.cpp',
-       'nageru/theme.cpp', 'nageru/image_input.cpp', 'nageru/alsa_output.cpp',
-       'nageru/timecode_renderer.cpp', 'nageru/tweaked_inputs.cpp', 'nageru/mjpeg_encoder.cpp']
+       'nageru/theme.cpp', 'nageru/scene.cpp', 'nageru/image_input.cpp', 'nageru/alsa_output.cpp',
+       'nageru/timecode_renderer.cpp', 'nageru/tweaked_inputs.cpp', 'nageru/mjpeg_encoder.cpp', 'nageru/srt_metrics.cpp']
 
 # Streaming and encoding objects (largely the set that is shared between Nageru and Kaeru).
-stream_srcs = ['nageru/quicksync_encoder.cpp', 'nageru/x264_encoder.cpp', 'nageru/x264_dynamic.cpp', 'nageru/x264_speed_control.cpp', 'nageru/video_encoder.cpp',
+stream_srcs = ['nageru/quicksync_encoder.cpp', 'nageru/video_encoder.cpp',
+       'nageru/x264_encoder.cpp', 'nageru/x264_dynamic.cpp', 'nageru/x264_speed_control.cpp',
        'nageru/audio_encoder.cpp', 'nageru/ffmpeg_util.cpp', 'nageru/ffmpeg_capture.cpp',
-       'nageru/print_latency.cpp', 'nageru/basic_stats.cpp', 'nageru/ref_counted_frame.cpp']
+       'nageru/print_latency.cpp', 'nageru/basic_stats.cpp', 'nageru/ref_counted_frame.cpp',
+       'nageru/v4l_output.cpp']
+if svtav1dep.found()
+       stream_srcs += 'nageru/av1_encoder.cpp'
+endif
 stream = static_library('stream', stream_srcs, dependencies: nageru_deps, include_directories: nageru_include_dirs)
 nageru_link_with += stream
 
 # DeckLink.
-nageru_srcs += ['nageru/decklink_capture.cpp', 'nageru/decklink_util.cpp', 'nageru/decklink_output.cpp',
-       'nageru/decklink/DeckLinkAPIDispatch.cpp']
-decklink_dir = include_directories('nageru/decklink')
+decklink_dir = include_directories('nageru/decklink', is_system: true)
+decklink_lib = static_library('decklink', 'nageru/decklink/DeckLinkAPIDispatch.cpp', include_directories: decklink_dir, cpp_args: '-w')
+nageru_link_with += decklink_lib
+
+nageru_srcs += ['nageru/decklink_capture.cpp', 'nageru/decklink_util.cpp', 'nageru/decklink_output.cpp']
 nageru_include_dirs += decklink_dir
 
 # CEF input.
@@ -233,7 +244,7 @@ nageru_srcs += proto_generated
 # Shaders needed at runtime.
 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']
 foreach shader : shaders
-       run_command('ln', '-s', join_paths(meson.current_source_dir(), shader), meson.current_build_dir())
+       run_command('ln', '-sf', join_paths(meson.current_source_dir(), shader), meson.current_build_dir(), check: true)
 endforeach
 
 nageru_shader_srcs = bin2h_gen.process(shaders)
@@ -269,10 +280,10 @@ executable('kaeru', 'nageru/kaeru.cpp',
 executable('benchmark_audio_mixer', 'nageru/benchmark_audio_mixer.cpp', dependencies: nageru_deps, include_directories: nageru_include_dirs, link_with: [audio, aux])
 
 # These are needed for a default run.
-data_files = ['nageru/theme.lua', 'nageru/simple.lua', 'nageru/bg.jpeg', 'nageru/akai_midimix.midimapping']
+data_files = ['nageru/theme.lua', 'nageru/simple.lua', 'nageru/bg.jpeg', 'nageru/akai_midimix.midimapping', 'futatabi/behringer_cmd_pl1.midimapping']
 install_data(data_files, install_dir: join_paths(get_option('prefix'), 'share/nageru'))
 foreach file : data_files
-       run_command('ln', '-s', join_paths(meson.current_source_dir(), file), meson.current_build_dir())
+       run_command('ln', '-sf', join_paths(meson.current_source_dir(), file), meson.current_build_dir(), check: true)
 endforeach
 
 # Futatabi. (Not a subdir() because we don't want the output in nageru/nageru.)
@@ -280,13 +291,14 @@ endforeach
 # Protobuf compilation.
 gen = generator(protoc, \
        output    : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
-       arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/futatabi', '--cpp_out=@BUILD_DIR@', '@INPUT@'])
-proto_generated = gen.process('futatabi/state.proto', 'futatabi/frame.proto')
+       arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/futatabi', '--cpp_out=@BUILD_DIR@', '-I@CURRENT_SOURCE_DIR@/shared', '@INPUT@'])
+proto_generated = gen.process('futatabi/state.proto', 'futatabi/frame.proto', 'futatabi/futatabi_midi_mapping.proto')
 
 # Preprocess Qt as needed.
 moc_files = qt5.preprocess(
-       moc_headers: ['futatabi/mainwindow.h', 'futatabi/jpeg_frame_view.h', 'futatabi/clip_list.h'],
-       ui_files: ['futatabi/mainwindow.ui'],
+       moc_headers: ['futatabi/mainwindow.h', 'futatabi/jpeg_frame_view.h', 'futatabi/clip_list.h', 'futatabi/midi_mapping_dialog.h'],
+       ui_files: ['futatabi/mainwindow.ui', 'futatabi/midi_mapping.ui'],
+       qresources: ['futatabi/mainwindow.qrc'],
        dependencies: qt5deps)
 
 # Flow objects.
@@ -296,7 +308,8 @@ futatabi_srcs = ['futatabi/flow.cpp', 'futatabi/gpu_timers.cpp']
 futatabi_srcs += ['futatabi/main.cpp', 'futatabi/player.cpp', 'futatabi/video_stream.cpp', 'futatabi/chroma_subsampler.cpp']
 futatabi_srcs += ['futatabi/vaapi_jpeg_decoder.cpp', 'futatabi/db.cpp', 'futatabi/ycbcr_converter.cpp', 'futatabi/flags.cpp']
 futatabi_srcs += ['futatabi/mainwindow.cpp', 'futatabi/jpeg_frame_view.cpp', 'futatabi/clip_list.cpp', 'futatabi/frame_on_disk.cpp']
-futatabi_srcs += ['futatabi/export.cpp']
+futatabi_srcs += ['futatabi/export.cpp', 'futatabi/midi_mapper.cpp', 'futatabi/midi_mapping_dialog.cpp']
+futatabi_srcs += ['futatabi/exif_parser.cpp', 'futatabi/pbo_pool.cpp']
 futatabi_srcs += moc_files
 futatabi_srcs += proto_generated
 
@@ -307,19 +320,21 @@ shaders += ['futatabi/add_base_flow.frag', 'futatabi/blend.frag', 'futatabi/chro
        'futatabi/sobel.frag', 'futatabi/sor.frag', 'futatabi/splat.frag']
 
 foreach shader : shaders
-       run_command('ln', '-s', join_paths(meson.current_source_dir(), shader), meson.current_build_dir())
+       run_command('ln', '-sf', join_paths(meson.current_source_dir(), shader), meson.current_build_dir(), check: true)
 endforeach
 
 futatabi_shader_srcs = bin2h_gen.process(shaders)
 futatabi_srcs += futatabi_shader_srcs
 
 executable('futatabi', futatabi_srcs,
-       dependencies: [shareddep, qt5deps, libjpegdep, movitdep, libmicrohttpddep, protobufdep, sqlite3dep, vax11dep, vadrmdep, x11dep, libavformatdep, libavcodecdep, libavutildep, libswscaledep],
+       dependencies: [shareddep, qt5deps, libjpegdep, movitdep, libmicrohttpddep, protobufdep, sqlite3dep, vax11dep, vadrmdep, x11dep, threaddep, libavformatdep, libavcodecdep, libavutildep, libswscaledep, eigendep],
        link_with: shared,
        include_directories: [include_directories('futatabi')],
        install: true)
 
 # Test binaries for the optical flow code.
-executable('flow', 'futatabi/flow_main.cpp', 'futatabi/flow.cpp', 'futatabi/gpu_timers.cpp', futatabi_shader_srcs, dependencies: [shareddep, epoxydep, sdl2dep, sdl2_imagedep])
+if sdl2dep.found() and sdl2_imagedep.found()
+       executable('flow', 'futatabi/flow_main.cpp', 'futatabi/flow.cpp', 'futatabi/gpu_timers.cpp', futatabi_shader_srcs, dependencies: [shareddep, epoxydep, sdl2dep, sdl2_imagedep])
+endif
 executable('eval', 'futatabi/eval.cpp', 'futatabi/util.cpp')
 executable('vis', 'futatabi/vis.cpp', 'futatabi/util.cpp')