meson: support building with system libgbm
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

This is the next step towards making libgbm just a loader.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33890>
This commit is contained in:
K900 2025-03-05 13:14:02 +03:00 committed by Marge Bot
parent d1ff9e951a
commit 3d7bfcf984
10 changed files with 34 additions and 17 deletions

View file

@ -2365,7 +2365,7 @@ summary(egl_summary, section: 'EGL', bool_yn: true, list_sep: ' ')
gbm_summary = {'Enabled': with_gbm}
if with_gbm
gbm_summary += {'Backends path': gbm_backends_path}
gbm_summary += {'External libgbm': get_option('libgbm-external'), 'Backends path': gbm_backends_path}
endif
summary(gbm_summary, section: 'GBM', bool_yn: true, list_sep: ' ')

View file

@ -330,6 +330,13 @@ option(
description : 'Build support for gbm platform'
)
option(
'libgbm-external',
type: 'boolean',
value: false,
description: 'Whether to use external libgbm (default: use in-tree copy)'
)
option(
'gbm-backends-path',
type : 'string',

View file

@ -108,9 +108,8 @@ if with_dri
endif
if with_gbm and not with_platform_android
files_egl += files('drivers/dri2/platform_drm.c')
link_for_egl += libgbm
incs_for_egl += [inc_gbm, include_directories('../gbm/main')]
deps_for_egl += dep_libdrm
incs_for_egl += [include_directories('../gbm/backends/dri')]
deps_for_egl += [dep_libdrm, dep_gbm]
endif
if with_platform_wayland
deps_for_egl += [dep_wayland_client, dep_wayland_server, dep_wayland_egl_headers]

View file

@ -25,7 +25,7 @@
#include <dlfcn.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "gbm/main/gbm.h"
#include <gbm.h>
#include "drm-uapi/drm_fourcc.h"
#define EGL_PLATFORM_GBM_MESA 0x31D7

View file

@ -51,10 +51,10 @@ dril_dri = shared_library(
link_depends : dril_link_depends,
link_with : [
libgallium,
libgbm,
],
dependencies : [
idep_mesautil,
dep_gbm,
],
# Will be deleted during installation, see install_megadrivers.py
install : true,

View file

@ -43,7 +43,7 @@
#include "mesa_interface.h"
#include "gbm_driint.h"
#include "gbmint.h"
#include <gbm_backend_abi.h>
#include "loader_dri_helper.h"
#include "kopper_interface.h"
#include "loader.h"

View file

@ -31,7 +31,7 @@
#include <xf86drm.h>
#include <string.h>
#include <sys/mman.h>
#include "gbmint.h"
#include <gbm_backend_abi.h>
#include "c11/threads.h"
#include <GL/gl.h> /* mesa_interface needs GL types */

View file

@ -11,10 +11,10 @@ endif
shared_library(
'dri_gbm',
files('gbm_dri.c', 'gbm_driint.h'),
include_directories : [incs_gbm, incs_gbm_dri, inc_st_dri, inc_gallium_aux],
include_directories : [inc_gallium, incs_gbm_dri, inc_loader, inc_st_dri, inc_gallium_aux],
link_args : [ld_args_gc_sections],
link_with : [libloader, libgallium_dri],
dependencies : [deps_gbm_dri, dep_dl, dep_libdrm, idep_mesautil, idep_xmlconfig],
dependencies : [deps_gbm_dri, dep_dl, dep_gbm, dep_libdrm, idep_mesautil, idep_xmlconfig],
gnu_symbol_visibility : 'hidden',
install : true,
install_dir: join_paths(get_option('libdir'), 'gbm'),

View file

@ -15,10 +15,6 @@ args_gbm = [
]
incs_gbm = [include_directories('main'), inc_loader, inc_gallium]
if with_dri2
subdir('backends/dri')
endif
libgbm_name = 'gbm'
if with_platform_android and get_option('platform-sdk-version') >= 30
@ -43,7 +39,7 @@ if with_tests
test('gbm-abi-check', abi_check, suite : ['gbm'])
endif
install_headers('main/gbm.h')
install_headers('main/gbm.h', 'main/gbm_backend_abi.h')
pkg.generate(
name : 'gbm',
@ -67,3 +63,8 @@ if with_symbols_check
suite : ['gbm'],
)
endif
dep_gbm = declare_dependency(
link_with : libgbm,
include_directories : inc_gbm,
)

View file

@ -127,11 +127,17 @@ endif
if with_glx == 'dri'
subdir('glx')
endif
if with_gbm
subdir('gbm')
if get_option('libgbm-external')
dep_gbm = dependency('gbm')
else
subdir('gbm')
endif
else
inc_gbm = []
dep_gbm = null_dep
endif
if with_egl
subdir('egl')
endif
@ -141,6 +147,10 @@ if with_gallium and with_gbm
endif
endif
if with_gbm and with_dri2
subdir('gbm/backends/dri')
endif
# This must be after at least mesa, glx, and gallium, since libgl will be
# defined in one of those subdirs depending on the glx provider.
if with_glx != 'disabled' and not with_glvnd