meson: use array type options

This option type is nice since it involves less converting strings into
lists, and because it validates the values that are provided.

v2: - Set with_any_vk to true if any vulkan driver is built (Eric)

Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Dylan Baker 2018-04-16 15:18:08 -07:00
parent c5a97d658e
commit 5608d0a2ce
2 changed files with 88 additions and 75 deletions

View File

@ -51,8 +51,8 @@ with_valgrind = get_option('valgrind')
with_libunwind = get_option('libunwind')
with_asm = get_option('asm')
with_osmesa = get_option('osmesa')
with_swr_arches = get_option('swr-arches').split(',')
with_tools = get_option('tools').split(',')
with_swr_arches = get_option('swr-arches')
with_tools = get_option('tools')
if with_tools.contains('all')
with_tools = ['freedreno', 'glsl', 'intel', 'nir', 'nouveau']
endif
@ -101,31 +101,30 @@ with_dri_r200 = false
with_dri_nouveau = false
with_dri_swrast = false
_drivers = get_option('dri-drivers')
if _drivers == 'auto'
if _drivers.contains('auto')
if system_has_kms_drm
# TODO: PPC, Sparc
if ['x86', 'x86_64'].contains(host_machine.cpu_family())
_drivers = 'i915,i965,r100,r200,nouveau'
_drivers = ['i915', 'i965', 'r100', 'r200', 'nouveau']
elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
_drivers = ''
_drivers = ['']
else
error('Unknown architecture. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
endif
elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
# only swrast would make sense here, but gallium swrast is a much better default
_drivers = ''
_drivers = ['']
else
error('Unknown OS. Please pass -Ddri-drivers to set driver options. Patches gladly accepted to fix this.')
endif
endif
if _drivers != ''
_split = _drivers.split(',')
with_dri_i915 = _split.contains('i915')
with_dri_i965 = _split.contains('i965')
with_dri_r100 = _split.contains('r100')
with_dri_r200 = _split.contains('r200')
with_dri_nouveau = _split.contains('nouveau')
with_dri_swrast = _split.contains('swrast')
if _drivers != ['']
with_dri_i915 = _drivers.contains('i915')
with_dri_i965 = _drivers.contains('i965')
with_dri_r100 = _drivers.contains('r100')
with_dri_r200 = _drivers.contains('r200')
with_dri_nouveau = _drivers.contains('nouveau')
with_dri_swrast = _drivers.contains('swrast')
with_dri = true
endif
@ -147,40 +146,44 @@ with_gallium_svga = false
with_gallium_virgl = false
with_gallium_swr = false
_drivers = get_option('gallium-drivers')
if _drivers == 'auto'
if _drivers.contains('auto')
if system_has_kms_drm
# TODO: PPC, Sparc
if ['x86', 'x86_64'].contains(host_machine.cpu_family())
_drivers = 'r300,r600,radeonsi,nouveau,virgl,svga,swrast'
_drivers = [
'r300', 'r600', 'radeonsi', 'nouveau', 'virgl', 'svga', 'swrast'
]
elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
_drivers = 'pl111,vc4,vc5,freedreno,etnaviv,imx,nouveau,tegra,virgl,swrast'
_drivers = [
'pl111', 'vc4', 'vc5', 'freedreno', 'etnaviv', 'imx', 'nouveau',
'tegra', 'virgl', 'swrast',
]
else
error('Unknown architecture. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
endif
elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
_drivers = 'swrast'
_drivers = ['swrast']
else
error('Unknown OS. Please pass -Dgallium-drivers to set driver options. Patches gladly accepted to fix this.')
endif
endif
if _drivers != ''
_split = _drivers.split(',')
with_gallium_pl111 = _split.contains('pl111')
with_gallium_radeonsi = _split.contains('radeonsi')
with_gallium_r300 = _split.contains('r300')
with_gallium_r600 = _split.contains('r600')
with_gallium_nouveau = _split.contains('nouveau')
with_gallium_freedreno = _split.contains('freedreno')
with_gallium_softpipe = _split.contains('swrast')
with_gallium_vc4 = _split.contains('vc4')
with_gallium_vc5 = _split.contains('vc5')
with_gallium_etnaviv = _split.contains('etnaviv')
with_gallium_imx = _split.contains('imx')
with_gallium_tegra = _split.contains('tegra')
with_gallium_i915 = _split.contains('i915')
with_gallium_svga = _split.contains('svga')
with_gallium_virgl = _split.contains('virgl')
with_gallium_swr = _split.contains('swr')
if _drivers != ['']
with_gallium_pl111 = _drivers.contains('pl111')
with_gallium_radeonsi = _drivers.contains('radeonsi')
with_gallium_r300 = _drivers.contains('r300')
with_gallium_r600 = _drivers.contains('r600')
with_gallium_nouveau = _drivers.contains('nouveau')
with_gallium_freedreno = _drivers.contains('freedreno')
with_gallium_softpipe = _drivers.contains('swrast')
with_gallium_vc4 = _drivers.contains('vc4')
with_gallium_vc5 = _drivers.contains('vc5')
with_gallium_etnaviv = _drivers.contains('etnaviv')
with_gallium_imx = _drivers.contains('imx')
with_gallium_tegra = _drivers.contains('tegra')
with_gallium_i915 = _drivers.contains('i915')
with_gallium_svga = _drivers.contains('svga')
with_gallium_virgl = _drivers.contains('virgl')
with_gallium_swr = _drivers.contains('swr')
with_gallium = true
if system_has_kms_drm
_glx = get_option('glx')
@ -195,25 +198,24 @@ with_intel_vk = false
with_amd_vk = false
with_any_vk = false
_vulkan_drivers = get_option('vulkan-drivers')
if _vulkan_drivers == 'auto'
if _vulkan_drivers.contains('auto')
if system_has_kms_drm
if host_machine.cpu_family().startswith('x86')
_vulkan_drivers = 'amd,intel'
_vulkan_drivers = ['amd', 'intel']
else
error('Unknown architecture. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
endif
elif ['darwin', 'windows', 'cygwin', 'haiku'].contains(host_machine.system())
# No vulkan driver supports windows or macOS currently
_vulkan_drivers = ''
_vulkan_drivers = ['']
else
error('Unknown OS. Please pass -Dvulkan-drivers to set driver options. Patches gladly accepted to fix this.')
endif
endif
if _vulkan_drivers != ''
_split = _vulkan_drivers.split(',')
with_intel_vk = _split.contains('intel')
with_amd_vk = _split.contains('amd')
with_any_vk = with_amd_vk or with_intel_vk
if _vulkan_drivers != ['']
with_intel_vk = _drivers.contains('intel')
with_amd_vk = _drivers.contains('amd')
with_any_vk = true
endif
if with_dri_swrast and (with_gallium_softpipe or with_gallium_swr)
@ -254,26 +256,25 @@ with_platform_drm = false
with_platform_surfaceless = false
egl_native_platform = ''
_platforms = get_option('platforms')
if _platforms == 'auto'
if _platforms.contains('auto')
if system_has_kms_drm
_platforms = 'x11,wayland,drm,surfaceless'
_platforms = ['x11', 'wayland', 'drm', 'surfaceless']
elif ['darwin', 'windows', 'cygwin'].contains(host_machine.system())
_platforms = 'x11,surfaceless'
_platforms = ['x11', 'surfaceless']
elif ['haiku'].contains(host_machine.system())
_platforms = 'haiku'
_platforms = ['haiku']
else
error('Unknown OS. Please pass -Dplatforms to set platforms. Patches gladly accepted to fix this.')
endif
endif
if _platforms != ''
_split = _platforms.split(',')
with_platform_android = _split.contains('android')
with_platform_x11 = _split.contains('x11')
with_platform_wayland = _split.contains('wayland')
with_platform_drm = _split.contains('drm')
with_platform_haiku = _split.contains('haiku')
with_platform_surfaceless = _split.contains('surfaceless')
egl_native_platform = _split[0]
if _platforms != ['']
with_platform_android = _platforms.contains('android')
with_platform_x11 = _platforms.contains('x11')
with_platform_wayland = _platforms.contains('wayland')
with_platform_drm = _platforms.contains('drm')
with_platform_haiku = _platforms.contains('haiku')
with_platform_surfaceless = _platforms.contains('surfaceless')
egl_native_platform = _platforms[0]
endif
with_glx = get_option('glx')

View File

@ -1,4 +1,4 @@
# Copyright © 2017 Intel Corporation
# Copyright © 2017-2018 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@ -20,8 +20,11 @@
option(
'platforms',
type : 'string',
value : 'auto',
type : 'array',
value : ['auto'],
choices : [
'', '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.'
)
option(
@ -33,9 +36,10 @@ option(
)
option(
'dri-drivers',
type : 'string',
value : 'auto',
description : 'comma separated list of dri drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
type : 'array',
value : ['auto'],
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(
'dri-drivers-path',
@ -51,9 +55,14 @@ option(
)
option(
'gallium-drivers',
type : 'string',
value : 'auto',
description : 'comma separated list of gallium drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
type : 'array',
value : ['auto'],
choices : [
'', 'auto', 'pl111', 'radeonsi', 'r300', 'r600', 'nouveau', 'freedreno',
'swrast', 'vc4', 'vc5', 'etnaviv', 'imx', 'tegra', 'i915', 'svga', 'virgl',
'swr',
],
description : 'List of gallium drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
)
option(
'gallium-extra-hud',
@ -141,9 +150,10 @@ option(
)
option(
'vulkan-drivers',
type : 'string',
value : 'auto',
description : 'comma separated list of vulkan drivers to build. If this is set to auto all drivers applicable to the target OS/architecture will be built'
type : 'array',
value : ['auto'],
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(
'shader-cache',
@ -276,13 +286,15 @@ option(
)
option(
'swr-arches',
type : 'string',
value : 'avx,avx2',
description : 'Comma delemited swr architectures. choices : avx,avx2,knl,skx'
type : 'array',
value : ['avx', 'avx2'],
choices : ['avx', 'avx2', 'knl', 'skx'],
description : 'Architectures to build SWR support for.',
)
option(
'tools',
type : 'string',
value : '',
description : 'Comma delimited list of tools to build. choices : freedreno,glsl,intel,nir,nouveau or all'
type : 'array',
value : [],
choices : ['freedreno', 'glsl', 'intel', 'nir', 'nouveau', 'all'],
description : 'List of tools to build.',
)