backend: make DRM and libinput backends optional

Co-authored-by: Simon Ser <contact@emersion.fr>
master
ayaka 4 years ago committed by Simon Zeni
parent 66c42f4fcb
commit 70fb21c35b

@ -6,10 +6,9 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/backend/drm.h>
#include <wlr/backend/headless.h> #include <wlr/backend/headless.h>
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/backend/libinput.h>
#include <wlr/backend/multi.h> #include <wlr/backend/multi.h>
#include <wlr/backend/noop.h> #include <wlr/backend/noop.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
@ -22,6 +21,14 @@
#include "render/allocator.h" #include "render/allocator.h"
#include "util/signal.h" #include "util/signal.h"
#if WLR_HAS_DRM_BACKEND
#include <wlr/backend/drm.h>
#endif
#if WLR_HAS_LIBINPUT_BACKEND
#include <wlr/backend/libinput.h>
#endif
#if WLR_HAS_X11_BACKEND #if WLR_HAS_X11_BACKEND
#include <wlr/backend/x11.h> #include <wlr/backend/x11.h>
#endif #endif
@ -211,6 +218,7 @@ static struct wlr_backend *attempt_noop_backend(struct wl_display *display) {
return backend; return backend;
} }
#if WLR_HAS_DRM_BACKEND
static struct wlr_backend *attempt_drm_backend(struct wl_display *display, static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
struct wlr_backend *backend, struct wlr_session *session) { struct wlr_backend *backend, struct wlr_session *session) {
struct wlr_device *gpus[8]; struct wlr_device *gpus[8];
@ -240,6 +248,7 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
return primary_drm; return primary_drm;
} }
#endif
static struct wlr_backend *attempt_backend_by_name(struct wl_display *display, static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
struct wlr_backend *backend, struct wlr_session **session, struct wlr_backend *backend, struct wlr_session **session,
@ -265,9 +274,17 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
} }
if (strcmp(name, "libinput") == 0) { if (strcmp(name, "libinput") == 0) {
#if WLR_HAS_LIBINPUT_BACKEND
return wlr_libinput_backend_create(display, *session); return wlr_libinput_backend_create(display, *session);
#else
return NULL;
#endif
} else { } else {
#if WLR_HAS_DRM_BACKEND
return attempt_drm_backend(display, backend, *session); return attempt_drm_backend(display, backend, *session);
#else
return NULL;
#endif
} }
} }
@ -355,6 +372,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
return NULL; return NULL;
} }
#if WLR_HAS_LIBINPUT_BACKEND
struct wlr_backend *libinput = wlr_libinput_backend_create(display, struct wlr_backend *libinput = wlr_libinput_backend_create(display,
multi->session); multi->session);
if (!libinput) { if (!libinput) {
@ -364,7 +382,9 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
return NULL; return NULL;
} }
wlr_multi_backend_add(backend, libinput); wlr_multi_backend_add(backend, libinput);
#endif
#if WLR_HAS_DRM_BACKEND
struct wlr_backend *primary_drm = struct wlr_backend *primary_drm =
attempt_drm_backend(display, backend, multi->session); attempt_drm_backend(display, backend, multi->session);
if (!primary_drm) { if (!primary_drm) {
@ -376,6 +396,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
} }
return backend; return backend;
#endif
error: error:
wlr_backend_destroy(backend); wlr_backend_destroy(backend);

@ -8,3 +8,5 @@ wlr_files += files(
'renderer.c', 'renderer.c',
'util.c', 'util.c',
) )
features += { 'drm-backend': true }

