meson: add wrap for libdrm

This allows building Mesa with the Android NDK, which doesn't provide
libdrm.

We will generate an `Android.bp` file using the `ninja-to-soong` tool
(https://github.com/rjodinchr/ninja-to-soong), and to do this we run
Mesa's standard meson build system to generate the ninja commands that
we then translate to soong.

That meson invocation is done using the Android NDK, which doesn't
provide libdrm, so until we find an alternative solution[*] we provide a
wrap file that builds libdrm as part of the Mesa build (but does not
install it--we still use the Android-provided libdrm at runtime)

Co-authored-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35058>
This commit is contained in:
Matt Turner 2025-05-21 11:15:46 -04:00 committed by Marge Bot
parent 2249ba9fa3
commit 278d894146
3 changed files with 25 additions and 2 deletions

View file

@ -1670,12 +1670,18 @@ if _drm_blame != ''
message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame)) message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame))
endif endif
allow_fallback_for_libdrm = get_option('allow-fallback-for').contains('libdrm')
# Then get each libdrm module # Then get each libdrm module
foreach d : _libdrm_checks foreach d : _libdrm_checks
if d[1] if d[1]
set_variable( set_variable(
'dep_libdrm_' + d[0], 'dep_libdrm_' + d[0],
dependency('libdrm_' + d[0], version : '>=' + _drm_ver) dependency(
'libdrm_' + d[0],
version : '>=' + _drm_ver,
allow_fallback: allow_fallback_for_libdrm,
)
) )
endif endif
endforeach endforeach
@ -1684,7 +1690,8 @@ with_gallium_drisw_kms = false
if system_has_kms_drm if system_has_kms_drm
dep_libdrm = dependency( dep_libdrm = dependency(
'libdrm', version : '>=' + _drm_ver, 'libdrm', version : '>=' + _drm_ver,
required : with_dri2 or with_dri or with_gbm required : with_dri2 or with_dri or with_gbm,
allow_fallback: allow_fallback_for_libdrm,
) )
else else
# We should prevent libdrm from being available when the target doesn't have it to avoid transitive # We should prevent libdrm from being available when the target doesn't have it to avoid transitive

View file

@ -832,3 +832,13 @@ option(
value : false, value : false,
description : 'Install the drivers internal shader compilers (if needed for cross builds).' description : 'Install the drivers internal shader compilers (if needed for cross builds).'
) )
option(
'allow-fallback-for',
type : 'array',
value : [],
choices : [
'libdrm',
],
description : 'Allows the fallback mechanism if the dependency is not available on the system, or too old.'
)

6
subprojects/libdrm.wrap Normal file
View file

@ -0,0 +1,6 @@
[wrap-file]
directory = libdrm-2.4.123
source_url = https://dri.freedesktop.org/libdrm/libdrm-2.4.123.tar.xz
source_filename = libdrm-2.4.123.tar.xz
source_hash = a2b98567a149a74b0f50e91e825f9c0315d86e7be9b74394dae8b298caadb79e
wrapdb_version = 2.4.123-1