meson: reduce dictionary usage

The build was a bit overzealous with using dictionaries. These are fine
for when the feature checking is more complicated, but there's no point
in having them for the simplier things. This also eliminates the usage
of the 'name' key completely.
This commit is contained in:
Dudemanguy 2022-08-12 13:02:41 -05:00
parent 484f1d7adc
commit 686027f9b2
1 changed files with 61 additions and 98 deletions

View File

@ -15,17 +15,13 @@ build_root = meson.project_build_root()
source_root = meson.project_source_root() source_root = meson.project_source_root()
python = find_program('python3') python = find_program('python3')
avutil = dependency('libavutil', version: '>= 56.12.100') # ffmpeg
libavcodec = dependency('libavcodec', version: '>= 58.12.100')
ffmpeg = { libavfilter = dependency('libavfilter', version: '>= 7.14.100')
'name': 'ffmpeg', libavformat = dependency('libavformat', version: '>= 58.9.100')
'deps': [avutil, libavutil = dependency('libavutil', version: '>= 56.12.100')
dependency('libavcodec', version: '>= 58.12.100'), libswresample = dependency('libswresample', version: '>= 3.0.100')
dependency('libavformat', version: '>= 58.9.100'), libswscale = dependency('libswscale', version: '>= 5.0.101')
dependency('libswscale', version: '>= 5.0.101'),
dependency('libavfilter', version: '>= 7.14.100'),
dependency('libswresample', version: '>= 3.0.100')],
}
libass = dependency('libass', version: '>= 0.12.2') libass = dependency('libass', version: '>= 0.12.2')
pthreads = dependency('threads') pthreads = dependency('threads')
@ -33,10 +29,15 @@ pthreads = dependency('threads')
# the dependency order of libass -> ffmpeg is necessary due to # the dependency order of libass -> ffmpeg is necessary due to
# static linking symbol resolution between fontconfig and MinGW # static linking symbol resolution between fontconfig and MinGW
dependencies = [libass, dependencies = [libass,
ffmpeg['deps'], libavcodec,
libavfilter,
libavformat,
libavutil,
libswresample,
libswscale,
pthreads] pthreads]
features = [ffmpeg['name'], libass.name(), pthreads.name()] features = ['ffmpeg', libass.name(), pthreads.name()]
# Builtin options we'd like to add to features. # Builtin options we'd like to add to features.
if get_option('optimization') != '0' if get_option('optimization') != '0'
@ -604,7 +605,7 @@ endif
# misc dependencies # misc dependencies
av_ch_layout_available = avutil.version().version_compare('>= 57.24.100') av_ch_layout_available = libavutil.version().version_compare('>= 57.24.100')
if av_ch_layout_available if av_ch_layout_available
features += 'av-channel-layout' features += 'av-channel-layout'
sources += files('audio/chmap_avchannel.c') sources += files('audio/chmap_avchannel.c')
@ -697,10 +698,7 @@ if librt.found()
features += 'librt' features += 'librt'
endif endif
lua = { lua = dependency('', required: false)
'name': 'lua',
'use': false,
}
lua_opt = get_option('lua') lua_opt = get_option('lua')
if lua_opt != 'disabled' if lua_opt != 'disabled'
lua_version = [['lua', ['>=5.1.0', '<5.3.0']], # generic lua.pc lua_version = [['lua', ['>=5.1.0', '<5.3.0']], # generic lua.pc
@ -713,28 +711,26 @@ if lua_opt != 'disabled'
['lua-5.1', '>= 5.1.0']] ['lua-5.1', '>= 5.1.0']]
foreach version : lua_version foreach version : lua_version
if lua_opt == 'auto' or lua_opt == 'enabled' if lua_opt == 'auto' or lua_opt == 'enabled'
lua += {'deps': dependency(version[0], version: version[1], required: false)} lua = dependency(version[0], version: version[1], required: false)
if lua['deps'].found() if lua.found()
lua += {'use': true}
break break
endif endif
elif lua_opt == version[0] elif lua_opt == version[0]
lua += {'deps': dependency(version[0], version: version[1])} lua = dependency(version[0], version: version[1])
if lua['deps'].found() if lua.found()
lua += {'use': true}
break break
endif endif
endif endif
endforeach endforeach
endif endif
if lua['use'] if lua.found()
dependencies += lua['deps'] dependencies += lua
features += lua['deps'].name() features += lua.name()
sources += files('player/lua.c') sources += files('player/lua.c')
subdir(join_paths('generated', 'player', 'lua')) subdir(join_paths('generated', 'player', 'lua'))
endif endif
if not lua['use'] and lua_opt == 'enabled' if not lua.found() and lua_opt == 'enabled'
error('lua enabled but no suitable lua version could be found!') error('lua enabled but no suitable lua version could be found!')
endif endif
@ -813,7 +809,6 @@ if alsa.found()
endif endif
audiounit = { audiounit = {
'name': 'audiounit',
'deps': dependency('appleframeworks', modules: ['Foundation', 'AudioToolbox'], 'deps': dependency('appleframeworks', modules: ['Foundation', 'AudioToolbox'],
required: get_option('audiounit')), required: get_option('audiounit')),
'symbol': cc.has_header_symbol('AudioToolbox/AudioToolbox.h', 'kAudioUnitSubType_RemoteIO', 'symbol': cc.has_header_symbol('AudioToolbox/AudioToolbox.h', 'kAudioUnitSubType_RemoteIO',
@ -940,14 +935,13 @@ if direct3d
endif endif
drm = { drm = {
'name': 'drm',
'deps': dependency('libdrm', version: '>= 2.4.75', required: get_option('drm')), 'deps': dependency('libdrm', version: '>= 2.4.75', required: get_option('drm')),
'header': vt_h or consio_h, 'header': vt_h or consio_h,
} }
drm += {'use': drm['deps'].found() and drm['header']} drm += {'use': drm['deps'].found() and drm['header']}
if drm['use'] if drm['use']
dependencies += drm['deps'] dependencies += drm['deps']
features += drm['name'] features += 'drm'
sources += files('video/drmprime.c', sources += files('video/drmprime.c',
'video/out/drm_atomic.c', 'video/out/drm_atomic.c',
'video/out/drm_common.c', 'video/out/drm_common.c',
@ -958,12 +952,9 @@ if drm['use']
endif endif
# This can be removed roughly when Debian 12 is released. # This can be removed roughly when Debian 12 is released.
drm_is_kms = { drm_is_kms = drm['use'] and drm['deps'].version().version_compare('>= 2.4.105')
'name': 'drm-is-kms', if drm_is_kms
'use': drm['use'] and drm['deps'].version().version_compare('>= 2.4.105') features += 'drm_is_kms'
}
if drm_is_kms['use']
features += drm_is_kms['name']
endif endif
gbm = dependency('gbm', version: '>=17.1.0', required: get_option('gbm')) gbm = dependency('gbm', version: '>=17.1.0', required: get_option('gbm'))
@ -1037,7 +1028,6 @@ if d3d11.allowed()
endif endif
wayland = { wayland = {
'name': 'wayland',
'deps': [dependency('wayland-client', version: '>= 1.15.0', required: get_option('wayland')), 'deps': [dependency('wayland-client', version: '>= 1.15.0', required: get_option('wayland')),
dependency('wayland-cursor', version: '>= 1.15.0', required: get_option('wayland')), dependency('wayland-cursor', version: '>= 1.15.0', required: get_option('wayland')),
dependency('wayland-protocols', version: '>= 1.15', required: get_option('wayland')), dependency('wayland-protocols', version: '>= 1.15', required: get_option('wayland')),
@ -1058,7 +1048,7 @@ if not wayland['header'] or not wayland['scanner'].found()
endif endif
if wayland['use'] if wayland['use']
features += wayland['name'] features += 'wayland'
subdir(join_paths('generated', 'wayland')) subdir(join_paths('generated', 'wayland'))
endif endif
@ -1077,7 +1067,6 @@ x11_opt = get_option('x11').require(
error_message: 'the build is not GPL!', error_message: 'the build is not GPL!',
) )
x11 = { x11 = {
'name': 'x11',
'deps': [dependency('x11', version: '>= 1.0.0', required: x11_opt), 'deps': [dependency('x11', version: '>= 1.0.0', required: x11_opt),
dependency('xscrnsaver', version: '>= 1.0.0', required: x11_opt), dependency('xscrnsaver', version: '>= 1.0.0', required: x11_opt),
dependency('xext', version: '>= 1.0.0', required: x11_opt), dependency('xext', version: '>= 1.0.0', required: x11_opt),
@ -1095,7 +1084,7 @@ endforeach
if x11['use'] if x11['use']
dependencies += x11['deps'] dependencies += x11['deps']
features += x11['name'] features += 'x11'
sources += files('video/out/vo_x11.c', sources += files('video/out/vo_x11.c',
'video/out/x11_common.c') 'video/out/x11_common.c')
endif endif
@ -1118,7 +1107,6 @@ endif
# OpenGL feature checking # OpenGL feature checking
gl = { gl = {
'name': 'gl',
'opt': get_option('gl').allowed(), 'opt': get_option('gl').allowed(),
'use': false, 'use': false,
} }
@ -1212,14 +1200,13 @@ if d3d11.allowed() or egl_angle_win32.allowed()
endif endif
egl = { egl = {
'name': 'egl',
'deps': dependency('egl', version: '> 1.4.0', required: get_option('egl')), 'deps': dependency('egl', version: '> 1.4.0', required: get_option('egl')),
'use': false, 'use': false,
} }
egl += {'use': egl['deps'].found() and gl['opt']} egl += {'use': egl['deps'].found() and gl['opt']}
if egl['use'] if egl['use']
dependencies += egl['deps'] dependencies += egl['deps']
features += egl['name'] features += 'egl'
endif endif
egl_android_opt = get_option('egl-android').require( egl_android_opt = get_option('egl-android').require(
@ -1245,14 +1232,13 @@ if egl_drm.allowed()
endif endif
egl_wayland = { egl_wayland = {
'name': 'egl-wayland',
'deps': dependency('wayland-egl', version: '>= 9.0.0', required: get_option('egl-wayland')), 'deps': dependency('wayland-egl', version: '>= 9.0.0', required: get_option('egl-wayland')),
'use': false, 'use': false,
} }
egl_wayland += {'use': egl['use'] and egl_wayland['deps'].found() and gl['opt'] and wayland['use']} egl_wayland += {'use': egl['use'] and egl_wayland['deps'].found() and gl['opt'] and wayland['use']}
if egl_wayland['use'] if egl_wayland['use']
dependencies += egl_wayland['deps'] dependencies += egl_wayland['deps']
features += egl_wayland['name'] features += 'gl-wayland'
gl += {'use': true} gl += {'use': true}
sources += files('video/out/opengl/context_wayland.c') sources += files('video/out/opengl/context_wayland.c')
endif endif
@ -1277,14 +1263,13 @@ if plain_gl.allowed()
endif endif
rpi = { rpi = {
'name': 'rpi',
'deps': dependency('/opt/vc/lib/pkgconfig/brcmegl.pc', 'brcmegl', required: get_option('rpi')), 'deps': dependency('/opt/vc/lib/pkgconfig/brcmegl.pc', 'brcmegl', required: get_option('rpi')),
'use': false, 'use': false,
} }
rpi += {'use': gl['opt'] and rpi['deps'].found()} rpi += {'use': gl['opt'] and rpi['deps'].found()}
if rpi['use'] if rpi['use']
dependencies += rpi['deps'] dependencies += rpi['deps']
features += rpi['name'] features += 'rpi'
gl += {'use': true} gl += {'use': true}
sources += files('video/out/opengl/context_rpi.c') sources += files('video/out/opengl/context_rpi.c')
endif endif
@ -1428,35 +1413,31 @@ if rpi_mmal.found()
endif endif
vaapi = { vaapi = {
'name': 'vaapi',
'deps': dependency('libva', version: '>= 1.1.0', required: get_option('vaapi')), 'deps': dependency('libva', version: '>= 1.1.0', required: get_option('vaapi')),
} }
vaapi += {'use': vaapi['deps'].found() and libdl and vaapi += {'use': vaapi['deps'].found() and libdl and
(x11['use'] or wayland['use'] or egl_drm.allowed())} (x11['use'] or wayland['use'] or egl_drm.allowed())}
if vaapi['use'] if vaapi['use']
dependencies += vaapi['deps'] dependencies += vaapi['deps']
features += vaapi['name'] features += 'vaapi'
sources += files('video/filter/vf_vavpp.c', sources += files('video/filter/vf_vavpp.c',
'video/vaapi.c') 'video/vaapi.c')
endif endif
vaapi_drm = { vaapi_drm = {
'name': 'vaapi-drm',
'deps': dependency('libva-drm', version: '>= 1.1.0', required: get_option('vaapi-drm')), 'deps': dependency('libva-drm', version: '>= 1.1.0', required: get_option('vaapi-drm')),
} }
vaapi_drm += {'use': vaapi['use'] and egl_drm.allowed() and vaapi_drm['deps'].found()} vaapi_drm += {'use': vaapi['use'] and egl_drm.allowed() and vaapi_drm['deps'].found()}
if vaapi_drm['use'] if vaapi_drm['use']
features += vaapi_drm['name'] features += 'vaapi-drm'
endif endif
vaapi_wayland = { vaapi_wayland = {
'name': 'vaapi-wayland',
'deps': dependency('libva-wayland', version: '>= 1.1.0', required: get_option('vaapi-wayland')), 'deps': dependency('libva-wayland', version: '>= 1.1.0', required: get_option('vaapi-wayland')),
} }
vaapi_wayland += {'use': vaapi['use'] and egl_wayland['use'] and vaapi_wayland['deps'].found()} vaapi_wayland += {'use': vaapi['use'] and egl_wayland['use'] and vaapi_wayland['deps'].found()}
if vaapi_wayland['use'] if vaapi_wayland['use']
features += vaapi_wayland['name'] features += 'vaapi-wayland'
endif endif
if vaapi_wayland['use'] and memfd_create if vaapi_wayland['use'] and memfd_create
@ -1465,62 +1446,44 @@ if vaapi_wayland['use'] and memfd_create
endif endif
vaapi_x11 = { vaapi_x11 = {
'name': 'vaapi-x11',
'deps': dependency('libva-x11', version: '>= 1.1.0', required: get_option('vaapi-x11')), 'deps': dependency('libva-x11', version: '>= 1.1.0', required: get_option('vaapi-x11')),
} }
vaapi_x11 += {'use': vaapi['use'] and x11['use'] and vaapi_x11['deps'].found()} vaapi_x11 += {'use': vaapi['use'] and x11['use'] and vaapi_x11['deps'].found()}
if vaapi_x11['use'] if vaapi_x11['use']
dependencies += vaapi_x11['deps'] dependencies += vaapi_x11['deps']
features += vaapi_x11['name'] features += 'vaapi-x11'
sources += files('video/out/vo_vaapi.c') sources += files('video/out/vo_vaapi.c')
endif endif
vaapi_x_egl = { vaapi_x_egl = vaapi_x11['use'] and egl_x11.allowed()
'name': 'vaapi-x-egl', if vaapi_x_egl
'use': vaapi_x11['use'] and egl_x11.allowed(), features += 'vaapi-x-egl'
}
if vaapi_x_egl['use']
features += vaapi_x_egl['name']
endif endif
vaapi_egl = { vaapi_egl = vaapi_x_egl or vaapi_wayland['use'] or vaapi_drm['use']
'name': 'vaapi-egl', if vaapi_egl
'use': vaapi_x_egl['use'] or vaapi_wayland['use'] or vaapi_drm['use'],
}
if vaapi_egl['use']
dependencies += [vaapi_wayland['deps'], vaapi_drm['deps']] dependencies += [vaapi_wayland['deps'], vaapi_drm['deps']]
features += vaapi_egl['name'] features += 'vaapi-egl'
endif endif
vaapi_libplacebo = { vaapi_libplacebo = vaapi['use'] and libplacebo.found()
'name': 'vaapi-libplacebo', if vaapi_libplacebo
'use': vaapi['use'] and libplacebo.found(), features += 'vaapi-libplacebo'
}
if vaapi_libplacebo['use']
features += vaapi_libplacebo['name']
endif endif
if vaapi_egl['use'] or vaapi_libplacebo['use'] if vaapi_egl or vaapi_libplacebo
sources += files('video/out/hwdec/hwdec_vaapi.c') sources += files('video/out/hwdec/hwdec_vaapi.c')
endif endif
dmabuf_interop_gl = { dmabuf_interop_gl = egl['use'] and drm['use']
'name': 'dmabuf-interop-gl', if dmabuf_interop_gl
'use': egl['use'] and drm['use'] features += 'dmabuf-interop-gl'
}
if dmabuf_interop_gl['use']
features += dmabuf_interop_gl['name']
sources += files('video/out/hwdec/dmabuf_interop_gl.c') sources += files('video/out/hwdec/dmabuf_interop_gl.c')
endif endif
dmabuf_interop_pl = { dmabuf_interop_pl = vaapi_libplacebo
'name': 'dmabuf-interop-pl', if dmabuf_interop_pl
'use': vaapi_libplacebo['use'] features += 'dmabuf-interop-pl'
}
if dmabuf_interop_pl['use']
features += dmabuf_interop_pl['name']
sources += files('video/out/hwdec/dmabuf_interop_pl.c') sources += files('video/out/hwdec/dmabuf_interop_pl.c')
endif endif
@ -1755,11 +1718,11 @@ conf_data.set10('HAVE_D3D_HWACCEL', d3d_hwaccel.allowed())
conf_data.set10('HAVE_D3D9_HWACCEL', d3d9_hwaccel.allowed()) conf_data.set10('HAVE_D3D9_HWACCEL', d3d9_hwaccel.allowed())
conf_data.set10('HAVE_D3D11', d3d11.allowed()) conf_data.set10('HAVE_D3D11', d3d11.allowed())
conf_data.set10('HAVE_DIRECT3D', direct3d) conf_data.set10('HAVE_DIRECT3D', direct3d)
conf_data.set10('HAVE_DMABUF_INTEROP_GL', dmabuf_interop_gl['use']) conf_data.set10('HAVE_DMABUF_INTEROP_GL', dmabuf_interop_gl)
conf_data.set10('HAVE_DMABUF_INTEROP_PL', dmabuf_interop_pl['use']) conf_data.set10('HAVE_DMABUF_INTEROP_PL', dmabuf_interop_pl)
conf_data.set10('HAVE_DOS_PATHS', win32) conf_data.set10('HAVE_DOS_PATHS', win32)
conf_data.set10('HAVE_DRM', drm['use']) conf_data.set10('HAVE_DRM', drm['use'])
conf_data.set10('HAVE_DRM_IS_KMS', drm_is_kms['use']) conf_data.set10('HAVE_DRM_IS_KMS', drm_is_kms)
conf_data.set10('HAVE_DVBIN', dvbin.allowed()) conf_data.set10('HAVE_DVBIN', dvbin.allowed())
conf_data.set10('HAVE_DVDNAV', dvdnav.found() and dvdread.found()) conf_data.set10('HAVE_DVDNAV', dvdnav.found() and dvdread.found())
conf_data.set10('HAVE_EGL', egl['use']) conf_data.set10('HAVE_EGL', egl['use'])
@ -1786,7 +1749,7 @@ conf_data.set10('HAVE_IOS_GL', ios_gl)
conf_data.set10('HAVE_JACK', jack.found()) conf_data.set10('HAVE_JACK', jack.found())
conf_data.set10('HAVE_JAVASCRIPT', javascript.found()) conf_data.set10('HAVE_JAVASCRIPT', javascript.found())
conf_data.set10('HAVE_JPEG', jpeg.found()) conf_data.set10('HAVE_JPEG', jpeg.found())
conf_data.set10('HAVE_JPEGXL', ffmpeg['deps'][1].version().version_compare('>= 59.27.100')) conf_data.set10('HAVE_JPEGXL', libavformat.version().version_compare('>= 59.27.100'))
conf_data.set10('HAVE_LCMS2', lcms2.found()) conf_data.set10('HAVE_LCMS2', lcms2.found())
conf_data.set10('HAVE_LIBARCHIVE', libarchive.found()) conf_data.set10('HAVE_LIBARCHIVE', libarchive.found())
conf_data.set10('HAVE_LIBAVDEVICE', libavdevice.found()) conf_data.set10('HAVE_LIBAVDEVICE', libavdevice.found())
@ -1794,7 +1757,7 @@ conf_data.set10('HAVE_LIBDL', libdl)
conf_data.set10('HAVE_LIBBLURAY', libbluray.found()) conf_data.set10('HAVE_LIBBLURAY', libbluray.found())
conf_data.set10('HAVE_LIBPLACEBO_NEXT', libplacebo_next) conf_data.set10('HAVE_LIBPLACEBO_NEXT', libplacebo_next)
conf_data.set10('HAVE_LINUX_FSTATFS', linux_fstatfs) conf_data.set10('HAVE_LINUX_FSTATFS', linux_fstatfs)
conf_data.set10('HAVE_LUA', lua['use']) conf_data.set10('HAVE_LUA', lua.found())
conf_data.set10('HAVE_MACOS_10_11_FEATURES', macos_10_11_features.allowed()) conf_data.set10('HAVE_MACOS_10_11_FEATURES', macos_10_11_features.allowed())
conf_data.set10('HAVE_MACOS_10_14_FEATURES', macos_10_14_features.allowed()) conf_data.set10('HAVE_MACOS_10_14_FEATURES', macos_10_14_features.allowed())
conf_data.set10('HAVE_MACOS_COCOA_CB', macos_cocoa_cb.allowed()) conf_data.set10('HAVE_MACOS_COCOA_CB', macos_cocoa_cb.allowed())
@ -1826,8 +1789,8 @@ conf_data.set10('HAVE_UCHARDET', uchardet.found())
conf_data.set10('HAVE_UWP', uwp.found()) conf_data.set10('HAVE_UWP', uwp.found())
conf_data.set10('HAVE_VAAPI', vaapi['use']) conf_data.set10('HAVE_VAAPI', vaapi['use'])
conf_data.set10('HAVE_VAAPI_DRM', vaapi_drm['use']) conf_data.set10('HAVE_VAAPI_DRM', vaapi_drm['use'])
conf_data.set10('HAVE_VAAPI_EGL', vaapi_egl['use']) conf_data.set10('HAVE_VAAPI_EGL', vaapi_egl)
conf_data.set10('HAVE_VAAPI_LIBPLACEBO', vaapi_libplacebo['use']) conf_data.set10('HAVE_VAAPI_LIBPLACEBO', vaapi_libplacebo)
conf_data.set10('HAVE_VAAPI_WAYLAND', vaapi_wayland['use']) conf_data.set10('HAVE_VAAPI_WAYLAND', vaapi_wayland['use'])
conf_data.set10('HAVE_VAAPI_X11', vaapi_x11['use']) conf_data.set10('HAVE_VAAPI_X11', vaapi_x11['use'])
conf_data.set10('HAVE_VAPOURSYNTH', vapoursynth.found() and vapoursynth_script.found()) conf_data.set10('HAVE_VAPOURSYNTH', vapoursynth.found() and vapoursynth_script.found())
@ -1923,7 +1886,7 @@ summary({'d3d11': d3d11.allowed(),
'gpu-next': libplacebo_next, 'gpu-next': libplacebo_next,
'javascript': javascript.found(), 'javascript': javascript.found(),
'libmpv': get_option('libmpv'), 'libmpv': get_option('libmpv'),
'lua': lua['use'], 'lua': lua.found(),
'opengl': GL.found() or egl['use'], 'opengl': GL.found() or egl['use'],
'vulkan': vulkan.found(), 'vulkan': vulkan.found(),
'wayland': wayland['use'], 'wayland': wayland['use'],