From ce07aabab124e14a47f13f9fb734d9502cf527b5 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 12 Jun 2023 10:53:58 -0700 Subject: [PATCH] meson: Key whether to build batch decoder on expat Instead of on Android. Which allows an end user to turn off expat without breaking or disabling Intel support. I've additionally refactored to separate expat and xmlconfig a bit more in the root meson.build This does make expat a hard dependency for building Intel tools, despite the fact that only aubinator actually requires it. This simplifies the build for the common case, and in the event that someone wants to build the Intel tools and doesn't have libexpat, they can fall back to the meson wrap for expat instead. fixes: 75276deebcf76f8fafa68f4e4ecb29768d98c764 closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8791 Reviewed-by: Mark Janes Part-of: --- meson.build | 24 +++++++++++++++++------- meson_options.txt | 9 +++++++++ src/intel/common/meson.build | 2 +- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 728fa74626e..51aeed8e651 100644 --- a/meson.build +++ b/meson.build @@ -1497,18 +1497,28 @@ if dep_thread.found() endif endif -# We don't have expat on Android or Windows, which is a needed dep for xmlconfig -opt_xmlconfig = get_option('xmlconfig') \ - .require(not (with_platform_android or with_platform_windows), - error_message : 'xmlconfig not available on Android or Windows') +with_expat = get_option('expat') \ + .disable_auto_if(with_platform_android or with_platform_windows) if host_machine.system() == 'darwin' - dep_expat = meson.get_compiler('c').find_library('expat', required : opt_xmlconfig) + dep_expat = meson.get_compiler('c').find_library('expat', required : with_expat) else dep_expat = dependency('expat', fallback : ['expat', 'expat_dep'], - required : opt_xmlconfig) + required : with_expat) endif -use_xmlconfig = dep_expat.found() + +# TODO: with Meson 1.1.0 this can be replaced with with_expat.enable_if(with_intel_tools) +if with_intel_tools and not dep_expat.found() + error('Intel tools require expat') +endif + +# We don't require expat on Android or Windows +use_xmlconfig = get_option('xmlconfig') \ + .require(not (with_platform_android or with_platform_windows), + error_message : 'xmlconfig not available on Android or Windows') \ + .require(dep_expat.found(), + error_message : 'requires expat') \ + .allowed() # Predefined macros for windows if host_machine.system() == 'windows' diff --git a/meson_options.txt b/meson_options.txt index 5984dc6d768..34a55ad7091 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -58,6 +58,14 @@ option( 'separated list. Default: dri-drivers-path.' ) +option( + 'expat', + type : 'feature', + value : 'auto', + description : 'Controls the use of expat. ' + + 'Cannot be disabled if xmlconfig is enabled.' +) + option( 'gallium-drivers', type : 'array', @@ -649,6 +657,7 @@ option( 'the default driconf file is hardcoded into Mesa. ' + 'Requires expat.' ) + option ( 'intel-xe-kmd', type : 'feature', diff --git a/src/intel/common/meson.build b/src/intel/common/meson.build index 0537de3614a..ad295ee188a 100644 --- a/src/intel/common/meson.build +++ b/src/intel/common/meson.build @@ -58,7 +58,7 @@ files_batch_decoder = files( ) batch_decoder_dependencies = [] -if with_platform_android +if not dep_expat.found() files_libintel_common += 'intel_batch_decoder_stub.c' else batch_decoder_dependencies += dep_expat