@ -1,3 +1,19 @@
msg = ['Required for libinput backend support.']
if 'libinput' in backends
msg += 'Install "libinput" or disable the libinput backend.'
endif
libinput = dependency(
'libinput',
version: '>=1.14.0',
required: 'libinput' in backends,
not_found_message: '\n'.join(msg),
)
if not libinput.found()
subdir_done()
endif
wlr_files += files( wlr_files += files(
'backend.c', 'backend.c',
'events.c', 'events.c',
@ -8,3 +24,6 @@ wlr_files += files(
'tablet_tool.c', 'tablet_tool.c',
'touch.c', 'touch.c',
) )
features += { 'libinput-backend': true }
wlr_deps += libinput

@ -1,11 +1,22 @@
wlr_files += files('backend.c') wlr_files += files('backend.c')
subdir('drm') all_backends = ['drm', 'libinput', 'x11']
subdir('headless') backends = get_option('backends')
subdir('libinput') if 'auto' in backends and get_option('auto_features').enabled()
backends = all_backends
elif 'auto' in backends and get_option('auto_features').disabled()
backends = []
endif
foreach backend : all_backends
if backend in backends or 'auto' in backends
subdir(backend)
endif
endforeach
subdir('multi') subdir('multi')
subdir('noop')
subdir('wayland') subdir('wayland')
subdir('x11') subdir('noop')
subdir('headless')
subdir('session') subdir('session')

@ -10,17 +10,14 @@ x11_required = [
'xcb-xinput', 'xcb-xinput',
] ]
msg = [] msg = ['Required for X11 backend support.']
if get_option('x11-backend').enabled() if 'x11' in backends
msg += 'Install "@0@" or pass "-Dx11-backend=disabled" to disable it.' msg += 'Install "@0@" or disable the X11 backend.'
endif
if not get_option('x11-backend').disabled()
msg += 'Required for X11 backend support.'
endif endif
foreach lib : x11_required foreach lib : x11_required
dep = dependency(lib, dep = dependency(lib,
required: get_option('x11-backend'), required: 'x11' in backends,
not_found_message: '\n'.join(msg).format(lib), not_found_message: '\n'.join(msg).format(lib),
) )
if not dep.found() if not dep.found()

@ -1,6 +1,8 @@
#ifndef WLR_CONFIG_H #ifndef WLR_CONFIG_H
#define WLR_CONFIG_H #define WLR_CONFIG_H
#mesondefine WLR_HAS_DRM_BACKEND
#mesondefine WLR_HAS_LIBINPUT_BACKEND
#mesondefine WLR_HAS_X11_BACKEND #mesondefine WLR_HAS_X11_BACKEND
#mesondefine WLR_HAS_GLES2_RENDERER #mesondefine WLR_HAS_GLES2_RENDERER

@ -86,7 +86,9 @@ else
endif endif
features = { features = {
'drm-backend': false,
'x11-backend': false, 'x11-backend': false,
'libinput-backend': false,
'xwayland': false, 'xwayland': false,
'gles2-renderer': false, 'gles2-renderer': false,
} }
@ -98,7 +100,6 @@ wayland_server = dependency('wayland-server', version: '>=1.19')
wayland_client = dependency('wayland-client') wayland_client = dependency('wayland-client')
drm = dependency('libdrm', version: '>=2.4.105') drm = dependency('libdrm', version: '>=2.4.105')
gbm = dependency('gbm', version: '>=17.1.0') gbm = dependency('gbm', version: '>=17.1.0')
libinput = dependency('libinput', version: '>=1.14.0')
xkbcommon = dependency('xkbcommon') xkbcommon = dependency('xkbcommon')
udev = dependency('libudev') udev = dependency('libudev')
pixman = dependency('pixman-1') pixman = dependency('pixman-1')
@ -111,7 +112,6 @@ wlr_deps = [
wayland_client, wayland_client,
drm, drm,
gbm, gbm,
libinput,
xkbcommon, xkbcommon,
udev, udev,
pixman, pixman,

@ -1,6 +1,6 @@
option('xcb-errors', type: 'feature', value: 'auto', description: 'Use xcb-errors util library') option('xcb-errors', type: 'feature', value: 'auto', description: 'Use xcb-errors util library')
option('xwayland', type: 'feature', value: 'auto', yield: true, description: 'Enable support for X11 applications') option('xwayland', type: 'feature', value: 'auto', yield: true, description: 'Enable support for X11 applications')
option('x11-backend', type: 'feature', value: 'auto', description: 'Enable X11 backend')
option('examples', type: 'boolean', value: true, description: 'Build example applications') option('examples', type: 'boolean', value: true, description: 'Build example applications')
option('icon_directory', description: 'Location used to look for cursors (default: ${datadir}/icons)', type: 'string', value: '') option('icon_directory', description: 'Location used to look for cursors (default: ${datadir}/icons)', type: 'string', value: '')
option('renderers', type: 'array', choices: ['auto', 'gles2'], value: ['auto'], description: 'Select built-in renderers') option('renderers', type: 'array', choices: ['auto', 'gles2'], value: ['auto'], description: 'Select built-in renderers')
option('backends', type: 'array', choices: ['auto', 'drm', 'libinput', 'x11'], value: ['auto'], description: 'Select built-in backends')

Loading…
Cancel
Save