Skip to content

Commit 70fb21c

Browse files
hizukiayakaemersion
authored andcommitted
backend: make DRM and libinput backends optional
Co-authored-by: Simon Ser <[email protected]>
1 parent 66c42f4 commit 70fb21c

File tree

8 files changed

+69
-17
lines changed

8 files changed

+69
-17
lines changed

backend/backend.c

+23-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
#include <string.h>
77
#include <unistd.h>
88
#include <wayland-server-core.h>
9-
#include <wlr/backend/drm.h>
9+
1010
#include <wlr/backend/headless.h>
1111
#include <wlr/backend/interface.h>
12-
#include <wlr/backend/libinput.h>
1312
#include <wlr/backend/multi.h>
1413
#include <wlr/backend/noop.h>
1514
#include <wlr/backend/session.h>
@@ -22,6 +21,14 @@
2221
#include "render/allocator.h"
2322
#include "util/signal.h"
2423

24+
#if WLR_HAS_DRM_BACKEND
25+
#include <wlr/backend/drm.h>
26+
#endif
27+
28+
#if WLR_HAS_LIBINPUT_BACKEND
29+
#include <wlr/backend/libinput.h>
30+
#endif
31+
2532
#if WLR_HAS_X11_BACKEND
2633
#include <wlr/backend/x11.h>
2734
#endif
@@ -211,6 +218,7 @@ static struct wlr_backend *attempt_noop_backend(struct wl_display *display) {
211218
return backend;
212219
}
213220

221+
#if WLR_HAS_DRM_BACKEND
214222
static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
215223
struct wlr_backend *backend, struct wlr_session *session) {
216224
struct wlr_device *gpus[8];
@@ -240,6 +248,7 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
240248

241249
return primary_drm;
242250
}
251+
#endif
243252

244253
static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
245254
struct wlr_backend *backend, struct wlr_session **session,
@@ -265,9 +274,17 @@ static struct wlr_backend *attempt_backend_by_name(struct wl_display *display,
265274
}
266275

267276
if (strcmp(name, "libinput") == 0) {
277+
#if WLR_HAS_LIBINPUT_BACKEND
268278
return wlr_libinput_backend_create(display, *session);
279+
#else
280+
return NULL;
281+
#endif
269282
} else {
283+
#if WLR_HAS_DRM_BACKEND
270284
return attempt_drm_backend(display, backend, *session);
285+
#else
286+
return NULL;
287+
#endif
271288
}
272289
}
273290

@@ -355,6 +372,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
355372
return NULL;
356373
}
357374

375+
#if WLR_HAS_LIBINPUT_BACKEND
358376
struct wlr_backend *libinput = wlr_libinput_backend_create(display,
359377
multi->session);
360378
if (!libinput) {
@@ -364,7 +382,9 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
364382
return NULL;
365383
}
366384
wlr_multi_backend_add(backend, libinput);
385+
#endif
367386

387+
#if WLR_HAS_DRM_BACKEND
368388
struct wlr_backend *primary_drm =
369389
attempt_drm_backend(display, backend, multi->session);
370390
if (!primary_drm) {
@@ -376,6 +396,7 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) {
376396
}
377397

378398
return backend;
399+
#endif
379400

380401
error:
381402
wlr_backend_destroy(backend);

backend/drm/meson.build

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ wlr_files += files(
88
'renderer.c',
99
'util.c',
1010
)
11+
12+
features += { 'drm-backend': true }

backend/libinput/meson.build

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
msg = ['Required for libinput backend support.']
2+
if 'libinput' in backends
3+
msg += 'Install "libinput" or disable the libinput backend.'
4+
endif
5+
6+
libinput = dependency(
7+
'libinput',
8+
version: '>=1.14.0',
9+
required: 'libinput' in backends,
10+
not_found_message: '\n'.join(msg),
11+
)
12+
13+
if not libinput.found()
14+
subdir_done()
15+
endif
16+
117
wlr_files += files(
218
'backend.c',
319
'events.c',
@@ -8,3 +24,6 @@ wlr_files += files(
824
'tablet_tool.c',
925
'touch.c',
1026
)
27+
28+
features += { 'libinput-backend': true }
29+
wlr_deps += libinput

backend/meson.build

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
wlr_files += files('backend.c')
22

3-
subdir('drm')
4-
subdir('headless')
5-
subdir('libinput')
3+
all_backends = ['drm', 'libinput', 'x11']
4+
backends = get_option('backends')
5+
if 'auto' in backends and get_option('auto_features').enabled()
6+
backends = all_backends
7+
elif 'auto' in backends and get_option('auto_features').disabled()
8+
backends = []
9+
endif
10+
11+
foreach backend : all_backends
12+
if backend in backends or 'auto' in backends
13+
subdir(backend)
14+
endif
15+
endforeach
16+
617
subdir('multi')
7-
subdir('noop')
818
subdir('wayland')
9-
subdir('x11')
19+
subdir('noop')
20+
subdir('headless')
1021

1122
subdir('session')

backend/x11/meson.build

+4-7
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@ x11_required = [
1010
'xcb-xinput',
1111
]
1212

13-
msg = []
14-
if get_option('x11-backend').enabled()
15-
msg += 'Install "@0@" or pass "-Dx11-backend=disabled" to disable it.'
16-
endif
17-
if not get_option('x11-backend').disabled()
18-
msg += 'Required for X11 backend support.'
13+
msg = ['Required for X11 backend support.']
14+
if 'x11' in backends
15+
msg += 'Install "@0@" or disable the X11 backend.'
1916
endif
2017

2118
foreach lib : x11_required
2219
dep = dependency(lib,
23-
required: get_option('x11-backend'),
20+
required: 'x11' in backends,
2421
not_found_message: '\n'.join(msg).format(lib),
2522
)
2623
if not dep.found()

include/wlr/config.h.in

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef WLR_CONFIG_H
22
#define WLR_CONFIG_H
33

4+
#mesondefine WLR_HAS_DRM_BACKEND
5+
#mesondefine WLR_HAS_LIBINPUT_BACKEND
46
#mesondefine WLR_HAS_X11_BACKEND
57

68
#mesondefine WLR_HAS_GLES2_RENDERER

meson.build

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ else
8686
endif
8787

8888
features = {
89+
'drm-backend': false,
8990
'x11-backend': false,
91+
'libinput-backend': false,
9092
'xwayland': false,
9193
'gles2-renderer': false,
9294
}
@@ -98,7 +100,6 @@ wayland_server = dependency('wayland-server', version: '>=1.19')
98100
wayland_client = dependency('wayland-client')
99101
drm = dependency('libdrm', version: '>=2.4.105')
100102
gbm = dependency('gbm', version: '>=17.1.0')
101-
libinput = dependency('libinput', version: '>=1.14.0')
102103
xkbcommon = dependency('xkbcommon')
103104
udev = dependency('libudev')
104105
pixman = dependency('pixman-1')
@@ -111,7 +112,6 @@ wlr_deps = [
111112
wayland_client,
112113
drm,
113114
gbm,
114-
libinput,
115115
xkbcommon,
116116
udev,
117117
pixman,

meson_options.txt

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

0 commit comments

Comments
 (0)