From 662bb5977b678861cbfe80c152359efd7eab8a32 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 9 Nov 2022 14:30:31 -0500 Subject: [PATCH] util: Add xmlconfig build option On embedded Linux, we can hardcode the driconf file (00-mesa-defaults.conf) with no possibility of the file changing after the build. The static driconf implementation, used on Windows and Android, suffices for that use case. It is undesireable for these platforms to depend on expat or to spend time during app start-up parsing driconf XML. We already have the static driconf implemented, all we need is a meson option to opt-out of runtime xmlconfig on Linux and use the static version instead. To opt-out of runtime xmlconfig, build Mesa with -Dxmlconfig=disabled. v2: Expand out feature.require() since it was only added in meson 0.59.0. v3: Use more concise Meson syntax (Dylan) Signed-off-by: Alyssa Rosenzweig Reviewed-by: Jesse Natalie [v2] Reviewed-by: Eric Engestrom [v2] Reviewed-by: Emma Anholt Tested-by: Chris Healy Part-of: --- meson_options.txt | 6 ++++++ src/util/meson.build | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 6f307018815b0..b8e3d73b3025c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -555,3 +555,9 @@ option( value : 8, description : 'Minimum Windows version to support. Defaults to Windows 8.' ) +option( + 'xmlconfig', + type : 'feature', + value : 'auto', + description : 'Build custom xmlconfig (driconf) support. If disabled, the default driconf file is hardcoded into Mesa. Requires expat.' +) diff --git a/src/util/meson.build b/src/util/meson.build index 43e5e39efde72..3f1aa152152c7 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -286,15 +286,23 @@ idep_mesautil = declare_dependency( dependencies : deps_for_libmesa_util, ) +# We don't have expat on Android or Windows, which is a needed dep for xmlconfig +supports_xmlconfig = not (with_platform_android or with_platform_windows) + +opt_xmlconfig = get_option('xmlconfig') +if opt_xmlconfig.enabled() and not supports_xmlconfig + error('xmlconfig not available on Android or Windows') +endif +use_xmlconfig = supports_xmlconfig and not opt_xmlconfig.disabled() + xmlconfig_deps = [] -if not (with_platform_android or with_platform_windows) - c_xmlconfig_arg = '-DWITH_XMLCONFIG=1' +if use_xmlconfig xmlconfig_deps += dep_expat -else - c_xmlconfig_arg = '-DWITH_XMLCONFIG=0' endif xmlconfig_deps += dep_regex +c_xmlconfig_arg = '-DWITH_XMLCONFIG=@0@'.format(use_xmlconfig.to_int()) + _libxmlconfig = static_library( 'xmlconfig', files_xmlconfig,