vaapi: Use meson's features for option selection.
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 9 Feb 2022 05:01:34 +0000 (06:01 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 14 Feb 2022 09:46:01 +0000 (09:46 +0000)
Modernize option selection, so if a required dependency is missing,
produce a meaningful error message.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1676>

subprojects/gstreamer-vaapi/meson.build
subprojects/gstreamer-vaapi/meson_options.txt

index d34040f..d400415 100644 (file)
@@ -79,32 +79,42 @@ else
   message('GStreamer debug system is enabled')
 endif
 
-# Other deps
-gmodule_dep = dependency('gmodule-2.0', required: false)
 libva_dep = dependency('libva', version: libva_req,
   fallback : ['libva', 'libva_dep'])
-
 libva_drm_dep = dependency('libva-drm', version: libva_req,
-  fallback : ['libva', 'libva_drm_dep'], required: false)
+  required: get_option('drm'), fallback : ['libva', 'libva_drm_dep'])
 libva_wayland_dep = dependency('libva-wayland', version: libva_req,
-  fallback : ['libva', 'libva_wayland_dep'], required: false)
+  required: get_option('wayland'), fallback : ['libva', 'libva_wayland_dep'])
 libva_x11_dep = dependency('libva-x11', version: libva_req,
-  fallback : ['libva', 'libva_x11_dep'], required: false)
-libdrm_dep = dependency('libdrm', version: libdrm_req, required: false,
-  fallback: ['libdrm', 'ext_libdrm'])
-libudev_dep = dependency('libudev', required: false)
-egl_dep = dependency('egl', required: false)
-gl_dep = dependency('gl', required: false)
+  required: get_option('x11'), fallback : ['libva', 'libva_x11_dep'])
+
+libdrm_dep = dependency('libdrm', version: libdrm_req,
+  required: get_option('drm'), fallback: ['libdrm', 'ext_libdrm'])
+libudev_dep = dependency('libudev', required: get_option('drm'))
+
+x11_dep = dependency('x11', required: get_option('x11'))
+xrandr_dep = dependency('xrandr', required: get_option('x11'))
+
+gmodule_dep = dependency('gmodule-2.0', required: get_option('egl'))
+egl_dep = dependency('egl', required: get_option('egl'))
 glesv2_dep = dependency('glesv2', required: false)
+
+glx_option = get_option('glx').require(libva_x11_dep.found() and x11_dep.found(),
+    error_message: 'glx requires libva-x11 and x11 dependency')
+gl_dep = dependency('gl', required: glx_option)
+libdl_dep = cc.find_library('dl', required: glx_option)
+
+wayland_option = get_option('wayland').require(libdrm_dep.found(),
+    error_message: 'wayland requires libdrm dependency')
+wayland_client_dep = dependency('wayland-client', version: libwayland_req,
+  required: wayland_option)
+wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15',
+  required: wayland_option)
+wayland_scanner_bin = find_program('wayland-scanner', required: wayland_option)
+
 gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
   required : get_option('tests'),
   fallback : ['gstreamer', 'gst_check_dep'])
-libdl_dep = cc.find_library('dl', required: false)
-wayland_client_dep = dependency('wayland-client', version: libwayland_req, required: false)
-wayland_protocols_dep = dependency('wayland-protocols', version: '>= 1.15', required: false)
-wayland_scanner_bin = find_program('wayland-scanner', required: false)
-x11_dep = dependency('x11', required: false)
-xrandr_dep = dependency('xrandr', required: false)
 
 # some of the examples can use GTK+-3
 gtk_dep = dependency('gtk+-3.0', version : '>= 3.10', required : get_option('examples'))
@@ -122,19 +132,23 @@ if glesv2_dep.found()
   endif
 endif
 
-USE_ENCODERS = get_option('with_encoders') != 'no'
+USE_ENCODERS = get_option('encoders').allowed()
 USE_VP9_ENCODER = USE_ENCODERS and libva_dep.version().version_compare('>= 0.40.0')
 USE_AV1_DECODER = libva_dep.version().version_compare('>= 1.10')
 
-USE_DRM = libva_drm_dep.found() and libdrm_dep.found() and libudev_dep.found() and get_option('with_drm') != 'no'
-USE_EGL = gmodule_dep.found() and egl_dep.found() and GLES_VERSION_MASK != 0 and get_option('with_egl') != 'no'
-USE_WAYLAND = libva_wayland_dep.found() and wayland_client_dep.found() and wayland_protocols_dep.found() and wayland_scanner_bin.found() and get_option('with_wayland') != 'no' and USE_DRM
-USE_X11 = libva_x11_dep.found() and x11_dep.found() and get_option('with_x11') != 'no'
-USE_GLX = gl_dep.found() and libdl_dep.found() and get_option('with_glx') != 'no' and USE_X11
-
-if get_option('with_wayland') == 'yes' and not USE_DRM
-   error('DRM support is required to enable Wayland support')
-endif
+USE_DRM = (libva_drm_dep.found()
+    and libdrm_dep.found()
+    and libudev_dep.found())
+USE_EGL = (gmodule_dep.found()
+    and egl_dep.found()
+    and GLES_VERSION_MASK != 0)
+USE_WAYLAND = (libva_wayland_dep.found()
+    and wayland_client_dep.found()
+    and wayland_protocols_dep.found()
+    and wayland_scanner_bin.found()
+    and libdrm_dep.found())
+USE_X11 = (libva_x11_dep.found() and x11_dep.found())
+USE_GLX = (USE_X11 and gl_dep.found() and libdl_dep.found())
 
 if not (USE_DRM or USE_X11 or USE_WAYLAND)
   error('No renderer API found (it is requried either DRM, X11 and/or WAYLAND)')
index 9c2b5e1..8db598b 100644 (file)
@@ -1,9 +1,9 @@
-option('with_encoders', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
-option('with_drm', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
-option('with_x11', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
-option('with_glx', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
-option('with_wayland', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
-option('with_egl', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
+option('encoders', type : 'feature', value : 'auto')
+option('drm', type : 'feature', value : 'auto')
+option('x11', type : 'feature', value : 'auto')
+option('glx', type : 'feature', value : 'auto')
+option('wayland', type : 'feature', value : 'auto')
+option('egl', type : 'feature', value : 'auto')
 
 # Common feature options
 option('examples', type : 'feature', value : 'auto', yield : true)