From eac76e433d7a75125afa16bce5adf3fcf7163839 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 20 Dec 2022 14:59:48 -0800 Subject: [PATCH] meson: use a feature option for gallium-vdpau Which we can use with the require method, and use the feature itself as the require argument to dependency call. All of this results in less code Reviewed-by: Jesse Natalie Acked-by: Alyssa Rosenzweig Part-of: --- meson.build | 62 ++++++++++++++--------------------------------- meson_options.txt | 4 +-- 2 files changed, 19 insertions(+), 47 deletions(-) diff --git a/meson.build b/meson.build index 19a95d37b0096..7f5709d2284d4 100644 --- a/meson.build +++ b/meson.build @@ -640,53 +640,27 @@ if with_gallium_d3d12 and not _with_gallium_d3d12_video.disabled() pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO' endif -_vdpau = get_option('gallium-vdpau') -if _vdpau == 'true' - _vdpau = 'enabled' - warning('gallium-vdpau option "true" deprecated, please use "enabled" instead.') -elif _vdpau == 'false' - _vdpau = 'disabled' - warning('gallium-vdpau option "false" deprecated, please use "disabled" instead.') -endif -if not system_has_kms_drm - if _vdpau == 'enabled' - error('VDPAU state tracker can only be build on unix-like OSes.') - else - _vdpau = 'disabled' - endif -elif not with_platform_x11 - if _vdpau == 'enabled' - error('VDPAU state tracker requires X11 support.') - else - _vdpau = 'disabled' - endif -elif not [ - with_gallium_d3d12_video, - with_gallium_nouveau, - with_gallium_r300, - with_gallium_r600, - with_gallium_radeonsi, - with_gallium_virgl, - ].contains(true) - if _vdpau == 'enabled' - error('VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).') - else - _vdpau = 'disabled' - endif -endif -dep_vdpau = null_dep -with_gallium_vdpau = false -if _vdpau != 'disabled' - dep_vdpau = dependency('vdpau', version : '>= 1.1', required : _vdpau == 'enabled') - if dep_vdpau.found() - dep_vdpau = dep_vdpau.partial_dependency(compile_args : true) - with_gallium_vdpau = true - endif -endif +_vdpau_drivers = [ + with_gallium_d3d12_video, + with_gallium_nouveau, + with_gallium_r300, + with_gallium_r600, + with_gallium_radeonsi, + with_gallium_virgl, +] -if with_gallium_vdpau +vdpau = get_option('gallium-vdpau') \ + .require(system_has_kms_drm, error_message : 'VDPAU state tracker can only be build on unix-like OSes.') \ + .require(with_platform_x11, error_message : 'VDPAU state tracker requires X11 support.') \ + .require(_vdpau_drivers.contains(true), error_message : 'VDPAU state tracker requires at least one of the following gallium drivers: r300, r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).') + +dep_vdpau = dependency('vdpau', version : '>= 1.1', required : vdpau) +if dep_vdpau.found() + dep_vdpau = dep_vdpau.partial_dependency(compile_args : true) pre_args += '-DHAVE_ST_VDPAU' endif +with_gallium_vdpau = dep_vdpau.found() + vdpau_drivers_path = get_option('vdpau-libs-path') if vdpau_drivers_path == '' vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau') diff --git a/meson_options.txt b/meson_options.txt index a40bebe879936..76bdcd454f23d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -85,9 +85,7 @@ option( ) option( 'gallium-vdpau', - type : 'combo', - value : 'auto', - choices : ['auto', 'true', 'false', 'enabled', 'disabled'], + type : 'feature', description : 'enable gallium vdpau frontend.', ) option(