From 66064a07a6830295c687706c7f8f1c1841998a3d Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 19:39:15 +1200 Subject: [PATCH 01/14] Remove unneeded mesa-specific header --- glgen.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/glgen.sh b/glgen.sh index 0356cf98..b27750e4 100755 --- a/glgen.sh +++ b/glgen.sh @@ -66,7 +66,6 @@ cat > $OUT_H << EOF #include #include -#include #include #include From 3fa3dca6d583cf809a8d8d47a44ac17a5048e4e5 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 19:41:53 +1200 Subject: [PATCH 02/14] Add new feature options Bump minimum meson version to 0.47 for the feature. --- meson.build | 2 +- meson_options.txt | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 655eb52d..502616ca 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( 'c', version: '0.0.1', license: 'MIT', - meson_version: '>=0.44.0', + meson_version: '>=0.47.0', default_options: [ 'c_std=c11', 'warning_level=2', diff --git a/meson_options.txt b/meson_options.txt index e474b8aa..918d7e98 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -6,3 +6,13 @@ option('enable-xwayland', type: 'boolean', value: true, description: 'Enable sup option('enable-x11_backend', type: 'boolean', value: true, description: 'Enable X11 backend') option('enable-rootston', type: 'boolean', value: true, description: 'Build the rootston example compositor') option('enable-examples', type: 'boolean', value: true, description: 'Build example applications') +option('libcap', type: 'feature', value: 'auto', description: 'Enable support for rootless session via capabilities (cap_sys_admin)') +option('logind', type: 'feature', value: 'auto', description: 'Enable support for rootless session via logind') +option('logind-provider', type: 'combo', choices: ['systemd', 'elogind'], value: 'systemd', description: 'Provider of logind support library') +option('xcb-errors', type: 'feature', value: 'auto', description: 'Use xcb-errors util library') +option('xcb-icccm', type: 'feature', value: 'auto', description: 'Use xcb-icccm util library') +option('xcb-xkb', type: 'feature', value: 'auto', description: 'Use xcb-xkb util library') +option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications') +option('x11-backend', type: 'feature', value: 'auto', description: 'Enable X11 backend') +option('rootston', type: 'boolean', value: true, description: 'Build the rootston example compositor') +option('examples', type: 'boolean', value: true, description: 'Build example applications') From 94ed2fc7bbe9f673f064d3cc5e6841a3879a4268 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 19:53:00 +1200 Subject: [PATCH 03/14] Use feature options for libcap/logind We now use a combo choice between systemd/elogind as they are mutually exclusive anyway. --- backend/meson.build | 9 ++------- meson.build | 17 ++++++----------- meson_options.txt | 3 --- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/backend/meson.build b/backend/meson.build index 52abe64d..48a0511a 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -44,9 +44,9 @@ else backend_files += files('session/direct.c') endif -if conf_data.get('WLR_HAS_SYSTEMD', false) +if logind.found() backend_files += files('session/logind.c') - backend_deps += systemd + backend_deps += logind endif if conf_data.get('WLR_HAS_X11_BACKEND', false) @@ -58,11 +58,6 @@ if conf_data.get('WLR_HAS_X11_BACKEND', false) backend_deps += xcb_xkb endif -if conf_data.get('WLR_HAS_ELOGIND', false) - backend_files += files('session/logind.c') - backend_deps += elogind -endif - lib_wlr_backend = static_library( 'wlr_backend', backend_files, diff --git a/meson.build b/meson.build index 502616ca..7d5266d2 100644 --- a/meson.build +++ b/meson.build @@ -62,27 +62,22 @@ libinput = dependency('libinput', version: '>=1.7.0') xkbcommon = dependency('xkbcommon') udev = dependency('libudev') pixman = dependency('pixman-1') -libcap = dependency('libcap', required: get_option('enable-libcap') == 'true') -systemd = dependency('libsystemd', required: get_option('enable-systemd') == 'true') -elogind = dependency('libelogind', required: get_option('enable-elogind') == 'true') +libcap = dependency('libcap', required: get_option('libcap')) +logind = dependency('lib' + get_option('logind-provider'), required: get_option('logind')) math = cc.find_library('m', required: false) exclude_headers = [] wlr_parts = [] wlr_deps = [] -if libcap.found() and get_option('enable-libcap') != 'false' +if libcap.found() conf_data.set('WLR_HAS_LIBCAP', true) wlr_deps += libcap endif -if systemd.found() and get_option('enable-systemd') != 'false' - conf_data.set('WLR_HAS_SYSTEMD', true) - wlr_deps += systemd -endif - -if elogind.found() and get_option('enable-elogind') != 'false' - conf_data.set('WLR_HAS_ELOGIND', true) +if logind.found() + conf_data.set('WLR_HAS_' + get_option('logind-provider').to_upper(), true) + wlr_deps += logind endif if get_option('enable-x11_backend') or get_option('enable-xwayland') diff --git a/meson_options.txt b/meson_options.txt index 918d7e98..fd1fbf05 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,6 +1,3 @@ -option('enable-libcap', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for capabilities') -option('enable-systemd', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for logind') -option('enable-elogind', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for logind') option('enable-xcb_errors', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Use xcb-errors util library') option('enable-xwayland', type: 'boolean', value: true, description: 'Enable support X11 applications') option('enable-x11_backend', type: 'boolean', value: true, description: 'Enable X11 backend') From 784c20c82fb6fb84c5ce49993b5a2ec0bda13475 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 20:27:37 +1200 Subject: [PATCH 04/14] Use new options for X11 backend and Xwayland --- backend/meson.build | 11 +++------ backend/x11/meson.build | 44 ++++++++++++++++++++++++++++++++++ meson.build | 53 ++++------------------------------------- meson_options.txt | 3 --- rootston/meson.build | 6 +++-- xwayland/meson.build | 41 +++++++++++++++++++++++++------ 6 files changed, 90 insertions(+), 68 deletions(-) create mode 100644 backend/x11/meson.build diff --git a/backend/meson.build b/backend/meson.build index 48a0511a..dd1f4df3 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -1,3 +1,4 @@ +backend_parts = [] backend_files = files( 'backend.c', 'drm/atomic.c', @@ -49,18 +50,12 @@ if logind.found() backend_deps += logind endif -if conf_data.get('WLR_HAS_X11_BACKEND', false) - backend_files += files( - 'x11/backend.c', - 'x11/input_device.c', - 'x11/output.c', - ) - backend_deps += xcb_xkb -endif +subdir('x11') lib_wlr_backend = static_library( 'wlr_backend', backend_files, include_directories: wlr_inc, + link_whole: backend_parts, dependencies: backend_deps, ) diff --git a/backend/x11/meson.build b/backend/x11/meson.build new file mode 100644 index 00000000..1164df1e --- /dev/null +++ b/backend/x11/meson.build @@ -0,0 +1,44 @@ +x11_libs = [] +x11_required = [ + 'xcb', + 'x11-xcb', +] +x11_optional = [ + 'xcb-xkb', +] + +foreach lib : x11_required + dep = dependency(lib, required: get_option('x11-backend')) + if not dep.found() + subdir_done() + endif + + x11_libs += dep +endforeach + +foreach lib : x11_optional + dep = dependency(lib, required: get_option(lib)) + if dep.found() + x11_libs += dep + conf_data.set('WLR_HAS_' + lib.underscorify().to_upper(), true) + endif +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, + ], +) + +backend_parts += lib_wlr_backend_x11 +conf_data.set('WLR_HAS_X11_BACKEND', true) diff --git a/meson.build b/meson.build index 7d5266d2..ff1a4ee8 100644 --- a/meson.build +++ b/meson.build @@ -80,64 +80,21 @@ if logind.found() wlr_deps += logind endif -if get_option('enable-x11_backend') or get_option('enable-xwayland') - xcb = dependency('xcb') - xcb_composite = dependency('xcb-composite') - xcb_xfixes = dependency('xcb-xfixes') - xcb_image = dependency('xcb-image') - xcb_render = dependency('xcb-render') - x11_xcb = dependency('x11-xcb') - - xcb_icccm = dependency('xcb-icccm', required: false) - xcb_xkb = dependency('xcb-xkb', required: false) - xcb_errors = dependency('xcb-errors', required: get_option('enable-xcb_errors') == 'true') - - if xcb_icccm.found() - conf_data.set('WLR_HAS_XCB_ICCCM', true) - endif - - if xcb_xkb.found() - conf_data.set('WLR_HAS_XCB_XKB', true) - endif - - if xcb_errors.found() and get_option('enable-xcb_errors') != 'false' - conf_data.set('WLR_HAS_XCB_ERRORS', true) - endif - - wlr_deps += [ - xcb, - xcb_composite, - x11_xcb, - ] -else - add_project_arguments('-DMESA_EGL_NO_X11_HEADERS', language: 'c') -endif - -if get_option('enable-x11_backend') - conf_data.set('WLR_HAS_X11_BACKEND', true) -endif - -if get_option('enable-xwayland') - subdir('xwayland') - wlr_parts += [lib_wlr_xwayland] - conf_data.set('WLR_HAS_XWAYLAND', true) -else - exclude_headers += 'xwayland.h' -endif - if cc.has_header_symbol('fcntl.h', 'posix_fallocate', prefix: '#define _POSIX_C_SOURCE 200112L') conf_data.set('WLR_HAS_POSIX_FALLOCATE', true) endif +subdir('protocol') +subdir('render') +subdir('backend') +subdir('xwayland') + includedir = get_option('includedir') exclude_headers += 'meson.build' install_subdir('include/wlr', install_dir: includedir, exclude_files: exclude_headers) subdir('include') -subdir('protocol') -subdir('render') -subdir('backend') subdir('types') subdir('util') subdir('xcursor') diff --git a/meson_options.txt b/meson_options.txt index fd1fbf05..854022e7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,6 +1,3 @@ -option('enable-xcb_errors', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Use xcb-errors util library') -option('enable-xwayland', type: 'boolean', value: true, description: 'Enable support X11 applications') -option('enable-x11_backend', type: 'boolean', value: true, description: 'Enable X11 backend') option('enable-rootston', type: 'boolean', value: true, description: 'Build the rootston example compositor') option('enable-examples', type: 'boolean', value: true, description: 'Build example applications') option('libcap', type: 'feature', value: 'auto', description: 'Enable support for rootless session via capabilities (cap_sys_admin)') diff --git a/rootston/meson.build b/rootston/meson.build index 8ab872b5..b461e1a0 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -14,9 +14,11 @@ sources = [ 'xdg_shell_v6.c', 'xdg_shell.c', ] -if get_option('enable-xwayland') - sources += ['xwayland.c'] + +if conf_data.get('WLR_HAS_XWAYLAND', false) + sources += 'xwayland.c' endif + executable( 'rootston', sources, dependencies: [wlroots, wlr_protos, pixman] ) diff --git a/xwayland/meson.build b/xwayland/meson.build index ec486f58..637f565e 100644 --- a/xwayland/meson.build +++ b/xwayland/meson.build @@ -1,3 +1,33 @@ +xwayland_libs = [] +xwayland_required = [ + 'xcb', + 'xcb-composite', + 'xcb-render', + 'xcb-xfixes', +] +xwayland_optional = [ + 'xcb-errors', + 'xcb-icccm', +] + +foreach lib : xwayland_required + dep = dependency(lib, required: get_option('xwayland')) + if not dep.found() + exclude_headers += 'xwayland.h' + subdir_done() + endif + + xwayland_libs += dep +endforeach + +foreach lib : xwayland_optional + dep = dependency(lib, required: get_option(lib)) + if dep.found() + xwayland_libs += dep + conf_data.set('WLR_HAS_' + lib.underscorify().to_upper(), true) + endif +endforeach + lib_wlr_xwayland = static_library( 'wlr_xwayland', files( @@ -12,14 +42,11 @@ lib_wlr_xwayland = static_library( include_directories: wlr_inc, dependencies: [ wayland_server, - xcb, - xcb_composite, - xcb_xfixes, - xcb_image, - xcb_render, - xcb_icccm, - xcb_errors, + xwayland_libs, xkbcommon, pixman, ], ) + +wlr_parts += lib_wlr_xwayland +conf_data.set('WLR_HAS_XWAYLAND', true) From 560e96aa57dc746adcbd5297c3544edd16c0626e Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 20:41:25 +1200 Subject: [PATCH 05/14] Update rootston to use new option --- meson.build | 6 ++---- meson_options.txt | 1 - rootston/meson.build | 7 +++++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index ff1a4ee8..004cab4a 100644 --- a/meson.build +++ b/meson.build @@ -161,14 +161,12 @@ summary = [ message('\n'.join(summary)) -if get_option('enable-rootston') - subdir('rootston') -endif - if get_option('enable-examples') subdir('examples') endif +subdir('rootston') + pkgconfig = import('pkgconfig') pkgconfig.generate( libraries: lib_wlr, diff --git a/meson_options.txt b/meson_options.txt index 854022e7..140459cb 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,3 @@ -option('enable-rootston', type: 'boolean', value: true, description: 'Build the rootston example compositor') option('enable-examples', type: 'boolean', value: true, description: 'Build example applications') option('libcap', type: 'feature', value: 'auto', description: 'Enable support for rootless session via capabilities (cap_sys_admin)') option('logind', type: 'feature', value: 'auto', description: 'Enable support for rootless session via logind') diff --git a/rootston/meson.build b/rootston/meson.build index b461e1a0..9d1decce 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -11,8 +11,8 @@ sources = [ 'seat.c', 'virtual_keyboard.c', 'wl_shell.c', - 'xdg_shell_v6.c', 'xdg_shell.c', + 'xdg_shell_v6.c', ] if conf_data.get('WLR_HAS_XWAYLAND', false) @@ -20,5 +20,8 @@ if conf_data.get('WLR_HAS_XWAYLAND', false) endif executable( - 'rootston', sources, dependencies: [wlroots, wlr_protos, pixman] + 'rootston', + sources, + dependencies: [wlroots, wlr_protos, pixman], + build_by_default: get_option('rootston'), ) From 584a3f8b6e9e241bb8510d845bbed386294ad48f Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 20:49:23 +1200 Subject: [PATCH 06/14] Update examples to use new option We use a dictionary to remove some code duplication. --- examples/meson.build | 154 ++++++++++++++++++++++++------------------- meson.build | 6 +- meson_options.txt | 1 - 3 files changed, 89 insertions(+), 72 deletions(-) diff --git a/examples/meson.build b/examples/meson.build index 25ad7566..0fb37a9e 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,80 +1,102 @@ threads = dependency('threads') wayland_cursor = dependency('wayland-cursor') - libpng = dependency('libpng', required: false) - # These versions correspond to ffmpeg 4.0 libavutil = dependency('libavutil', version: '>=56.14.100', required: false) libavcodec = dependency('libavcodec', version: '>=58.18.100', required: false) libavformat = dependency('libavformat', version: '>=58.12.100', required: false) +# Small hack until https://github.com/mesonbuild/meson/pull/3386/ is merged +foreach dep : ['libpng', 'libavutil', 'libavcodec', 'libavformat'] + if not get_variable(dep).found() + set_variable(dep, disabler()) + endif +endforeach + if not cc.has_header('libavutil/hwcontext_drm.h', dependencies: libavutil) - libavutil = disabler() + libavutil = disabler() endif -executable('simple', 'simple.c', dependencies: wlroots) -executable('pointer', 'pointer.c', dependencies: wlroots) -executable('touch', 'touch.c', 'cat.c', dependencies: wlroots) -executable('tablet', 'tablet.c', dependencies: wlroots) -executable('rotation', 'rotation.c', 'cat.c', dependencies: wlroots) -executable('multi-pointer', 'multi-pointer.c', dependencies: wlroots) -executable('output-layout', 'output-layout.c', 'cat.c', dependencies: wlroots) - -executable( - 'screenshot', - 'screenshot.c', - dependencies: [wayland_client, wlr_protos, wlroots] -) - -executable( - 'idle', - 'idle.c', - dependencies: [wayland_client, wlr_protos, wlroots, threads] -) - -executable( - 'idle-inhibit', - 'idle-inhibit.c', - dependencies: [wayland_client, wlr_protos, wlroots, threads] -) - -executable( - 'layer-shell', - 'layer-shell.c', - dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots] -) - -executable( - 'input-inhibitor', - 'input-inhibitor.c', - dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots] -) +examples = { + '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, + }, + 'screenshot': { + 'src': 'screenshot.c', + 'dep': [wayland_client, wlr_protos, wlroots], + }, + 'idle': { + 'src': 'idle.c', + 'dep': [wayland_client, wlr_protos, wlroots, threads], + }, + 'idle-inhibit': { + 'src': 'idle-inhibit.c', + 'dep': [wayland_client, wlr_protos, wlroots], + }, + 'layer-shell': { + 'src': 'layer-shell.c', + 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots], + }, + 'input-inhibitor': { + 'src': 'input-inhibitor.c', + 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots], + }, + 'gamma-control': { + 'src': 'gamma-control.c', + 'dep': [wayland_client, wayland_cursor, wlr_protos, wlroots], + }, + 'dmabuf-capture': { + 'src': 'dmabuf-capture.c', + 'dep': [ + libavcodec, + libavformat, + libavutil, + threads, + wayland_client, + wlr_protos, + wlroots, + ], + }, + 'screencopy': { + 'src': 'screencopy.c', + 'dep': [libpng, wayland_client, wlr_protos, wlroots], + }, + 'toplevel-decoration': { + 'src': 'toplevel-decoration.c', + 'dep': [wayland_client, wlr_protos, wlroots], + }, +} -executable( - 'gamma-control', - 'gamma-control.c', - dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots] -) - -if libavutil.found() and libavcodec.found() and libavformat.found() +foreach name, info : examples executable( - 'dmabuf-capture', - 'dmabuf-capture.c', - dependencies: [wayland_client, wlr_protos, libavutil, libavcodec, - libavformat, wlroots, threads ] + name, + info.get('src'), + dependencies: info.get('dep'), + build_by_default: get_option('examples'), ) -endif - -if libpng.found() - executable( - 'screencopy', - 'screencopy.c', - dependencies: [wayland_client, wlr_protos, wlroots, libpng] - ) -endif - -executable( - 'toplevel-decoration', - 'toplevel-decoration.c', - dependencies: [wayland_client, wlr_protos, wlroots] -) +endforeach diff --git a/meson.build b/meson.build index 004cab4a..2790342b 100644 --- a/meson.build +++ b/meson.build @@ -160,11 +160,7 @@ summary = [ ] message('\n'.join(summary)) - -if get_option('enable-examples') - subdir('examples') -endif - +subdir('examples') subdir('rootston') pkgconfig = import('pkgconfig') diff --git a/meson_options.txt b/meson_options.txt index 140459cb..360c6f6a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,3 @@ -option('enable-examples', type: 'boolean', value: true, description: 'Build example applications') option('libcap', type: 'feature', value: 'auto', description: 'Enable support for rootless session via capabilities (cap_sys_admin)') option('logind', type: 'feature', value: 'auto', description: 'Enable support for rootless session via logind') option('logind-provider', type: 'combo', choices: ['systemd', 'elogind'], value: 'systemd', description: 'Provider of logind support library') From 1358d80ab99d91492d9f14d14385a537f1044a12 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 20:56:12 +1200 Subject: [PATCH 07/14] Add link dependency on symbols file So the library is rebuilt properly when it's updated. --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 2790342b..3216f208 100644 --- a/meson.build +++ b/meson.build @@ -134,6 +134,7 @@ lib_wlr = library( include_directories: wlr_inc, install: true, link_args : symbols_flag, + link_depends: symbols_file, ) wlroots = declare_dependency( From 869dca1bce662e685a83a33f7550644817265fb9 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 20:59:02 +1200 Subject: [PATCH 08/14] Remove unnecessary project arguments Meson handles rpath properly, and we don't need to use -I ourselves by using include_directories with '.'. --- meson.build | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/meson.build b/meson.build index 3216f208..db2e13e8 100644 --- a/meson.build +++ b/meson.build @@ -21,14 +21,6 @@ add_project_arguments( '-DWLR_SRC_DIR="@0@"'.format(meson.source_root()), language: 'c', ) -add_project_arguments( - '-I@0@'.format(meson.build_root()), - language: 'c', -) -add_project_link_arguments( - '-Wl,-rpath,@0@'.format(meson.build_root()), - language: 'c', -) add_project_arguments( '-DWLR_USE_UNSTABLE', language: 'c', @@ -36,7 +28,7 @@ add_project_arguments( conf_data = configuration_data() -wlr_inc = include_directories('include') +wlr_inc = include_directories('.', 'include') cc = meson.get_compiler('c') From a2bbf2c1f70ef374ff4a2506e65379c819b72414 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 21:03:38 +1200 Subject: [PATCH 09/14] Make style more consistent --- meson.build | 20 ++++++++++++-------- protocol/meson.build | 7 +++++-- render/meson.build | 6 +++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index db2e13e8..d31296f7 100644 --- a/meson.build +++ b/meson.build @@ -135,7 +135,6 @@ wlroots = declare_dependency( include_directories: wlr_inc, ) - summary = [ '', '----------------', @@ -169,26 +168,31 @@ git = find_program('git', required: false) if git.found() all_files = run_command( git, - ['--git-dir=@0@/.git'.format(meson.current_source_dir()), - 'ls-files', - ':/*.[ch]']) + '--git-dir=@0@/.git'.format(meson.current_source_dir()), + 'ls-files', + ':/*.[ch]', + ) all_files = files(all_files.stdout().split()) etags = find_program('etags', required: false) if etags.found() and all_files.length() > 0 - custom_target('etags', + custom_target( + 'etags', build_by_default: true, input: all_files, output: 'TAGS', - command: [etags.path(), '-o', 'TAGS'] + all_files) + command: [etags, '-o', '@OUTPUT@', '@INPUT@'], + ) endif ctags = find_program('ctags', required: false) if ctags.found() and all_files.length() > 0 - custom_target('ctags', + custom_target( + 'ctags', build_by_default: true, input: all_files, output: 'tags', - command: [ctags.path(), '-f', 'tags'] + all_files) + command: [ctags, '-f', '@OUTPUT@', '@INPUT@'], + ) endif endif diff --git a/protocol/meson.build b/protocol/meson.build index 73a3156a..58126561 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -76,8 +76,11 @@ foreach p : client_protocols wl_protos_headers += wayland_scanner_client.process(xml) endforeach -lib_wl_protos = static_library('wl_protos', wl_protos_src + wl_protos_headers, - dependencies: [wayland_client]) # for the include directory +lib_wl_protos = static_library( + 'wl_protos', + wl_protos_src + wl_protos_headers, + dependencies: wayland_client.partial_dependency(includes: true), +) wlr_protos = declare_dependency( link_with: lib_wl_protos, diff --git a/render/meson.build b/render/meson.build index 4b90c229..c5401d22 100644 --- a/render/meson.build +++ b/render/meson.build @@ -1,6 +1,7 @@ glgen = find_program('../glgen.sh') -glapi = custom_target('glapi', +glapi = custom_target( + 'glapi', input: 'glapi.txt', output: ['@BASENAME@.c', '@BASENAME@.h'], command: [glgen, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@'], @@ -19,8 +20,7 @@ lib_wlr_render = static_library( 'wlr_renderer.c', 'wlr_texture.c', ), - glapi[0], - glapi[1], + glapi, include_directories: wlr_inc, dependencies: [egl, glesv2, pixman, wayland_server], ) From 51892e0d7483d57b1e5eadae88e967e72e968cc0 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 21:14:07 +1200 Subject: [PATCH 10/14] Install headers explicitly --- include/wlr/backend/meson.build | 16 ++++++++++ include/wlr/backend/session/meson.build | 1 + include/wlr/interfaces/meson.build | 10 ++++++ include/wlr/meson.build | 19 +++++++++-- include/wlr/render/meson.build | 9 ++++++ include/wlr/types/meson.build | 42 +++++++++++++++++++++++++ include/wlr/util/meson.build | 6 ++++ meson.build | 13 +++----- xwayland/meson.build | 1 - 9 files changed, 104 insertions(+), 13 deletions(-) create mode 100644 include/wlr/backend/meson.build create mode 100644 include/wlr/backend/session/meson.build create mode 100644 include/wlr/interfaces/meson.build create mode 100644 include/wlr/render/meson.build create mode 100644 include/wlr/types/meson.build create mode 100644 include/wlr/util/meson.build diff --git a/include/wlr/backend/meson.build b/include/wlr/backend/meson.build new file mode 100644 index 00000000..e005b854 --- /dev/null +++ b/include/wlr/backend/meson.build @@ -0,0 +1,16 @@ +install_headers( + 'drm.h', + 'headless.h', + 'interface.h', + 'libinput.h', + 'multi.h', + 'session.h', + 'wayland.h', + subdir: 'wlr/backend', +) + +if conf_data.get('WLR_HAS_X11_BACKEND', false) + 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 new file mode 100644 index 00000000..21b5a96b --- /dev/null +++ b/include/wlr/backend/session/meson.build @@ -0,0 +1 @@ +install_headers('interface.h', subdir: 'wlr/backend/session') diff --git a/include/wlr/interfaces/meson.build b/include/wlr/interfaces/meson.build new file mode 100644 index 00000000..207896b5 --- /dev/null +++ b/include/wlr/interfaces/meson.build @@ -0,0 +1,10 @@ +install_headers( + 'wlr_input_device.h', + 'wlr_keyboard.h', + 'wlr_output.h', + 'wlr_pointer.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 6259c311..14551cb4 100644 --- a/include/wlr/meson.build +++ b/include/wlr/meson.build @@ -9,6 +9,19 @@ 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]) -wlr_inc_dest = join_paths(get_option('includedir'), 'wlr') -configure_file(output: 'config.h', install_dir: wlr_inc_dest, configuration: conf_data) -configure_file(output: 'version.h', install_dir: wlr_inc_dest, configuration: version_data) +install_headers( + configure_file(output: 'config.h', configuration: conf_data), + configure_file(output: 'version.h', configuration: version_data), + 'backend.h', + 'xcursor.h', + subdir: 'wlr' +) +if conf_data.get('WLR_HAS_XWAYLAND', false) + install_headers('xwayland.h', subdir: 'wlr') +endif + +subdir('backend') +subdir('interfaces') +subdir('render') +subdir('types') +subdir('util') diff --git a/include/wlr/render/meson.build b/include/wlr/render/meson.build new file mode 100644 index 00000000..05127bb7 --- /dev/null +++ b/include/wlr/render/meson.build @@ -0,0 +1,9 @@ +install_headers( + 'dmabuf.h', + 'egl.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 new file mode 100644 index 00000000..8c81cb0e --- /dev/null +++ b/include/wlr/types/meson.build @@ -0,0 +1,42 @@ +install_headers( + 'wlr_box.h', + 'wlr_buffer.h', + 'wlr_compositor.h', + 'wlr_cursor.h', + 'wlr_data_device.h', + 'wlr_export_dmabuf_v1.h', + 'wlr_gamma_control.h', + 'wlr_gamma_control_v1.h', + 'wlr_idle.h', + 'wlr_idle_inhibit_v1.h', + 'wlr_input_device.h', + 'wlr_input_inhibitor.h', + 'wlr_keyboard.h', + 'wlr_layer_shell.h', + 'wlr_linux_dmabuf_v1.h', + 'wlr_list.h', + 'wlr_matrix.h', + 'wlr_output.h', + 'wlr_output_damage.h', + 'wlr_output_layout.h', + 'wlr_pointer.h', + 'wlr_primary_selection.h', + 'wlr_region.h', + 'wlr_screencopy_v1.h', + 'wlr_screenshooter.h', + 'wlr_seat.h', + 'wlr_server_decoration.h', + 'wlr_surface.h', + 'wlr_tablet_pad.h', + 'wlr_tablet_tool.h', + 'wlr_tablet_v2.h', + 'wlr_touch.h', + 'wlr_virtual_keyboard_v1.h', + 'wlr_wl_shell.h', + 'wlr_xcursor_manager.h', + 'wlr_xdg_decoration_v1.h', + 'wlr_xdg_output.h', + 'wlr_xdg_shell.h', + 'wlr_xdg_shell_v6.h', + subdir: 'wlr/types', +) diff --git a/include/wlr/util/meson.build b/include/wlr/util/meson.build new file mode 100644 index 00000000..ee72cbd6 --- /dev/null +++ b/include/wlr/util/meson.build @@ -0,0 +1,6 @@ +install_headers( + 'edges.h', + 'log.h', + 'region.h', + subdir: 'wlr/util', +) diff --git a/meson.build b/meson.build index d31296f7..06605189 100644 --- a/meson.build +++ b/meson.build @@ -58,7 +58,6 @@ libcap = dependency('libcap', required: get_option('libcap')) logind = dependency('lib' + get_option('logind-provider'), required: get_option('logind')) math = cc.find_library('m', required: false) -exclude_headers = [] wlr_parts = [] wlr_deps = [] @@ -78,18 +77,14 @@ endif subdir('protocol') subdir('render') -subdir('backend') -subdir('xwayland') - -includedir = get_option('includedir') -exclude_headers += 'meson.build' -install_subdir('include/wlr', install_dir: includedir, exclude_files: exclude_headers) - -subdir('include') +subdir('backend') subdir('types') subdir('util') subdir('xcursor') +subdir('xwayland') + +subdir('include') wlr_parts += [ lib_wl_protos, diff --git a/xwayland/meson.build b/xwayland/meson.build index 637f565e..0bd88924 100644 --- a/xwayland/meson.build +++ b/xwayland/meson.build @@ -13,7 +13,6 @@ xwayland_optional = [ foreach lib : xwayland_required dep = dependency(lib, required: get_option('xwayland')) if not dep.found() - exclude_headers += 'xwayland.h' subdir_done() endif From b1ed61b6493e2a5882aedf9d6732d34b390a8d26 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 17:29:43 +1200 Subject: [PATCH 11/14] Use pkg-config to find wayland-scanner --- protocol/meson.build | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/protocol/meson.build b/protocol/meson.build index 58126561..17318e1c 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -1,6 +1,14 @@ wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir') -wayland_scanner = find_program('wayland-scanner') +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'), + native: true, + ) +else + wayland_scanner = find_program('wayland-scanner', native: true) +endif wayland_scanner_server = generator( wayland_scanner, @@ -8,17 +16,10 @@ wayland_scanner_server = generator( arguments: ['server-header', '@INPUT@', '@OUTPUT@'], ) -# should check wayland_scanner's version, but it is hard to get -if wayland_server.version().version_compare('>=1.14.91') - code_type = 'private-code' -else - code_type = 'code' -endif - wayland_scanner_code = generator( wayland_scanner, output: '@BASENAME@-protocol.c', - arguments: [code_type, '@INPUT@', '@OUTPUT@'], + arguments: ['private-code', '@INPUT@', '@OUTPUT@'], ) wayland_scanner_client = generator( From 653ea512c2a44260394c0c3a8d5aecd028c0e188 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 21:20:26 +1200 Subject: [PATCH 12/14] Use current_source_dir instead of source_root This is so that log messages are printed properly when wlroots is build as a subproject. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 06605189..8458a66c 100644 --- a/meson.build +++ b/meson.build @@ -18,7 +18,7 @@ so_version = ['0', '0', '0'] add_project_arguments('-Wno-unused-parameter', language: 'c') add_project_arguments( - '-DWLR_SRC_DIR="@0@"'.format(meson.source_root()), + '-DWLR_SRC_DIR="@0@"'.format(meson.current_source_dir()), language: 'c', ) add_project_arguments( From f41c411980c7451083b3cd2f168f29ad065eb0d7 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 22 Aug 2018 21:32:24 +1200 Subject: [PATCH 13/14] Use input file for configure_file This is so we can potentially add comments to it, and so if a user looks at the installed header, they can see the /* #undef WLR_HAS_FEATURE */ line to see every option, even if not available. --- include/wlr/config.h.in | 19 +++++++++++++++++++ include/wlr/meson.build | 5 ++--- include/wlr/version.h.in | 16 ++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 include/wlr/config.h.in create mode 100644 include/wlr/version.h.in diff --git a/include/wlr/config.h.in b/include/wlr/config.h.in new file mode 100644 index 00000000..750ad3b7 --- /dev/null +++ b/include/wlr/config.h.in @@ -0,0 +1,19 @@ +#ifndef WLR_CONFIG_H +#define WLR_CONFIG_H + +#mesondefine WLR_HAS_LIBCAP + +#mesondefine WLR_HAS_SYSTEMD +#mesondefine WLR_HAS_ELOGIND + +#mesondefine WLR_HAS_X11_BACKEND + +#mesondefine WLR_HAS_XWAYLAND + +#mesondefine WLR_HAS_XCB_ERRORS +#mesondefine WLR_HAS_XCB_ICCCM +#mesondefine WLR_HAS_XCB_XKB + +#mesondefine WLR_HAS_POSIX_FALLOCATE + +#endif diff --git a/include/wlr/meson.build b/include/wlr/meson.build index 14551cb4..43b5aec9 100644 --- a/include/wlr/meson.build +++ b/include/wlr/meson.build @@ -4,14 +4,13 @@ version_data.set_quoted('WLR_VERSION_STR', meson.project_version()) version_data.set('WLR_VERSION_MAJOR', version_array[0]) version_data.set('WLR_VERSION_MINOR', version_array[1]) version_data.set('WLR_VERSION_MICRO', version_array[2]) -version_data.set('WLR_VERSION_NUM', '(WLR_VERSION_MAJOR << 16) | (WLR_VERSION_MINOR << 8) | WLR_VERSION_MICRO') 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(output: 'config.h', configuration: conf_data), - configure_file(output: 'version.h', configuration: version_data), + 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' diff --git a/include/wlr/version.h.in b/include/wlr/version.h.in new file mode 100644 index 00000000..cdc0fd75 --- /dev/null +++ b/include/wlr/version.h.in @@ -0,0 +1,16 @@ +#ifndef WLR_VERSION_H +#define WLR_VERSION_H + +#mesondefine WLR_VERSION_STR + +#mesondefine WLR_VERSION_MAJOR +#mesondefine WLR_VERSION_MINOR +#mesondefine WLR_VERSION_MICRO + +#define WLR_VERSION_NUM ((WLR_VERSION_MAJOR << 16) | (WLR_VERSION_MINOR << 8) | WLR_VERSION_MICRO) + +#mesondefine WLR_VERSION_API_CURRENT +#mesondefine WLR_VERSION_API_REVISION +#mesondefine WLR_VERSION_API_AGE + +#endif From 39ac21401fddd36474df0191603c0616d332e6da Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 23 Aug 2018 14:13:00 +1200 Subject: [PATCH 14/14] Replace generator with custom_target This stops the protocol header constantly being regenerated for every target using them. --- protocol/meson.build | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/protocol/meson.build b/protocol/meson.build index 17318e1c..2d2a73ed 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -10,24 +10,6 @@ else wayland_scanner = find_program('wayland-scanner', native: true) endif -wayland_scanner_server = generator( - wayland_scanner, - output: '@BASENAME@-protocol.h', - arguments: ['server-header', '@INPUT@', '@OUTPUT@'], -) - -wayland_scanner_code = generator( - wayland_scanner, - output: '@BASENAME@-protocol.c', - arguments: ['private-code', '@INPUT@', '@OUTPUT@'], -) - -wayland_scanner_client = generator( - wayland_scanner, - output: '@BASENAME@-client-protocol.h', - arguments: ['client-header', '@INPUT@', '@OUTPUT@'], -) - protocols = [ [wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'], [wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'], @@ -68,13 +50,28 @@ wl_protos_headers = [] foreach p : protocols xml = join_paths(p) - wl_protos_src += wayland_scanner_code.process(xml) - wl_protos_headers += wayland_scanner_server.process(xml) + wl_protos_src += custom_target( + xml.underscorify() + '_server_c', + input: xml, + output: '@BASENAME@-protocol.c', + command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'], + ) + wl_protos_headers += custom_target( + xml.underscorify() + '_server_h', + input: xml, + output: '@BASENAME@-protocol.h', + command: [wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@'], + ) endforeach foreach p : client_protocols xml = join_paths(p) - wl_protos_headers += wayland_scanner_client.process(xml) + wl_protos_headers += custom_target( + xml.underscorify() + '_client_h', + input: xml, + output: '@BASENAME@-client-protocol.h', + command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'], + ) endforeach lib_wl_protos = static_library(