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 <alyssa@collabora.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com> [v2]
Reviewed-by: Eric Engestrom <eric@igalia.com> [v2]
Reviewed-by: Emma Anholt <emma@anholt.net>
Tested-by: Chris Healy <healych@amazon.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19626>
This commit is contained in:
Alyssa Rosenzweig 2022-11-09 14:30:31 -05:00 committed by Marge Bot
parent fb0a4a5d6c
commit 662bb5977b
2 changed files with 18 additions and 4 deletions

View File

@ -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.'
)

View File

@ -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,