From 52747d70e05de4da76767630e725e80b22b08029 Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Mon, 4 Oct 2021 09:23:15 -0600 Subject: [PATCH 1/3] meson: Don't use x11 at all if the x11 feature is disabled. Currently, building with -Dx11=disabled or -Dx11=auto gives identical results. In both cases, it only makes the x11 dependency optional: It'll still look for libx11, and if libx11 is available, then it'll still build with X11 support enabled. This changes the meson build so that if you pass -Dx11=disabled, then it will use a dummy dependency for x11, which will cause it to build as if libx11 was not available. --- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index cbe2ec4..a462465 100644 --- a/meson.build +++ b/meson.build @@ -87,7 +87,12 @@ endif dep_dl = cc.find_library('dl', required : false) dep_m = cc.find_library('m', required : false) dep_threads = dependency('threads') -dep_x11 = dependency('x11', required : get_option('x11')) +if get_option('x11').disabled() + dep_x11 = dependency('', required : false) +else + dep_x11 = dependency('x11', required : get_option('x11')) +endif + dep_x11_headers = dep_x11.partial_dependency(compile_args : true, includes : true) if dep_x11.found() add_project_arguments('-DUSE_X11', language : ['c']) From fa9ef3971ff9445e1cd30cb5291ec855629b307d Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Mon, 4 Oct 2021 09:31:42 -0600 Subject: [PATCH 2/3] Replace USE_X11 macro with ENABLE_EGL_X11. If x11 support is enabled, then the meson and configure scripts will set a macro named ENABLE_EGL_X11 instead of USE_X11. USE_X11 will also select the Xlib typedef of EGLNativeDisplayType in eglplatform.h, and libglvnd does not need or want those. Enabling or disabling X11 support for EGL only affects platform detection in eglGetDisplay. The rest of libEGL is supposed to treat EGLNativeDisplayType as an opaque void* pointer. --- configure.ac | 2 +- meson.build | 2 +- src/EGL/libegl.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index a205e56..62f3ad7 100644 --- a/configure.ac +++ b/configure.ac @@ -203,7 +203,7 @@ AX_PTHREAD() if test "x$enable_x11" = "xyes" ; then PKG_CHECK_MODULES([X11], [x11]) - AC_DEFINE([USE_X11], 1, + AC_DEFINE([ENABLE_EGL_X11], 1, [Define to 1 if X11 support is enabled.]) fi if test "x$enable_glx" = "xyes" ; then diff --git a/meson.build b/meson.build index a462465..6737703 100644 --- a/meson.build +++ b/meson.build @@ -95,7 +95,7 @@ endif dep_x11_headers = dep_x11.partial_dependency(compile_args : true, includes : true) if dep_x11.found() - add_project_arguments('-DUSE_X11', language : ['c']) + add_project_arguments('-DENABLE_EGL_X11', language : ['c']) endif dep_xext = dep_null diff --git a/src/EGL/libegl.c b/src/EGL/libegl.c index 1fe5884..4e9f615 100644 --- a/src/EGL/libegl.c +++ b/src/EGL/libegl.c @@ -32,7 +32,7 @@ #include #include -#if defined(USE_X11) +#if defined(ENABLE_EGL_X11) #include #endif @@ -176,7 +176,7 @@ static EGLBoolean IsGbmDisplay(void *native_display) static EGLBoolean IsX11Display(void *dpy) { -#if defined(USE_X11) +#if defined(ENABLE_EGL_X11) void *alloc; void *handle; void *XAllocID = NULL; @@ -193,9 +193,9 @@ static EGLBoolean IsX11Display(void *dpy) } return (XAllocID != NULL && XAllocID == alloc); -#else // defined(USE_X11) +#else // defined(ENABLE_EGL_X11) return EGL_FALSE; -#endif // defined(USE_X11) +#endif // defined(ENABLE_EGL_X11) } static EGLBoolean IsWaylandDisplay(void *native_display) From 27eb562a11a77798d404444db88dbd0512d44f46 Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Wed, 6 Oct 2021 10:40:38 -0600 Subject: [PATCH 3/3] tests: Remove the X11 dependency from the EGL tests. The EGL tests don't use X11, and only included the Xlib headers by way of eglplatform.h. Now that we don't set the USE_X11 macro anymore, eglplatform.h won't try to include anything from Xlib, and so the EGL tests don't need X11 as a dependency. --- tests/dummy/meson.build | 2 +- tests/meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/dummy/meson.build b/tests/dummy/meson.build index d8f29f4..f15c144 100644 --- a/tests/dummy/meson.build +++ b/tests/dummy/meson.build @@ -48,7 +48,7 @@ if get_option('egl') c_args : ['-DDUMMY_VENDOR_NAME="dummy@0@"'.format(v)], include_directories : [inc_include], link_with: [libpatchentrypoints], - dependencies : [idep_glvnd_pthread, dep_x11_headers], + dependencies : [idep_glvnd_pthread], version : '0', ) endforeach diff --git a/tests/meson.build b/tests/meson.build index fa2e2bf..a16c033 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -200,7 +200,7 @@ if get_option('egl') ['test@0@.c'.format(t[0]), 'egl_test_utils.c'], include_directories : [inc_include], link_with : [libEGL, t[1]], - dependencies : [t[2], dep_x11_headers], + dependencies : [t[2]], ), env : env_egl, suite : ['egl'],