meson: Use feature.require() and feature.allowed()
To reduce the size and complexity of checks. require() allows combining auto and enabled checks(), so that something like ```meson x = get_option('feature') y = false if x.enabled() if not condition error(...) endif y = condition endif ``` can be rewritten as: ```meson y = get_option('feature').require(condition, error_message : ...).allowed() ``` require checks the condition, then if the feature is required it emits an error with the given message otherwise it returns a disabled feature. allowed then returns whether the feature is not disabled, and returns that (ie, .allowed() == not .disabled()). This is especially helpful for longer more complex conditions Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>main
parent
a6a2ccb448
commit
16e6a96505
|
@ -41,10 +41,10 @@ stages:
|
||||||
BUILD_OS: debian
|
BUILD_OS: debian
|
||||||
FDO_DISTRIBUTION_VERSION: buster
|
FDO_DISTRIBUTION_VERSION: buster
|
||||||
FDO_DISTRIBUTION_PACKAGES: 'build-essential docbook-xsl libatomic-ops-dev libcairo2-dev libcunit1-dev libpciaccess-dev meson ninja-build pkg-config python3 python3-pip python3-wheel python3-setuptools python3-docutils valgrind'
|
FDO_DISTRIBUTION_PACKAGES: 'build-essential docbook-xsl libatomic-ops-dev libcairo2-dev libcunit1-dev libpciaccess-dev meson ninja-build pkg-config python3 python3-pip python3-wheel python3-setuptools python3-docutils valgrind'
|
||||||
FDO_DISTRIBUTION_EXEC: 'pip3 install meson==0.53.0'
|
FDO_DISTRIBUTION_EXEC: 'pip3 install meson==0.59.0'
|
||||||
# bump this tag every time you change something which requires rebuilding the
|
# bump this tag every time you change something which requires rebuilding the
|
||||||
# base image
|
# base image
|
||||||
FDO_DISTRIBUTION_TAG: "2022-08-22.0"
|
FDO_DISTRIBUTION_TAG: "2023-09-01.0"
|
||||||
|
|
||||||
.debian-x86_64:
|
.debian-x86_64:
|
||||||
extends:
|
extends:
|
||||||
|
|
120
meson.build
120
meson.build
|
@ -23,7 +23,7 @@ project(
|
||||||
['c'],
|
['c'],
|
||||||
version : '2.4.116',
|
version : '2.4.116',
|
||||||
license : 'MIT',
|
license : 'MIT',
|
||||||
meson_version : '>= 0.53',
|
meson_version : '>= 0.59',
|
||||||
default_options : ['buildtype=debugoptimized', 'c_std=c11'],
|
default_options : ['buildtype=debugoptimized', 'c_std=c11'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,113 +84,61 @@ config.set10('HAVE_LIB_ATOMIC_OPS', lib_atomics)
|
||||||
|
|
||||||
dep_pciaccess = dependency('pciaccess', version : '>= 0.10', required : get_option('intel'))
|
dep_pciaccess = dependency('pciaccess', version : '>= 0.10', required : get_option('intel'))
|
||||||
|
|
||||||
with_intel = false
|
with_intel = get_option('intel') \
|
||||||
_intel = get_option('intel')
|
.require(with_atomics, error_message : 'libdrm_intel requires atomics') \
|
||||||
if not _intel.disabled()
|
.require(dep_pciaccess.found(), error_message : 'libdrm_intel requires libpciaccess') \
|
||||||
if _intel.enabled()
|
.disable_auto_if(not host_machine.system().startswith('x86')) \
|
||||||
if not with_atomics
|
.allowed()
|
||||||
error('libdrm_intel requires atomics.')
|
|
||||||
elif not dep_pciaccess.found()
|
|
||||||
error('libdrm_intel requires libpciaccess')
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
with_intel = (_intel.enabled() or host_machine.cpu_family().startswith('x86')) and with_atomics and dep_pciaccess.found()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
summary('Intel', with_intel)
|
summary('Intel', with_intel)
|
||||||
|
|
||||||
with_radeon = false
|
with_radeon = get_option('radeon') \
|
||||||
_radeon = get_option('radeon')
|
.require(with_atomics, error_message : 'libdrm_radeon requires atomics') \
|
||||||
if not _radeon.disabled()
|
.allowed()
|
||||||
if _radeon.enabled() and not with_atomics
|
|
||||||
error('libdrm_radeon requires atomics.')
|
|
||||||
endif
|
|
||||||
with_radeon = with_atomics
|
|
||||||
endif
|
|
||||||
summary('Radeon', with_radeon)
|
summary('Radeon', with_radeon)
|
||||||
|
|
||||||
with_amdgpu = false
|
with_amdgpu = get_option('amdgpu') \
|
||||||
_amdgpu = get_option('amdgpu')
|
.require(with_atomics, error_message : 'libdrm_amdgpu requires atomics') \
|
||||||
if not _amdgpu.disabled()
|
.allowed()
|
||||||
if _amdgpu.enabled() and not with_atomics
|
|
||||||
error('libdrm_amdgpu requires atomics.')
|
|
||||||
endif
|
|
||||||
with_amdgpu = with_atomics
|
|
||||||
endif
|
|
||||||
summary('AMDGPU', with_amdgpu)
|
summary('AMDGPU', with_amdgpu)
|
||||||
|
|
||||||
with_nouveau = false
|
with_nouveau = get_option('nouveau') \
|
||||||
_nouveau = get_option('nouveau')
|
.require(with_atomics, error_message : 'libdrm_nouveau requires atomics') \
|
||||||
if not _nouveau.disabled()
|
.allowed()
|
||||||
if _nouveau.enabled() and not with_atomics
|
|
||||||
error('libdrm_nouveau requires atomics.')
|
|
||||||
endif
|
|
||||||
with_nouveau = with_atomics
|
|
||||||
endif
|
|
||||||
summary('Nouveau', with_nouveau)
|
summary('Nouveau', with_nouveau)
|
||||||
|
|
||||||
with_vmwgfx = false
|
with_vmwgfx = get_option('vmwgfx').allowed()
|
||||||
_vmwgfx = get_option('vmwgfx')
|
|
||||||
if not _vmwgfx.disabled()
|
|
||||||
with_vmwgfx = true
|
|
||||||
endif
|
|
||||||
summary('vmwgfx', with_vmwgfx)
|
summary('vmwgfx', with_vmwgfx)
|
||||||
|
|
||||||
with_omap = false
|
with_omap = get_option('omap') \
|
||||||
_omap = get_option('omap')
|
.require(with_atomics, error_message : 'libdrm_omap requires atomics') \
|
||||||
if _omap.enabled()
|
.enabled()
|
||||||
if not with_atomics
|
|
||||||
error('libdrm_omap requires atomics.')
|
|
||||||
endif
|
|
||||||
with_omap = true
|
|
||||||
endif
|
|
||||||
summary('OMAP', with_omap)
|
summary('OMAP', with_omap)
|
||||||
|
|
||||||
with_freedreno = false
|
with_freedreno = get_option('freedreno') \
|
||||||
_freedreno = get_option('freedreno')
|
.require(with_atomics, error_message : 'libdrm_freedreno requires atomics') \
|
||||||
if not _freedreno.disabled()
|
.disable_auto_if(not ['arm', 'aarch64'].contains(host_machine.cpu_family())) \
|
||||||
if _freedreno.enabled() and not with_atomics
|
.allowed()
|
||||||
error('libdrm_freedreno requires atomics.')
|
|
||||||
else
|
|
||||||
with_freedreno = (_freedreno.enabled() or ['arm', 'aarch64'].contains(host_machine.cpu_family())) and with_atomics
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
summary('Freedreno', with_freedreno)
|
summary('Freedreno', with_freedreno)
|
||||||
summary('Freedreon-kgsl', with_freedreno_kgsl)
|
summary('Freedreon-kgsl', with_freedreno_kgsl)
|
||||||
|
|
||||||
with_tegra = false
|
with_tegra = get_option('tegra') \
|
||||||
_tegra = get_option('tegra')
|
.require(with_atomics, error_message : 'libdrm_tegra requires atomics') \
|
||||||
if _tegra.enabled()
|
.disable_auto_if(not ['arm', 'aarch64'].contains(host_machine.cpu_family())) \
|
||||||
if not with_atomics
|
.enabled()
|
||||||
error('libdrm_tegra requires atomics.')
|
|
||||||
endif
|
|
||||||
with_tegra = true
|
|
||||||
endif
|
|
||||||
summary('Tegra', with_tegra)
|
summary('Tegra', with_tegra)
|
||||||
|
|
||||||
with_etnaviv = false
|
with_etnaviv = get_option('etnaviv') \
|
||||||
_etnaviv = get_option('etnaviv')
|
.require(with_atomics, error_message : 'libdrm_etnaviv requires atomics') \
|
||||||
if not _etnaviv.disabled()
|
.disable_auto_if(not ['arm', 'aarch64', 'arc', 'mips', 'mips64', 'loongarch64'].contains(host_machine.cpu_family())) \
|
||||||
if _etnaviv.enabled() and not with_atomics
|
.allowed()
|
||||||
error('libdrm_etnaviv requires atomics.')
|
|
||||||
endif
|
|
||||||
with_etnaviv = _etnaviv.enabled() or (
|
|
||||||
with_atomics and [
|
|
||||||
'loongarch64', 'mips', 'mips64',
|
|
||||||
'arm', 'aarch64', 'arc',
|
|
||||||
].contains(host_machine.cpu_family())
|
|
||||||
)
|
|
||||||
endif
|
|
||||||
summary('Etnaviv', with_etnaviv)
|
summary('Etnaviv', with_etnaviv)
|
||||||
|
|
||||||
with_exynos = get_option('exynos').enabled()
|
with_exynos = get_option('exynos').enabled()
|
||||||
summary('EXYNOS', with_exynos)
|
summary('EXYNOS', with_exynos)
|
||||||
|
|
||||||
with_vc4 = false
|
with_vc4 = get_option('vc4') \
|
||||||
_vc4 = get_option('vc4')
|
.disable_auto_if(not ['arm', 'aarch64'].contains(host_machine.cpu_family())) \
|
||||||
if not _vc4.disabled()
|
.allowed()
|
||||||
with_vc4 = _vc4.enabled() or ['arm', 'aarch64'].contains(host_machine.cpu_family())
|
|
||||||
endif
|
|
||||||
summary('VC4', with_vc4)
|
summary('VC4', with_vc4)
|
||||||
|
|
||||||
# Among others FreeBSD does not have a separate dl library.
|
# Among others FreeBSD does not have a separate dl library.
|
||||||
|
|
Loading…
Reference in New Issue