Update examples to use new option

We use a dictionary to remove some code duplication.
master
Scott Anderson 6 years ago
parent 560e96aa57
commit 584a3f8b6e

@ -1,80 +1,102 @@
threads = dependency('threads') threads = dependency('threads')
wayland_cursor = dependency('wayland-cursor') wayland_cursor = dependency('wayland-cursor')
libpng = dependency('libpng', required: false) libpng = dependency('libpng', required: false)
# These versions correspond to ffmpeg 4.0 # These versions correspond to ffmpeg 4.0
libavutil = dependency('libavutil', version: '>=56.14.100', required: false) libavutil = dependency('libavutil', version: '>=56.14.100', required: false)
libavcodec = dependency('libavcodec', version: '>=58.18.100', required: false) libavcodec = dependency('libavcodec', version: '>=58.18.100', required: false)
libavformat = dependency('libavformat', version: '>=58.12.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) if not cc.has_header('libavutil/hwcontext_drm.h', dependencies: libavutil)
libavutil = disabler() libavutil = disabler()
endif endif
executable('simple', 'simple.c', dependencies: wlroots) examples = {
executable('pointer', 'pointer.c', dependencies: wlroots) 'simple': {
executable('touch', 'touch.c', 'cat.c', dependencies: wlroots) 'src': 'simple.c',
executable('tablet', 'tablet.c', dependencies: wlroots) 'dep': wlroots,
executable('rotation', 'rotation.c', 'cat.c', dependencies: wlroots) },
executable('multi-pointer', 'multi-pointer.c', dependencies: wlroots) 'pointer': {
executable('output-layout', 'output-layout.c', 'cat.c', dependencies: wlroots) 'src': 'pointer.c',
'dep': wlroots,
executable( },
'screenshot', 'touch': {
'screenshot.c', 'src': ['touch.c', 'cat.c'],
dependencies: [wayland_client, wlr_protos, wlroots] 'dep': wlroots,
) },
'tablet': {
executable( 'src': 'tablet.c',
'idle', 'dep': wlroots,
'idle.c', },
dependencies: [wayland_client, wlr_protos, wlroots, threads] 'rotation': {
) 'src': ['rotation.c', 'cat.c'],
'dep': wlroots,
executable( },
'idle-inhibit', 'multi-pointer': {
'idle-inhibit.c', 'src': 'multi-pointer.c',
dependencies: [wayland_client, wlr_protos, wlroots, threads] 'dep': wlroots,
) },
'output-layout': {
executable( 'src': ['output-layout.c', 'cat.c'],
'layer-shell', 'dep': wlroots,
'layer-shell.c', },
dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots] 'screenshot': {
) 'src': 'screenshot.c',
'dep': [wayland_client, wlr_protos, wlroots],
executable( },
'input-inhibitor', 'idle': {
'input-inhibitor.c', 'src': 'idle.c',
dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots] '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( foreach name, info : examples
'gamma-control',
'gamma-control.c',
dependencies: [wayland_cursor, wayland_client, wlr_protos, wlroots]
)
if libavutil.found() and libavcodec.found() and libavformat.found()
executable( executable(
'dmabuf-capture', name,
'dmabuf-capture.c', info.get('src'),
dependencies: [wayland_client, wlr_protos, libavutil, libavcodec, dependencies: info.get('dep'),
libavformat, wlroots, threads ] build_by_default: get_option('examples'),
) )
endif endforeach
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]
)

@ -160,11 +160,7 @@ summary = [
] ]
message('\n'.join(summary)) message('\n'.join(summary))
subdir('examples')
if get_option('enable-examples')
subdir('examples')
endif
subdir('rootston') subdir('rootston')
pkgconfig = import('pkgconfig') pkgconfig = import('pkgconfig')

@ -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('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', 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('logind-provider', type: 'combo', choices: ['systemd', 'elogind'], value: 'systemd', description: 'Provider of logind support library')

Loading…
Cancel
Save