1project( 2 'wob', 3 'c', 4 version: '0.13', 5 license: 'ISC', 6 default_options: ['c_std=c99'] 7) 8 9cc = meson.get_compiler('c') 10 11wayland_protos = dependency('wayland-protocols', version: '>=1.13') 12wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir') 13wayland_scanner = find_program('wayland-scanner') 14wayland_client = dependency('wayland-client') 15rt = cc.find_library('rt') 16seccomp = dependency('libseccomp', required: get_option('seccomp')) 17 18wob_version = '"@0@"'.format(meson.project_version()) 19add_project_arguments('-DWOB_VERSION=@0@'.format(wob_version), language: 'c') 20 21wayland_scanner_code = generator( 22 wayland_scanner, 23 output: '@BASENAME@-protocol.c', 24 arguments: ['private-code', '@INPUT@', '@OUTPUT@'], 25) 26 27wayland_scanner_client = generator( 28 wayland_scanner, 29 output: '@BASENAME@-client-protocol.h', 30 arguments: ['client-header', '@INPUT@', '@OUTPUT@'], 31) 32 33client_protocols = [ 34 [wl_protocol_dir + '/stable/xdg-shell', 'xdg-shell.xml'], 35 [wl_protocol_dir + '/unstable/xdg-output', 'xdg-output-unstable-v1.xml'], 36 [meson.source_root() + '/protocols', 'wlr-layer-shell-unstable-v1.xml'], 37] 38 39foreach p : client_protocols 40 xml = join_paths(p) 41 src = wayland_scanner_code.process(xml) 42 header = wayland_scanner_client.process(xml) 43 44 name = p[1].split('.')[0].underscorify() 45 46 lib = static_library( 47 name, 48 [src, header], 49 dependencies: [wayland_client], 50 ) 51 52 dep = declare_dependency( 53 link_with: lib, 54 sources: header, 55 ) 56 57 set_variable(name, dep) 58endforeach 59 60wob_inc = include_directories('include') 61 62wob_sources = ['main.c', 'parse.c', 'buffer.c', 'log.c', 'color.c'] 63wob_dependencies = [xdg_output_unstable_v1, wayland_client, wlr_layer_shell_unstable_v1, xdg_shell, rt] 64if seccomp.found() 65 wob_dependencies += seccomp 66 wob_sources += 'pledge_seccomp.c' 67else 68 wob_sources += 'pledge.c' 69endif 70 71executable( 72 'wob', 73 wob_sources, 74 include_directories: [wob_inc], 75 dependencies: wob_dependencies, 76 install: true 77) 78 79test('parse-input', executable( 80 'test-parse-input', 81 ['tests/wob_parse_input.c', 'parse.c', 'color.c'], 82 include_directories: [wob_inc] 83)) 84 85scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages')) 86if scdoc.found() 87 scdoc = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true) 88 sh = find_program('sh', native: true) 89 mandir = get_option('mandir') 90 scdfile = 'wob.1.scd' 91 manfile = scdfile.split('.scd')[0] 92 93 custom_target( 94 manfile, 95 input: scdfile, 96 output: manfile, 97 command: [ 98 sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc.path(), manfile) 99 ], 100 install: true, 101 install_dir: join_paths(mandir, 'man1') 102 ) 103endif 104