From cff1c2f740a2f7d22339a0fae14c4923223a8d61 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 22 Nov 2019 20:11:15 +1300 Subject: [PATCH] meson: Various improvements Bumps minimum version to 0.51.0 - Remove all intermediate static libraries. They serve no purpose and are just add a bunch of boilerplate for managing dependencies and options. It's now managed as a list of files which are compiled into libwlroots directly. - Use install_subdir instead of installing headers individually. I've changed my mind since I did that. Listing them out is annoying as hell, and it's easy to forget to do it. - Add not_found_message for all of our optional dependencies that have a meson option. It gives some hints about what option to pass and what the optional dependency is for. - Move all backend subdirectories into their own meson.build. This keeps some of the backend-specific build logic (especially rdp and session) more neatly separated off. - Don't overlink example clients with code they're not using. This was done by merging the protocol dictionaries and setting some variables containing the code and client header file. Example clients now explicitly mention what extension protocols they want to link to. - Split compositor example logic from client example logic. - Minor formatting changes --- backend/drm/meson.build | 10 ++ backend/headless/meson.build | 5 + backend/libinput/meson.build | 10 ++ backend/meson.build | 88 ++------------ backend/multi/meson.build | 1 + backend/noop/meson.build | 4 + backend/rdp/meson.build | 36 ++++++ backend/session/meson.build | 53 +++++++++ backend/wayland/meson.build | 20 ++++ backend/x11/meson.build | 34 +++--- examples/meson.build | 108 ++++++++++++----- include/meson.build | 13 +++ include/wlr/backend/meson.build | 17 --- include/wlr/backend/session/meson.build | 1 - include/wlr/interfaces/meson.build | 11 -- include/wlr/meson.build | 24 ++-- include/wlr/render/meson.build | 10 -- include/wlr/types/meson.build | 53 --------- include/wlr/util/meson.build | 6 - meson.build | 102 ++++++---------- protocol/meson.build | 131 ++++++++------------- render/meson.build | 35 ++---- types/meson.build | 147 +++++++++++------------- util/meson.build | 17 +-- xcursor/meson.build | 11 +- xwayland/meson.build | 65 ++++++----- 26 files changed, 479 insertions(+), 533 deletions(-) create mode 100644 backend/drm/meson.build create mode 100644 backend/headless/meson.build create mode 100644 backend/libinput/meson.build create mode 100644 backend/multi/meson.build create mode 100644 backend/noop/meson.build create mode 100644 backend/rdp/meson.build create mode 100644 backend/session/meson.build create mode 100644 backend/wayland/meson.build delete mode 100644 include/wlr/backend/meson.build delete mode 100644 include/wlr/backend/session/meson.build delete mode 100644 include/wlr/interfaces/meson.build delete mode 100644 include/wlr/render/meson.build delete mode 100644 include/wlr/types/meson.build delete mode 100644 include/wlr/util/meson.build diff --git a/backend/drm/meson.build b/backend/drm/meson.build new file mode 100644 index 000000000..ffddfdfc7 --- /dev/null +++ b/backend/drm/meson.build @@ -0,0 +1,10 @@ +wlr_files += files( + 'atomic.c', + 'backend.c', + 'cvt.c', + 'drm.c', + 'legacy.c', + 'properties.c', + 'renderer.c', + 'util.c', +) diff --git a/backend/headless/meson.build b/backend/headless/meson.build new file mode 100644 index 000000000..e38ce1333 --- /dev/null +++ b/backend/headless/meson.build @@ -0,0 +1,5 @@ +wlr_files += files( + 'backend.c', + 'input_device.c', + 'output.c', +) diff --git a/backend/libinput/meson.build b/backend/libinput/meson.build new file mode 100644 index 000000000..ff78d2f84 --- /dev/null +++ b/backend/libinput/meson.build @@ -0,0 +1,10 @@ +wlr_files += files( + 'backend.c', + 'events.c', + 'keyboard.c', + 'pointer.c', + 'switch.c', + 'tablet_pad.c', + 'tablet_tool.c', + 'touch.c', +) diff --git a/backend/meson.build b/backend/meson.build index e4a484f44..373102b6d 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -1,82 +1,12 @@ -backend_parts = [] -backend_files = files( - 'backend.c', - 'drm/atomic.c', - 'drm/backend.c', - 'drm/cvt.c', - 'drm/drm.c', - 'drm/legacy.c', - 'drm/properties.c', - 'drm/renderer.c', - 'drm/util.c', - 'headless/backend.c', - 'headless/input_device.c', - 'headless/output.c', - 'libinput/backend.c', - 'libinput/events.c', - 'libinput/keyboard.c', - 'libinput/pointer.c', - 'libinput/switch.c', - 'libinput/tablet_pad.c', - 'libinput/tablet_tool.c', - 'libinput/touch.c', - 'multi/backend.c', - 'noop/backend.c', - 'noop/output.c', - 'session/direct-ipc.c', - 'session/noop.c', - 'session/session.c', - 'wayland/backend.c', - 'wayland/output.c', - 'wayland/wl_seat.c', - 'wayland/tablet_v2.c', -) - -backend_deps = [ - drm, - egl, - gbm, - libinput, - pixman, - xkbcommon, - wayland_server, - wlr_protos, - wlr_render, -] - -if host_machine.system().startswith('freebsd') - backend_files += files('session/direct-freebsd.c') -else - backend_files += files('session/direct.c') -endif - -if logind.found() - backend_files += files('session/logind.c') - backend_deps += logind -endif - -if freerdp.found() and winpr2.found() - backend_files += files( - 'rdp/backend.c', - 'rdp/keyboard.c', - 'rdp/listener.c', - 'rdp/output.c', - 'rdp/peer.c', - 'rdp/pointer.c', - ) - backend_deps += [ - freerdp, - winpr2 - ] - conf_data.set10('WLR_HAS_RDP_BACKEND', true) -endif +wlr_files += files('backend.c') +subdir('drm') +subdir('headless') +subdir('libinput') +subdir('multi') +subdir('noop') +subdir('rdp') +subdir('wayland') subdir('x11') -lib_wlr_backend = static_library( - 'wlr_backend', - backend_files, - include_directories: wlr_inc, - link_whole: backend_parts, - dependencies: backend_deps, -) +subdir('session') diff --git a/backend/multi/meson.build b/backend/multi/meson.build new file mode 100644 index 000000000..be4abfb64 --- /dev/null +++ b/backend/multi/meson.build @@ -0,0 +1 @@ +wlr_files += files('backend.c') diff --git a/backend/noop/meson.build b/backend/noop/meson.build new file mode 100644 index 000000000..950c07160 --- /dev/null +++ b/backend/noop/meson.build @@ -0,0 +1,4 @@ +wlr_files += files( + 'backend.c', + 'output.c', +) diff --git a/backend/rdp/meson.build b/backend/rdp/meson.build new file mode 100644 index 000000000..40259c652 --- /dev/null +++ b/backend/rdp/meson.build @@ -0,0 +1,36 @@ +rdp_libs = [] +rdp_required = [ + 'freerdp2', + 'winpr2', +] + +msg = [] +if get_option('freerdp').enabled() + msg += 'Install "@0@" or pass "-Dfreerdp=disabled".' +endif +if not get_option('freerdp').disabled() + msg += 'Required for RDP backend support.' +endif + +foreach lib : rdp_required + dep = dependency(lib, + required: get_option('freerdp'), + not_found_message: '\n'.join(msg).format(lib), + ) + if not dep.found() + subdir_done() + endif + + rdp_libs += dep +endforeach + +wlr_files += files( + 'backend.c', + 'keyboard.c', + 'listener.c', + 'output.c', + 'peer.c', + 'pointer.c', +) +wlr_deps += rdp_libs +conf_data.set10('WLR_HAS_RDP_BACKEND', true) diff --git a/backend/session/meson.build b/backend/session/meson.build new file mode 100644 index 000000000..2c3f09c76 --- /dev/null +++ b/backend/session/meson.build @@ -0,0 +1,53 @@ +wlr_files += files( + 'direct-ipc.c', + 'noop.c', + 'session.c', +) + +if host_machine.system().startswith('freebsd') + wlr_files += files('direct-freebsd.c') +else + wlr_files += files('direct.c') +endif + +# logind + +msg = [] +if get_option('logind').enabled() + msg += 'Install "lib@0@" or pass "-Dlogind=disabled".' +endif +if not get_option('logind').disabled() + msg += 'Required for logind support.' + msg += 'You may need to pass "-Dlogind-provider=elogind" or "-Dlogind-provider=systemd" to ensure the correct library is detected.' +endif + +logind = dependency('lib' + get_option('logind-provider'), + required: get_option('logind'), + not_found_message: '\n'.join(msg).format(get_option('logind-provider')), + version: '>=237', +) +if logind.found() + wlr_files += files('logind.c') + wlr_deps += logind + conf_data.set10('WLR_HAS_' + get_option('logind-provider').to_upper(), true) +endif + +# libcap + +msg = [] +if get_option('libcap').enabled() + msg += 'Install "libcap" or pass "-Dlibcap=disabled".' +endif +if not get_option('libcap').disabled() + msg += 'Required for POSIX capability support (Not needed if using logind).' +endif + +libcap = dependency('libcap', + required: get_option('libcap'), + not_found_message: '\n'.join(msg), +) +if libcap.found() + conf_data.set10('WLR_HAS_LIBCAP', true) + wlr_deps += libcap +endif + diff --git a/backend/wayland/meson.build b/backend/wayland/meson.build new file mode 100644 index 000000000..73336d203 --- /dev/null +++ b/backend/wayland/meson.build @@ -0,0 +1,20 @@ +wlr_files += files( + 'backend.c', + 'output.c', + 'wl_seat.c', + 'tablet_v2.c', +) + +client_protos = [ + 'linux-dmabuf-unstable-v1', + 'pointer-gestures-unstable-v1', + 'presentation-time', + 'relative-pointer-unstable-v1', + 'tablet-unstable-v2', + 'xdg-decoration-unstable-v1', + 'xdg-shell', +] + +foreach proto : client_protos + wlr_files += get_variable(proto.underscorify() + '_h') +endforeach diff --git a/backend/x11/meson.build b/backend/x11/meson.build index 19e873abd..40530bb0f 100644 --- a/backend/x11/meson.build +++ b/backend/x11/meson.build @@ -6,8 +6,19 @@ x11_required = [ 'xcb-xfixes', ] +msg = [] +if get_option('x11-backend').enabled() + msg += 'Install "@0@" or pass "-Dx11-backend=disabled" to disable it.' +endif +if not get_option('x11-backend').disabled() + msg += 'Required for X11 backend support.' +endif + foreach lib : x11_required - dep = dependency(lib, required: get_option('x11-backend')) + dep = dependency(lib, + required: get_option('x11-backend'), + not_found_message: '\n'.join(msg).format(lib), + ) if not dep.found() subdir_done() endif @@ -15,21 +26,10 @@ foreach lib : x11_required x11_libs += dep endforeach -lib_wlr_backend_x11 = static_library( - 'wlr_backend_x11', - files( - 'backend.c', - 'input_device.c', - 'output.c', - ), - include_directories: wlr_inc, - dependencies: [ - wayland_server, - pixman, - xkbcommon, - x11_libs, - ], +wlr_files += files( + 'backend.c', + 'input_device.c', + 'output.c', ) - -backend_parts += lib_wlr_backend_x11 +wlr_deps += x11_libs conf_data.set10('WLR_HAS_X11_BACKEND', true) diff --git a/examples/meson.build b/examples/meson.build index 4a6d1634b..cfc4df866 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -8,9 +8,9 @@ libavformat = dependency('libavformat', version: '>=58.12.100', required: false, # epoll is a separate library in FreeBSD if host_machine.system() == 'freebsd' - libepoll = [dependency('epoll-shim')] + libepoll = dependency('epoll-shim') else - libepoll = [] + libepoll = dependency('', required: false) endif # Check if libavutil is found because of https://github.com/mesonbuild/meson/issues/6010 @@ -18,62 +18,84 @@ if libavutil.found() and not cc.has_header('libavutil/hwcontext_drm.h', dependen libavutil = disabler() endif -examples = { +compositors = { 'simple': { 'src': 'simple.c', - 'dep': [wlroots], }, 'pointer': { 'src': 'pointer.c', - 'dep': [wlroots], }, 'touch': { 'src': ['touch.c', 'cat.c'], - 'dep': [wlroots], }, 'tablet': { 'src': 'tablet.c', - 'dep': [wlroots], }, 'rotation': { 'src': ['rotation.c', 'cat.c'], - 'dep': [wlroots], }, 'multi-pointer': { 'src': 'multi-pointer.c', - 'dep': [wlroots], }, 'output-layout': { 'src': ['output-layout.c', 'cat.c'], - 'dep': [wlroots], }, + 'fullscreen-shell': { + 'src': 'fullscreen-shell.c', + }, +} + +clients = { 'idle': { 'src': 'idle.c', - 'dep': [wayland_client, wlr_protos, threads], + 'dep': threads, + 'proto': ['kde-idle'], }, 'idle-inhibit': { 'src': 'idle-inhibit.c', - 'dep': [wayland_client, wlr_protos, wlroots], + 'dep': wlroots, + 'proto': [ + 'idle-inhibit-unstable-v1', + 'xdg-shell', + ], }, 'layer-shell': { 'src': 'layer-shell.c', - 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots], + 'dep': [wayland_cursor, wlroots], + 'proto': [ + 'wlr-layer-shell-unstable-v1', + 'xdg-shell', + ], }, 'input-inhibitor': { 'src': 'input-inhibitor.c', - 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots], + 'dep': [wayland_cursor, wlroots], + 'proto': [ + 'wlr-input-inhibitor-unstable-v1', + 'xdg-shell', + ], }, 'gamma-control': { 'src': 'gamma-control.c', - 'dep': [wayland_client, wayland_cursor, wlr_protos, math], + 'dep': [wayland_cursor, math], + 'proto': ['wlr-gamma-control-unstable-v1'], }, 'pointer-constraints': { 'src': 'pointer-constraints.c', - 'dep': [wayland_client, wlr_protos, wlroots], + 'dep': wlroots, + 'proto': [ + 'pointer-constraints-unstable-v1', + 'xdg-shell', + ], }, 'relative-pointer': { 'src': 'relative-pointer-unstable-v1.c', - 'dep': [wayland_client, wlr_protos, wlroots], + 'dep': wlroots, + 'proto': [ + 'pointer-constraints-unstable-v1', + 'relative-pointer-unstable-v1', + 'xdg-shell', + ], }, 'dmabuf-capture': { 'src': 'dmabuf-capture.c', @@ -83,41 +105,67 @@ examples = { libavutil, drm.partial_dependency(compile_args: true), # threads, - wayland_client, - wlr_protos, ], + 'proto': ['wlr-export-dmabuf-unstable-v1'], }, 'screencopy': { 'src': 'screencopy.c', - 'dep': [libpng, wayland_client, wlr_protos, rt], + 'dep': [libpng, rt], + 'proto': ['wlr-screencopy-unstable-v1'], }, 'toplevel-decoration': { 'src': 'toplevel-decoration.c', - 'dep': [wayland_client, wlr_protos, wlroots], + 'dep': wlroots, + 'proto': [ + 'xdg-decoration-unstable-v1', + 'xdg-shell', + ], }, 'input-method': { 'src': 'input-method.c', - 'dep': [wayland_client, wlr_protos] + libepoll, + 'dep': libepoll, + 'proto': [ + 'input-method-unstable-v2', + 'text-input-unstable-v3', + 'xdg-shell', + ], }, 'text-input': { 'src': 'text-input.c', - 'dep': [wayland_cursor, wayland_client, wlr_protos, wlroots], + 'dep': [wayland_cursor, wlroots], + 'proto': [ + 'text-input-unstable-v3', + 'xdg-shell', + ], }, 'foreign-toplevel': { 'src': 'foreign-toplevel.c', - 'dep': [wayland_client, wlr_protos, wlroots], - }, - 'fullscreen-shell': { - 'src': 'fullscreen-shell.c', - 'dep': [wlr_protos, wlroots], + 'dep': [wlroots], + 'proto': ['wlr-foreign-toplevel-management-unstable-v1'], }, } -foreach name, info : examples +foreach name, info : compositors executable( name, info.get('src'), - dependencies: info.get('dep'), + dependencies: wlroots, + include_directories: [wlr_inc, proto_inc], + build_by_default: get_option('examples'), + ) +endforeach + +foreach name, info : clients + extra_src = [] + foreach p : info.get('proto') + extra_src += get_variable(p.underscorify() + '_c') + extra_src += get_variable(p.underscorify() + '_h') + endforeach + + executable( + name, + [info.get('src'), extra_src], + dependencies: [wayland_client, info.get('dep')], build_by_default: get_option('examples'), ) endforeach diff --git a/include/meson.build b/include/meson.build index d16d6ef46..e2428e8d9 100644 --- a/include/meson.build +++ b/include/meson.build @@ -1 +1,14 @@ subdir('wlr') + +exclude_files = ['meson.build', 'config.h.in', 'version.h.in'] +if conf_data.get('WLR_HAS_X11_BACKEND', 0) != 1 + exclude_files += 'backend/x11.h' +endif +if conf_data.get('WLR_HAS_XWAYLAND', 0) != 1 + exclude_files += 'xwayland.h' +endif + +install_subdir('wlr', + install_dir: get_option('includedir'), + exclude_files: exclude_files, +) diff --git a/include/wlr/backend/meson.build b/include/wlr/backend/meson.build deleted file mode 100644 index 47de62d27..000000000 --- a/include/wlr/backend/meson.build +++ /dev/null @@ -1,17 +0,0 @@ -install_headers( - 'drm.h', - 'headless.h', - 'interface.h', - 'libinput.h', - 'multi.h', - 'noop.h', - 'session.h', - 'wayland.h', - subdir: 'wlr/backend', -) - -if conf_data.get('WLR_HAS_X11_BACKEND', 0) == 1 - install_headers('x11.h', subdir: 'wlr/backend') -endif - -subdir('session') diff --git a/include/wlr/backend/session/meson.build b/include/wlr/backend/session/meson.build deleted file mode 100644 index 21b5a96b5..000000000 --- a/include/wlr/backend/session/meson.build +++ /dev/null @@ -1 +0,0 @@ -install_headers('interface.h', subdir: 'wlr/backend/session') diff --git a/include/wlr/interfaces/meson.build b/include/wlr/interfaces/meson.build deleted file mode 100644 index 7d4d811d3..000000000 --- a/include/wlr/interfaces/meson.build +++ /dev/null @@ -1,11 +0,0 @@ -install_headers( - 'wlr_input_device.h', - 'wlr_keyboard.h', - 'wlr_output.h', - 'wlr_pointer.h', - 'wlr_switch.h', - 'wlr_tablet_pad.h', - 'wlr_tablet_tool.h', - 'wlr_touch.h', - subdir: 'wlr/interfaces', -) diff --git a/include/wlr/meson.build b/include/wlr/meson.build index 8874dbc7d..032c08d2f 100644 --- a/include/wlr/meson.build +++ b/include/wlr/meson.build @@ -8,19 +8,15 @@ version_data.set('WLR_VERSION_API_CURRENT', so_version[0]) version_data.set('WLR_VERSION_API_REVISION', so_version[1]) version_data.set('WLR_VERSION_API_AGE', so_version[2]) -install_headers( - configure_file(input: 'config.h.in', output: 'config.h',configuration: conf_data), - configure_file(input: 'version.h.in', output: 'version.h', configuration: version_data), - 'backend.h', - 'xcursor.h', - subdir: 'wlr' +conf_h = configure_file( + input: 'config.h.in', + output: 'config.h', + configuration: conf_data, +) +ver_h = configure_file( + input: 'version.h.in', + output: 'version.h', + configuration: version_data, ) -if conf_data.get('WLR_HAS_XWAYLAND', 0) == 1 - install_headers('xwayland.h', subdir: 'wlr') -endif -subdir('backend') -subdir('interfaces') -subdir('render') -subdir('types') -subdir('util') +install_headers(conf_h, ver_h, subdir: 'wlr') diff --git a/include/wlr/render/meson.build b/include/wlr/render/meson.build deleted file mode 100644 index 06ebcc371..000000000 --- a/include/wlr/render/meson.build +++ /dev/null @@ -1,10 +0,0 @@ -install_headers( - 'dmabuf.h', - 'egl.h', - 'drm_format_set.h', - 'gles2.h', - 'interface.h', - 'wlr_renderer.h', - 'wlr_texture.h', - subdir: 'wlr/render', -) diff --git a/include/wlr/types/meson.build b/include/wlr/types/meson.build deleted file mode 100644 index aee5c6d90..000000000 --- a/include/wlr/types/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -install_headers( - 'wlr_box.h', - 'wlr_buffer.h', - 'wlr_compositor.h', - 'wlr_cursor.h', - 'wlr_data_control_v1.h', - 'wlr_data_device.h', - 'wlr_export_dmabuf_v1.h', - 'wlr_foreign_toplevel_management_v1.h', - 'wlr_fullscreen_shell_v1.h', - 'wlr_gamma_control_v1.h', - 'wlr_gtk_primary_selection.h', - 'wlr_idle_inhibit_v1.h', - 'wlr_idle.h', - 'wlr_input_device.h', - 'wlr_input_inhibitor.h', - 'wlr_input_method_v2.h', - 'wlr_keyboard.h', - 'wlr_keyboard_group.h', - 'wlr_layer_shell_v1.h', - 'wlr_linux_dmabuf_v1.h', - 'wlr_list.h', - 'wlr_matrix.h', - 'wlr_output_damage.h', - 'wlr_output_layout.h', - 'wlr_output_management_v1.h', - 'wlr_output.h', - 'wlr_pointer_constraints_v1.h', - 'wlr_pointer_gestures_v1.h', - 'wlr_pointer.h', - 'wlr_presentation_time.h', - 'wlr_primary_selection_v1.h', - 'wlr_primary_selection.h', - 'wlr_region.h', - 'wlr_relative_pointer_v1.h', - 'wlr_screencopy_v1.h', - 'wlr_seat.h', - 'wlr_server_decoration.h', - 'wlr_surface.h', - 'wlr_switch.h', - 'wlr_tablet_pad.h', - 'wlr_tablet_tool.h', - 'wlr_tablet_v2.h', - 'wlr_text_input_v3.h', - 'wlr_touch.h', - 'wlr_virtual_keyboard_v1.h', - 'wlr_xcursor_manager.h', - 'wlr_xdg_decoration_v1.h', - 'wlr_xdg_output_v1.h', - 'wlr_xdg_shell_v6.h', - 'wlr_xdg_shell.h', - subdir: 'wlr/types', -) diff --git a/include/wlr/util/meson.build b/include/wlr/util/meson.build deleted file mode 100644 index ee72cbd64..000000000 --- a/include/wlr/util/meson.build +++ /dev/null @@ -1,6 +0,0 @@ -install_headers( - 'edges.h', - 'log.h', - 'region.h', - subdir: 'wlr/util', -) diff --git a/meson.build b/meson.build index 18528df26..87af465ec 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( 'c', version: '0.8.1', license: 'MIT', - meson_version: '>=0.49.0', + meson_version: '>=0.51.0', default_options: [ 'c_std=c11', 'warning_level=2', @@ -88,8 +88,6 @@ conf_data.set10('WLR_HAS_XWAYLAND', false) conf_data.set10('WLR_HAS_XCB_ERRORS', false) conf_data.set10('WLR_HAS_XCB_ICCCM', false) -wlr_inc = include_directories('.', 'include') - # Clang complains about some zeroed initializer lists (= {0}), even though they # are valid if cc.get_id() == 'clang' @@ -99,66 +97,21 @@ endif wayland_server = dependency('wayland-server', version: '>=1.16') wayland_client = dependency('wayland-client') -wayland_egl = dependency('wayland-egl') +wayland_egl = dependency('wayland-egl') wayland_protos = dependency('wayland-protocols', version: '>=1.17') -egl = dependency('egl') -freerdp = dependency('freerdp2', required: get_option('freerdp')) -winpr2 = dependency('winpr2', required: get_option('freerdp')) -glesv2 = dependency('glesv2') -drm = dependency('libdrm', version: '>=2.4.95') -gbm = dependency('gbm', version: '>=17.1.0') -libinput = dependency('libinput', version: '>=1.9.0') -xkbcommon = dependency('xkbcommon') -udev = dependency('libudev') -pixman = dependency('pixman-1') -libcap = dependency('libcap', required: get_option('libcap')) -logind = dependency('lib' + get_option('logind-provider'), required: get_option('logind'), version: '>=237') -math = cc.find_library('m') -rt = cc.find_library('rt') +egl = dependency('egl') +glesv2 = dependency('glesv2') +drm = dependency('libdrm', version: '>=2.4.95') +gbm = dependency('gbm', version: '>=17.1.0') +libinput = dependency('libinput', version: '>=1.9.0') +xkbcommon = dependency('xkbcommon') +udev = dependency('libudev') +pixman = dependency('pixman-1') +math = cc.find_library('m') +rt = cc.find_library('rt') -wlr_parts = [] -wlr_deps = [] - -if libcap.found() - conf_data.set10('WLR_HAS_LIBCAP', true) - wlr_deps += libcap -endif - -if logind.found() - conf_data.set10('WLR_HAS_' + get_option('logind-provider').to_upper(), true) - wlr_deps += logind -endif - -if libinput.found() - ver = libinput.version().split('.') - add_project_arguments([ - '-DLIBINPUT_MAJOR=' + ver[0], - '-DLIBINPUT_MINOR=' + ver[1], - '-DLIBINPUT_PATCH=' + ver[2], - ], language: 'c') -endif - -subdir('protocol') -subdir('render') - -subdir('backend') -subdir('types') -subdir('util') -subdir('xcursor') -subdir('xwayland') - -subdir('include') - -wlr_parts += [ - lib_wl_protos, - lib_wlr_backend, - lib_wlr_render, - lib_wlr_types, - lib_wlr_util, - lib_wlr_xcursor, -] - -wlr_deps += [ +wlr_files = [] +wlr_deps = [ wayland_server, wayland_client, wayland_egl, @@ -172,16 +125,37 @@ wlr_deps += [ udev, pixman, math, + rt, ] +libinput_ver = libinput.version().split('.') +add_project_arguments([ + '-DLIBINPUT_MAJOR=' + libinput_ver[0], + '-DLIBINPUT_MINOR=' + libinput_ver[1], + '-DLIBINPUT_PATCH=' + libinput_ver[2], +], language: 'c') + +subdir('protocol') +subdir('render') + +subdir('backend') +subdir('types') +subdir('util') +subdir('xcursor') +subdir('xwayland') + +subdir('include') + +wlr_inc = include_directories('.', 'include') +proto_inc = include_directories('protocol') + symbols_file = 'wlroots.syms' symbols_flag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), symbols_file) lib_wlr = library( - meson.project_name(), + meson.project_name(), wlr_files, version: '.'.join(so_version), - link_whole: wlr_parts, dependencies: wlr_deps, - include_directories: wlr_inc, + include_directories: [wlr_inc, proto_inc], install: true, link_args : symbols_flag, link_depends: symbols_file, diff --git a/protocol/meson.build b/protocol/meson.build index ed5491c85..c39be751d 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -1,103 +1,72 @@ -wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir') +wl_protocol_dir = wayland_protos.get_variable(pkgconfig: 'pkgdatadir') wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true) if wayland_scanner_dep.found() wayland_scanner = find_program( - wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner'), + wayland_scanner_dep.get_variable(pkgconfig: 'wayland_scanner'), native: true, ) else wayland_scanner = find_program('wayland-scanner', native: true) endif -protocols = [ - [wl_protocol_dir, 'stable/presentation-time/presentation-time.xml'], - [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], - [wl_protocol_dir, 'unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/primary-selection/primary-selection-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/relative-pointer/relative-pointer-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/tablet/tablet-unstable-v2.xml'], - [wl_protocol_dir, 'unstable/text-input/text-input-unstable-v3.xml'], - [wl_protocol_dir, 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'], - 'gtk-primary-selection.xml', - 'idle.xml', - 'input-method-unstable-v2.xml', - 'server-decoration.xml', - 'virtual-keyboard-unstable-v1.xml', - 'wlr-data-control-unstable-v1.xml', - 'wlr-export-dmabuf-unstable-v1.xml', - 'wlr-foreign-toplevel-management-unstable-v1.xml', - 'wlr-gamma-control-unstable-v1.xml', - 'wlr-input-inhibitor-unstable-v1.xml', - 'wlr-layer-shell-unstable-v1.xml', - 'wlr-output-management-unstable-v1.xml', - 'wlr-screencopy-unstable-v1.xml', -] +protocols = { + # Stable upstream protocols + 'xdg-shell': wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml', + 'presentation-time': wl_protocol_dir / 'stable/presentation-time/presentation-time.xml', + # Unstable upstream protocols + 'fullscreen-shell-unstable-v1': wl_protocol_dir / 'unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml', + 'idle-inhibit-unstable-v1': wl_protocol_dir / 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml', + 'linux-dmabuf-unstable-v1': wl_protocol_dir / 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml', + 'pointer-constraints-unstable-v1': wl_protocol_dir / 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml', + 'pointer-gestures-unstable-v1': wl_protocol_dir / 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml', + 'primary-selection-unstable-v1': wl_protocol_dir / 'unstable/primary-selection/primary-selection-unstable-v1.xml', + 'relative-pointer-unstable-v1': wl_protocol_dir / 'unstable/relative-pointer/relative-pointer-unstable-v1.xml', + 'tablet-unstable-v2': wl_protocol_dir / 'unstable/tablet/tablet-unstable-v2.xml', + 'text-input-unstable-v3': wl_protocol_dir / 'unstable/text-input/text-input-unstable-v3.xml', + 'xdg-decoration-unstable-v1': wl_protocol_dir / 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml', + 'xdg-output-unstable-v1': wl_protocol_dir / 'unstable/xdg-output/xdg-output-unstable-v1.xml', + 'xdg-shell-unstable-v6': wl_protocol_dir / 'unstable/xdg-shell/xdg-shell-unstable-v6.xml', + # Other protocols + 'gtk-primary-selection': 'gtk-primary-selection.xml', + 'kde-idle': 'idle.xml', + 'kde-server-decoration': 'server-decoration.xml', + 'input-method-unstable-v2': 'input-method-unstable-v2.xml', + 'virtual-keyboard-unstable-v1': 'virtual-keyboard-unstable-v1.xml', + 'wlr-data-control-unstable-v1': 'wlr-data-control-unstable-v1.xml', + 'wlr-export-dmabuf-unstable-v1': 'wlr-export-dmabuf-unstable-v1.xml', + 'wlr-foreign-toplevel-management-unstable-v1': 'wlr-foreign-toplevel-management-unstable-v1.xml', + 'wlr-gamma-control-unstable-v1': 'wlr-gamma-control-unstable-v1.xml', + 'wlr-input-inhibitor-unstable-v1': 'wlr-input-inhibitor-unstable-v1.xml', + 'wlr-layer-shell-unstable-v1': 'wlr-layer-shell-unstable-v1.xml', + 'wlr-output-management-unstable-v1': 'wlr-output-management-unstable-v1.xml', + 'wlr-screencopy-unstable-v1': 'wlr-screencopy-unstable-v1.xml', +} -client_protocols = [ - [wl_protocol_dir, 'stable/presentation-time/presentation-time.xml'], - [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], - [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/relative-pointer/relative-pointer-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/tablet/tablet-unstable-v2.xml'], - [wl_protocol_dir, 'unstable/text-input/text-input-unstable-v3.xml'], - [wl_protocol_dir, 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml'], - [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'], - 'idle.xml', - 'input-method-unstable-v2.xml', - 'wlr-export-dmabuf-unstable-v1.xml', - 'wlr-foreign-toplevel-management-unstable-v1.xml', - 'wlr-gamma-control-unstable-v1.xml', - 'wlr-input-inhibitor-unstable-v1.xml', - 'wlr-layer-shell-unstable-v1.xml', - 'wlr-screencopy-unstable-v1.xml', -] - -wl_protos_src = [] -wl_protos_headers = [] - -foreach p : protocols - xml = join_paths(p) - wl_protos_src += custom_target( - xml.underscorify() + '_server_c', - input: xml, +foreach name, path : protocols + code = custom_target( + name.underscorify() + '_c', + input: path, output: '@BASENAME@-protocol.c', command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'], ) - wl_protos_headers += custom_target( - xml.underscorify() + '_server_h', - input: xml, + wlr_files += code + + wlr_files += custom_target( + name.underscorify() + '_server_h', + input: path, output: '@BASENAME@-protocol.h', command: [wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@'], ) -endforeach -foreach p : client_protocols - xml = join_paths(p) - wl_protos_headers += custom_target( - xml.underscorify() + '_client_h', - input: xml, + header = custom_target( + name.underscorify() + '_client_h', + input: path, output: '@BASENAME@-client-protocol.h', command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'], + build_by_default: false, ) + + set_variable(name.underscorify() + '_c', code) + set_variable(name.underscorify() + '_h', header) endforeach - -lib_wl_protos = static_library( - 'wl_protos', - wl_protos_src + wl_protos_headers, - dependencies: wayland_client.partial_dependency(compile_args: true), -) - -wlr_protos = declare_dependency( - link_with: lib_wl_protos, - sources: wl_protos_headers, -) diff --git a/render/meson.build b/render/meson.build index 79daba93b..9486c22de 100644 --- a/render/meson.build +++ b/render/meson.build @@ -1,26 +1,11 @@ -lib_wlr_render = static_library( - 'wlr_render', - files( - 'dmabuf.c', - 'egl.c', - 'drm_format_set.c', - 'gles2/pixel_format.c', - 'gles2/renderer.c', - 'gles2/shaders.c', - 'gles2/texture.c', - 'wlr_renderer.c', - 'wlr_texture.c', - ), - include_directories: wlr_inc, - dependencies: [ - egl, - drm.partial_dependency(compile_args: true), # - glesv2, - pixman, - wayland_server, - ], -) - -wlr_render = declare_dependency( - link_with: lib_wlr_render, +wlr_files += files( + 'dmabuf.c', + 'egl.c', + 'drm_format_set.c', + 'gles2/pixel_format.c', + 'gles2/renderer.c', + 'gles2/shaders.c', + 'gles2/texture.c', + 'wlr_renderer.c', + 'wlr_texture.c', ) diff --git a/types/meson.build b/types/meson.build index 6e9c2826a..4e141fb34 100644 --- a/types/meson.build +++ b/types/meson.build @@ -1,80 +1,69 @@ -lib_wlr_types = static_library( - 'wlr_types', - files( - 'data_device/wlr_data_device.c', - 'data_device/wlr_data_offer.c', - 'data_device/wlr_data_source.c', - 'data_device/wlr_drag.c', - 'seat/wlr_seat_keyboard.c', - 'seat/wlr_seat_pointer.c', - 'seat/wlr_seat_touch.c', - 'seat/wlr_seat.c', - 'tablet_v2/wlr_tablet_v2_pad.c', - 'tablet_v2/wlr_tablet_v2_tablet.c', - 'tablet_v2/wlr_tablet_v2_tool.c', - 'tablet_v2/wlr_tablet_v2.c', - 'xdg_shell_v6/wlr_xdg_popup_v6.c', - 'xdg_shell_v6/wlr_xdg_positioner_v6.c', - 'xdg_shell_v6/wlr_xdg_shell_v6.c', - 'xdg_shell_v6/wlr_xdg_surface_v6.c', - 'xdg_shell_v6/wlr_xdg_toplevel_v6.c', - 'xdg_shell/wlr_xdg_popup.c', - 'xdg_shell/wlr_xdg_positioner.c', - 'xdg_shell/wlr_xdg_shell.c', - 'xdg_shell/wlr_xdg_surface.c', - 'xdg_shell/wlr_xdg_toplevel.c', - 'wlr_box.c', - 'wlr_buffer.c', - 'wlr_compositor.c', - 'wlr_cursor.c', - 'wlr_data_control_v1.c', - 'wlr_export_dmabuf_v1.c', - 'wlr_foreign_toplevel_management_v1.c', - 'wlr_fullscreen_shell_v1.c', - 'wlr_gamma_control_v1.c', - 'wlr_gtk_primary_selection.c', - 'wlr_idle_inhibit_v1.c', - 'wlr_idle.c', - 'wlr_input_device.c', - 'wlr_input_inhibitor.c', - 'wlr_input_method_v2.c', - 'wlr_keyboard.c', - 'wlr_keyboard_group.c', - 'wlr_layer_shell_v1.c', - 'wlr_linux_dmabuf_v1.c', - 'wlr_list.c', - 'wlr_matrix.c', - 'wlr_output_damage.c', - 'wlr_output_layout.c', - 'wlr_output_management_v1.c', - 'wlr_output.c', - 'wlr_pointer_constraints_v1.c', - 'wlr_pointer_gestures_v1.c', - 'wlr_pointer.c', - 'wlr_presentation_time.c', - 'wlr_primary_selection_v1.c', - 'wlr_primary_selection.c', - 'wlr_region.c', - 'wlr_relative_pointer_v1.c', - 'wlr_screencopy_v1.c', - 'wlr_server_decoration.c', - 'wlr_surface.c', - 'wlr_switch.c', - 'wlr_tablet_pad.c', - 'wlr_tablet_tool.c', - 'wlr_text_input_v3.c', - 'wlr_touch.c', - 'wlr_virtual_keyboard_v1.c', - 'wlr_xcursor_manager.c', - 'wlr_xdg_decoration_v1.c', - 'wlr_xdg_output_v1.c', - ), - include_directories: wlr_inc, - dependencies: [ - drm.partial_dependency(compile_args: true), # - pixman, - wayland_server, - wlr_protos, - xkbcommon, - ], +wlr_files += files( + 'data_device/wlr_data_device.c', + 'data_device/wlr_data_offer.c', + 'data_device/wlr_data_source.c', + 'data_device/wlr_drag.c', + 'seat/wlr_seat_keyboard.c', + 'seat/wlr_seat_pointer.c', + 'seat/wlr_seat_touch.c', + 'seat/wlr_seat.c', + 'tablet_v2/wlr_tablet_v2_pad.c', + 'tablet_v2/wlr_tablet_v2_tablet.c', + 'tablet_v2/wlr_tablet_v2_tool.c', + 'tablet_v2/wlr_tablet_v2.c', + 'xdg_shell_v6/wlr_xdg_popup_v6.c', + 'xdg_shell_v6/wlr_xdg_positioner_v6.c', + 'xdg_shell_v6/wlr_xdg_shell_v6.c', + 'xdg_shell_v6/wlr_xdg_surface_v6.c', + 'xdg_shell_v6/wlr_xdg_toplevel_v6.c', + 'xdg_shell/wlr_xdg_popup.c', + 'xdg_shell/wlr_xdg_positioner.c', + 'xdg_shell/wlr_xdg_shell.c', + 'xdg_shell/wlr_xdg_surface.c', + 'xdg_shell/wlr_xdg_toplevel.c', + 'wlr_box.c', + 'wlr_buffer.c', + 'wlr_compositor.c', + 'wlr_cursor.c', + 'wlr_data_control_v1.c', + 'wlr_export_dmabuf_v1.c', + 'wlr_foreign_toplevel_management_v1.c', + 'wlr_fullscreen_shell_v1.c', + 'wlr_gamma_control_v1.c', + 'wlr_gtk_primary_selection.c', + 'wlr_idle_inhibit_v1.c', + 'wlr_idle.c', + 'wlr_input_device.c', + 'wlr_input_inhibitor.c', + 'wlr_input_method_v2.c', + 'wlr_keyboard.c', + 'wlr_keyboard_group.c', + 'wlr_layer_shell_v1.c', + 'wlr_linux_dmabuf_v1.c', + 'wlr_list.c', + 'wlr_matrix.c', + 'wlr_output_damage.c', + 'wlr_output_layout.c', + 'wlr_output_management_v1.c', + 'wlr_output.c', + 'wlr_pointer_constraints_v1.c', + 'wlr_pointer_gestures_v1.c', + 'wlr_pointer.c', + 'wlr_presentation_time.c', + 'wlr_primary_selection_v1.c', + 'wlr_primary_selection.c', + 'wlr_region.c', + 'wlr_relative_pointer_v1.c', + 'wlr_screencopy_v1.c', + 'wlr_server_decoration.c', + 'wlr_surface.c', + 'wlr_switch.c', + 'wlr_tablet_pad.c', + 'wlr_tablet_tool.c', + 'wlr_text_input_v3.c', + 'wlr_touch.c', + 'wlr_virtual_keyboard_v1.c', + 'wlr_xcursor_manager.c', + 'wlr_xdg_decoration_v1.c', + 'wlr_xdg_output_v1.c', ) diff --git a/util/meson.build b/util/meson.build index dca3e9a44..c66142757 100644 --- a/util/meson.build +++ b/util/meson.build @@ -1,12 +1,7 @@ -lib_wlr_util = static_library( - 'wlr_util', - files( - 'array.c', - 'log.c', - 'region.c', - 'shm.c', - 'signal.c', - ), - include_directories: wlr_inc, - dependencies: [wayland_server, pixman, rt], +wlr_files += files( + 'array.c', + 'log.c', + 'region.c', + 'shm.c', + 'signal.c', ) diff --git a/xcursor/meson.build b/xcursor/meson.build index 31040a92e..a85051e9e 100644 --- a/xcursor/meson.build +++ b/xcursor/meson.build @@ -1,9 +1,4 @@ -lib_wlr_xcursor = static_library( - 'wlr_xcursor', - files( - 'wlr_xcursor.c', - 'xcursor.c', - ), - include_directories: wlr_inc, - dependencies: [egl] # header required via include/wlr/render.h +wlr_files += files( + 'wlr_xcursor.c', + 'xcursor.c', ) diff --git a/xwayland/meson.build b/xwayland/meson.build index e5f9b9bea..12c69da42 100644 --- a/xwayland/meson.build +++ b/xwayland/meson.build @@ -5,13 +5,24 @@ xwayland_required = [ 'xcb-render', 'xcb-xfixes', ] -xwayland_optional = [ - 'xcb-errors', - 'xcb-icccm', -] +xwayland_optional = { + 'xcb-errors': 'Required for printing X11 errors.', + 'xcb-icccm': 'Required for extended X11 window manager hints.', +} + +msg = [] +if get_option('xwayland').enabled() + msg += 'Install "@0@" or pass "-Dxwayland=disabled".' +endif +if not get_option('xwayland').disabled() + msg += 'Required for Xwayland support.' +endif foreach lib : xwayland_required - dep = dependency(lib, required: get_option('xwayland')) + dep = dependency(lib, + required: get_option('xwayland'), + not_found_message: '\n'.join(msg).format(lib), + ) if not dep.found() subdir_done() endif @@ -19,33 +30,33 @@ foreach lib : xwayland_required xwayland_libs += dep endforeach -foreach lib : xwayland_optional - dep = dependency(lib, required: get_option(lib)) +foreach lib, desc : xwayland_optional + msg = [] + if get_option(lib).enabled() + msg += 'Install "@0@" or pass "-D@0@=disabled".' + endif + if not get_option(lib).disabled() + msg += desc + endif + + dep = dependency(lib, + required: get_option(lib), + not_found_message: '\n'.join(msg).format(lib), + ) if dep.found() xwayland_libs += dep conf_data.set10('WLR_HAS_' + lib.underscorify().to_upper(), true) endif endforeach -lib_wlr_xwayland = static_library( - 'wlr_xwayland', - files( - 'selection/dnd.c', - 'selection/incoming.c', - 'selection/outgoing.c', - 'selection/selection.c', - 'sockets.c', - 'xwayland.c', - 'xwm.c', - ), - include_directories: wlr_inc, - dependencies: [ - wayland_server, - xwayland_libs, - xkbcommon, - pixman, - ], +wlr_files += files( + 'selection/dnd.c', + 'selection/incoming.c', + 'selection/outgoing.c', + 'selection/selection.c', + 'sockets.c', + 'xwayland.c', + 'xwm.c', ) - -wlr_parts += lib_wlr_xwayland +wlr_deps += xwayland_libs conf_data.set10('WLR_HAS_XWAYLAND', true)