[Mesa-dev] [PATCH mesa v2 7/7] meson: remove "empty array"/"array of an empty string" confusion

Eric Engestrom eric.engestrom at intel.com
Tue May 15 16:20:04 UTC 2018


Setting `-D arrayoption=` is not the same as setting `-D arrayoption=[]`;
the latter clears the array, while the former fills it with an empty
string option.

This makes the code handling array options a bit more complicated, and
a lot more error-prone, so let's get rid of the confusion by removing
the empty-string option.

Cc: Dylan Baker <dylan at pnwbakers.com>
Cc: Eric Anholt <eric at anholt.net>
Cc: Matt Turner <mattst88 at gmail.com>
Cc: Daniel Stone <daniel at fooishbar.org>
Cc: Jason Ekstrand <jason.ekstrand at gmail.com>
Cc: Kenneth Graunke <kenneth at whitecape.org>
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
---
The rest of the series can land independently of this patch

v2: drop unnecessary code at the same time as we remove the empty string
option
---
 meson.build       | 14 ++++++--------
 meson_options.txt |  8 ++++----
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/meson.build b/meson.build
index a8fd0980010babae8c9f..db9237fa0746f6beeacb 100644
--- a/meson.build
+++ b/meson.build
@@ -119,7 +119,7 @@ with_dri_r200 = _drivers.contains('r200')
 with_dri_nouveau = _drivers.contains('nouveau')
 with_dri_swrast = _drivers.contains('swrast')
 
-with_dri = _drivers.length() != 0 and _drivers != ['']
+with_dri = _drivers.length() != 0
 
 _drivers = get_option('gallium-drivers')
 if _drivers.contains('auto')
@@ -161,7 +161,7 @@ with_gallium_svga = _drivers.contains('svga')
 with_gallium_virgl = _drivers.contains('virgl')
 with_gallium_swr = _drivers.contains('swr')
 
-with_gallium = _drivers.length() != 0 and _drivers != ['']
+with_gallium = _drivers.length() != 0
 
 if with_gallium and system_has_kms_drm
   _glx = get_option('glx')
@@ -189,7 +189,7 @@ endif
 
 with_intel_vk = _vulkan_drivers.contains('intel')
 with_amd_vk = _vulkan_drivers.contains('amd')
-with_any_vk = _vulkan_drivers.length() != 0 and _vulkan_drivers != ['']
+with_any_vk = _vulkan_drivers.length() != 0
 
 if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr)
   error('Only one swrast provider can be built')
@@ -242,9 +242,7 @@ with_platform_drm = _platforms.contains('drm')
 with_platform_haiku = _platforms.contains('haiku')
 with_platform_surfaceless = _platforms.contains('surfaceless')
 
-with_platforms = false
-if _platforms.length() != 0 and _platforms != ['']
-  with_platforms = true
+if _platforms.length() != 0
   egl_native_platform = _platforms[0]
 endif
 
@@ -287,13 +285,13 @@ endif
 
 _egl = get_option('egl')
 if _egl == 'auto'
-  with_egl = with_dri and with_shared_glapi and with_platforms
+  with_egl = with_dri and with_shared_glapi and _platforms.length() != 0
 elif _egl == 'true'
   if not with_dri
     error('EGL requires dri')
   elif not with_shared_glapi
     error('EGL requires shared-glapi')
-  elif with_platforms
+  elif _platforms.length() != 0
     error('No platforms specified, consider -Dplatforms=drm,x11 at least')
   elif not ['disabled', 'dri'].contains(with_glx)
     error('EGL requires dri, but a GLX is being built without dri')
diff --git a/meson_options.txt b/meson_options.txt
index ce7d87f1ebd74a4ecc2c..b851f086a2b756142d8d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -23,7 +23,7 @@ option(
   type : 'array',
   value : ['auto'],
   choices : [
-    '', 'auto', 'x11', 'wayland', 'drm', 'surfaceless', 'haiku', 'android',
+    'auto', 'x11', 'wayland', 'drm', 'surfaceless', 'haiku', 'android',
   ],
   description : 'comma separated list of window systems to support. If this is set to auto all platforms applicable to the OS will be enabled.'
 )
@@ -38,7 +38,7 @@ option(
   'dri-drivers',
   type : 'array',
   value : ['auto'],
-  choices : ['', 'auto', 'i915', 'i965', 'r100', 'r200', 'nouveau', 'swrast'],
+  choices : ['auto', 'i915', 'i965', 'r100', 'r200', 'nouveau', 'swrast'],
   description : 'List of dri drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
 )
 option(
@@ -58,7 +58,7 @@ option(
   type : 'array',
   value : ['auto'],
   choices : [
-    '', 'auto', 'pl111', 'radeonsi', 'r300', 'r600', 'nouveau', 'freedreno',
+    'auto', 'pl111', 'radeonsi', 'r300', 'r600', 'nouveau', 'freedreno',
     'swrast', 'vc4', 'vc5', 'etnaviv', 'imx', 'tegra', 'i915', 'svga', 'virgl',
     'swr',
   ],
@@ -152,7 +152,7 @@ option(
   'vulkan-drivers',
   type : 'array',
   value : ['auto'],
-  choices : ['', 'auto', 'amd', 'intel'],
+  choices : ['auto', 'amd', 'intel'],
   description : 'List of vulkan drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
 )
 option(
-- 
Cheers,
  Eric



More information about the mesa-dev mailing list