From 278d894146c047452e7145cbfc34c00742f46108 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Wed, 21 May 2025 11:15:46 -0400 Subject: [PATCH] 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 Part-of: --- meson.build | 11 +++++++++-- meson.options | 10 ++++++++++ subprojects/libdrm.wrap | 6 ++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 subprojects/libdrm.wrap diff --git a/meson.build b/meson.build index 0a227880e4f..277a7842c46 100644 --- a/meson.build +++ b/meson.build @@ -1670,12 +1670,18 @@ if _drm_blame != '' message('libdrm @0@ needed because @1@ has the highest requirement'.format(_drm_ver, _drm_blame)) endif +allow_fallback_for_libdrm = get_option('allow-fallback-for').contains('libdrm') + # Then get each libdrm module foreach d : _libdrm_checks if d[1] set_variable( '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 endforeach @@ -1684,7 +1690,8 @@ with_gallium_drisw_kms = false if system_has_kms_drm dep_libdrm = dependency( '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 # We should prevent libdrm from being available when the target doesn't have it to avoid transitive diff --git a/meson.options b/meson.options index ded6649d511..5fd5102d3fb 100644 --- a/meson.options +++ b/meson.options @@ -832,3 +832,13 @@ option( value : false, 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.' +) diff --git a/subprojects/libdrm.wrap b/subprojects/libdrm.wrap new file mode 100644 index 00000000000..9fbfeadfc9e --- /dev/null +++ b/subprojects/libdrm.wrap @@ -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