From c8052d423a285e0ac55f76399bf52f0ae0cc4d7e Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 30 Jul 2021 07:49:52 -0500 Subject: [PATCH] build: Split core protocols out as separate library Currently both libwayland-client and libwayland-server contain the core protocol symbols. This disappoints ASAN when both libraries are included in the same binary (such as in our test suite). Compositors also can include both client and server libraries, so this provides some pointless minor space savings in real world usage as well. Let's split the protocol bits off into their own library to avoid this duplication. Signed-off-by: Derek Foreman --- cursor/meson.build | 2 +- src/meson.build | 19 +++++++++++++++++-- tests/meson.build | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cursor/meson.build b/cursor/meson.build index ae85ed9b..24d639c5 100644 --- a/cursor/meson.build +++ b/cursor/meson.build @@ -11,7 +11,7 @@ wayland_cursor = library( 'xcursor.c', ], version: '0.0.0', - dependencies: [ wayland_client_dep ], + dependencies: [ wayland_client_dep, wayland_core_protocols_dep ], c_args: [ '-DICONDIR="@0@"'.format(icondir) ], install: true, ) diff --git a/src/meson.build b/src/meson.build index ec00d816..5f17462a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -151,12 +151,24 @@ if get_option('libraries') output: 'wayland-protocol.c' ) + wayland_core_protocols = library( + 'wayland-core-protocols', + sources: [ + wayland_protocol_c + ], + version: '0.1.0', + include_directories: root_inc, + install: true + ) + wayland_core_protocols_dep = declare_dependency( + link_with: wayland_core_protocols + ) + wayland_server = library( 'wayland-server', sources: [ wayland_server_protocol_core_h, wayland_server_protocol_h, - wayland_protocol_c, 'wayland-server.c', 'wayland-shm.c', 'event-loop.c' @@ -164,6 +176,7 @@ if get_option('libraries') version: '0.1.0', dependencies: [ ffi_dep, + wayland_core_protocols_dep, wayland_private_dep, wayland_util_dep, mathlib_dep, @@ -190,6 +203,7 @@ if get_option('libraries') description: 'Server side implementation of the Wayland protocol', version: meson.project_version(), filebase: 'wayland-server', + libraries: '-lwayland-core-protocols', variables: [ 'datarootdir=' + join_paths('${prefix}', get_option('datadir')), 'pkgdatadir=' + join_paths('${datarootdir}', meson.project_name()) @@ -201,12 +215,12 @@ if get_option('libraries') sources: [ wayland_client_protocol_core_h, wayland_client_protocol_h, - wayland_protocol_c, 'wayland-client.c' ], version: '0.3.0', dependencies: [ ffi_dep, + wayland_core_protocols_dep, wayland_private_dep, wayland_util_dep, mathlib_dep, @@ -222,6 +236,7 @@ if get_option('libraries') description: 'Wayland client side library', version: meson.project_version(), filebase: 'wayland-client', + libraries: '-lwayland-core-protocols', variables: [ 'datarootdir=' + join_paths('${prefix}', get_option('datadir')), 'pkgdatadir=' + join_paths('${datarootdir}', meson.project_name()) diff --git a/tests/meson.build b/tests/meson.build index 2e11af4e..740f1a21 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -22,7 +22,8 @@ test_runner_dep = declare_dependency( include_directories: [ src_inc ], dependencies: [ dependency('threads'), - cc.find_library('dl', required: false) + cc.find_library('dl', required: false), + wayland_core_protocols_dep ] )