install_dir: libds_bindir,
install : true)
-executable('tdm-backend',
- 'tdm-backend.c',
- dependencies: common_deps,
- install_dir: libds_bindir,
- install : true)
-
executable('tinyds',
'tinyds.c',
dependencies: [
install_dir: libds_bindir,
install : true)
-executable('tinyds-tdm',
- ['tinyds-tdm.c', 'tinyds-helper.c'],
- dependencies: [
- common_deps,
- dependency('pixman-1', required: true),
- dependency('libdrm', required: true),
- dependency('libtbm', required: true),
- ],
- install_dir: libds_bindir,
- install : true)
+if features.get('tdm-backend')
+ executable('tdm-backend',
+ 'tdm-backend.c',
+ dependencies: common_deps,
+ install_dir: libds_bindir,
+ install : true)
+
+ executable('tinyds-tdm',
+ ['tinyds-tdm.c', 'tinyds-helper.c'],
+ dependencies: [
+ common_deps,
+ dependency('pixman-1', required: true),
+ dependency('libdrm', required: true),
+ dependency('libtbm', required: true),
+ ],
+ install_dir: libds_bindir,
+ install : true)
+endif
+exclude_files = []
+if not features.get('tdm-backend')
+ exclude_files += 'backend/tdm.h'
+endif
+
+if not features.get('tbm-allocator')
+ exclude_files += 'allocator/tbm.h'
+endif
+
install_subdir('libds',
- install_dir: get_option('includedir')
+ install_dir: get_option('includedir'),
+ exclude_files: exclude_files,
)
cdata.set('LIBDS_VERSION_MINOR', libds_version_minor)
cdata.set('LIBDS_VERSION_PATCH', libds_version_patch)
+features = {
+ 'tdm-backend': false,
+ 'tbm-allocator': false,
+}
subdir('include')
subdir('src')
configure_file(output: 'config.h', install: false, configuration: cdata)
-pkgconfig = import('pkgconfig')
-pkgconfig.generate(lib_libds,
- version: meson.project_version(),
- filebase: meson.project_name(),
- name: meson.project_name(),
- description: 'Wayland compositor library',
-)
+summary(features, bool_yn: true)
--- /dev/null
+option('backends', type: 'array', choices: ['auto', 'tdm'], value: ['auto'], description: 'Select built-in backends')
--- /dev/null
+#include <assert.h>
+#include <stdlib.h>
+#include <wayland-server.h>
+
+#include "libds/log.h"
+#include "libds/interfaces/allocator.h"
+
+WL_EXPORT void
+ds_allocator_init(struct ds_allocator *alloc,
+ const struct ds_allocator_interface *iface, uint32_t buffer_caps)
+{
+ alloc->iface = iface;
+ alloc->buffer_caps = buffer_caps;
+
+ wl_signal_init(&alloc->events.destroy);
+}
+
+WL_EXPORT void
+ds_allocator_destroy(struct ds_allocator *alloc)
+{
+ wl_signal_emit(&alloc->events.destroy, NULL);
+ alloc->iface->destroy(alloc);
+}
+
+WL_EXPORT struct ds_buffer *
+ds_allocator_create_buffer(struct ds_allocator *alloc, int width, int height,
+ uint32_t format)
+{
+ return alloc->iface->create_buffer(alloc, width, height, format);
+}
+
+WL_EXPORT void
+ds_allocator_add_destroy_listener(struct ds_allocator *alloc,
+ struct wl_listener *listener)
+{
+ wl_signal_add(&alloc->events.destroy, listener);
+}
+++ /dev/null
-#include <assert.h>
-#include <stdlib.h>
-#include <wayland-server.h>
-
-#include "libds/log.h"
-#include "libds/interfaces/allocator.h"
-
-WL_EXPORT void
-ds_allocator_init(struct ds_allocator *alloc,
- const struct ds_allocator_interface *iface, uint32_t buffer_caps)
-{
- alloc->iface = iface;
- alloc->buffer_caps = buffer_caps;
-
- wl_signal_init(&alloc->events.destroy);
-}
-
-WL_EXPORT void
-ds_allocator_destroy(struct ds_allocator *alloc)
-{
- wl_signal_emit(&alloc->events.destroy, NULL);
- alloc->iface->destroy(alloc);
-}
-
-WL_EXPORT struct ds_buffer *
-ds_allocator_create_buffer(struct ds_allocator *alloc, int width, int height,
- uint32_t format)
-{
- return alloc->iface->create_buffer(alloc, width, height, format);
-}
-
-WL_EXPORT void
-ds_allocator_add_destroy_listener(struct ds_allocator *alloc,
- struct wl_listener *listener)
-{
- wl_signal_add(&alloc->events.destroy, listener);
-}
--- /dev/null
+libds_files += files('shm.c')
+
+libtbm = dependency(
+ 'libtbm',
+ required: false,
+ not_found_message: 'Required for TBM allocator support.'
+)
+if libtbm.found()
+ libds_files += files('tbm.c')
+ libds_deps += libtbm
+ features += { 'tbm-allocator': true }
+endif
+all_backends = ['tdm']
+backends = get_option('backends')
+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('wayland')
-subdir('tdm')
+msg = ['Required for TDM backend support.']
+if 'tdm' in backends
+ msg += 'Install "libtdm" and "libtbm", or disable the tdm backend'
+endif
+
+libtdm = dependency(
+ 'libtdm',
+ required: 'tdm' in backends,
+ not_found_message: '\n'.join(msg)
+)
+
+libtbm = dependency(
+ 'libtbm',
+ required: 'tdm' in backends,
+ not_found_message: '\n'.join(msg)
+)
+
+if not libtdm.found() or not libtbm.found()
+ subdir_done()
+endif
+
libds_files += files(
'backend.c',
'output.c',
)
libds_deps += [
- dependency('libtdm', required: true),
+ libtdm,
+ libtbm
]
+
+features += { 'tdm-backend': true }
'log.c',
'addon.c',
'buffer.c',
- 'allocator/allocator.c',
- 'allocator/shm.c',
- 'allocator/tbm.c',
+ 'allocator.c',
'swapchain.c',
'output.c',
'compositor.c',
wayland_server = dependency('wayland-server', required: true)
pixman = dependency('pixman-1', required: true)
libdrm = dependency('libdrm', required: true)
-libtbm = dependency('libtbm', required: true)
libds_deps = [
math,
]
subdir('backend')
+subdir('allocator')
lib_libds = shared_library('ds', libds_files,
dependencies: libds_deps,
install: true
)
+ds_vars = {}
+foreach name, have : features
+ ds_vars += { 'have_' + name.underscorify(): have.to_string() }
+endforeach
+
dep_libds = declare_dependency(
link_with: lib_libds,
dependencies: libds_deps,
include_directories: [ common_inc, include_directories('.') ],
+ variables: ds_vars,
+)
+
+pkgconfig = import('pkgconfig')
+pkgconfig.generate(lib_libds,
+ version: meson.project_version(),
+ filebase: meson.project_name(),
+ name: meson.project_name(),
+ description: 'Wayland compositor library',
+ variables: ds_vars,
)