meson: Avoid building hook library when not needed

The hook library is for hacking GBM/EGL/X11 APIs.

Change-Id: I98c0d0a4fff4b1a56688e82367cf563700eec8f9
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
This commit is contained in:
Jeffy Chen 2025-02-28 18:40:48 +08:00
parent 7ea1c41397
commit da4d604016
2 changed files with 11 additions and 6 deletions

View file

@ -29,7 +29,7 @@ libhook_dep = [
libhook_inc = []
if cc.has_function('gbm_create_device', dependencies : mali)
if has_gbm
# Add hooks to support new GBM APIs
libhook_inc += include_directories('..' / gbm_headers.keys()[0])
libhook_cflags += '-DHAS_GBM'
@ -40,7 +40,7 @@ if cc.has_function('gbm_create_device', dependencies : mali)
endforeach
endif
if cc.has_function('eglCreateContext', dependencies : mali)
if has_egl
# Add hooks to support default winsys
libhook_inc += include_directories('../include')
libhook_cflags += '-DHAS_EGL'

View file

@ -52,11 +52,10 @@ is_utgard = gpu.split('-')[0] == 'utgard'
is_px3se = gpu == 'utgard-400' and subversion == 'r3p0'
# Parse platforms
has_gbm = run_command('grep', '-wq', 'gbm_create_device', default_lib,
has_gbm = cc.has_function('gbm_create_device', dependencies : mali)
has_x11 = run_command('grep', '-wq', 'libxcb.so', default_lib,
check : false).returncode() == 0
has_x11 = run_command('grep', '-wq', 'XSync', default_lib,
check : false).returncode() == 0
has_wayland = run_command('grep', '-wq', 'wl_egl_window_create', default_lib,
has_wayland = run_command('grep', '-wq', 'libwayland-client.so', default_lib,
check : false).returncode() == 0
message('Using ' + default_lib + ' with' + (has_x11 ? ' x11' : '') +
@ -89,6 +88,12 @@ foreach require : requires
dependency(require)
endforeach
# The hook library is for hacking GBM/EGL/X11 APIs
has_egl = cc.has_function('eglCreateContext', dependencies : mali)
if not has_gbm and not has_egl and not has_x11
build_hook = false
endif
if wrappers_opts.auto() and is_utgard
wrappers = false
warning('Wrappers are disabled for utgard by default')