test: include unstd.h in the registry test to cut down the MacOS warnings
[platform/upstream/libxkbcommon.git] / meson.build
1 project(
2     'libxkbcommon',
3     'c',
4     version: '1.0.0',
5     default_options: [
6         'c_std=c99',
7         'warning_level=2',
8         'b_lundef=true',
9     ],
10     meson_version : '>= 0.49.0',
11 )
12 pkgconfig = import('pkgconfig')
13 cc = meson.get_compiler('c')
14
15 dir_libexec = get_option('prefix')/get_option('libexecdir')/'xkbcommon'
16
17 # Compiler flags.
18 cflags = [
19     '-fno-strict-aliasing',
20     '-fsanitize-undefined-trap-on-error',
21     '-Wno-unused-parameter',
22     '-Wno-missing-field-initializers',
23     '-Wpointer-arith',
24     '-Wmissing-declarations',
25     '-Wformat=2',
26     '-Wstrict-prototypes',
27     '-Wmissing-prototypes',
28     '-Wnested-externs',
29     '-Wbad-function-cast',
30     '-Wshadow',
31     '-Wlogical-op',
32     '-Wdate-time',
33     '-Wwrite-strings',
34     '-Wno-documentation-deprecated-sync',
35 ]
36 add_project_arguments(cc.get_supported_arguments(cflags), language: 'c')
37
38
39 # The XKB config root.
40 XKBCONFIGROOT = get_option('xkb-config-root')
41 if XKBCONFIGROOT == ''
42     xkeyboard_config_dep = dependency('xkeyboard-config', required: false)
43     if xkeyboard_config_dep.found()
44         XKBCONFIGROOT = xkeyboard_config_dep.get_pkgconfig_variable('xkb_base')
45     else
46         XKBCONFIGROOT = get_option('prefix')/get_option('datadir')/'X11'/'xkb'
47   endif
48 endif
49
50 XKBCONFIGEXTRAPATH = get_option('xkb-config-extra-path')
51 if XKBCONFIGEXTRAPATH == ''
52     XKBCONFIGEXTRAPATH = join_paths(get_option('prefix'), get_option('sysconfdir'), 'xkb')
53 endif
54
55 # The X locale directory for compose.
56 XLOCALEDIR = get_option('x-locale-root')
57 if XLOCALEDIR == ''
58     XLOCALEDIR = get_option('prefix')/get_option('datadir')/'X11'/'locale'
59 endif
60
61
62 # config.h.
63 configh_data = configuration_data()
64 configh_data.set('EXIT_INVALID_USAGE', '2')
65 configh_data.set_quoted('LIBXKBCOMMON_VERSION', meson.project_version())
66 configh_data.set_quoted('LIBXKBCOMMON_TOOL_PATH', dir_libexec)
67 # Like AC_USE_SYSTEM_EXTENSIONS, what #define to use to get extensions
68 # beyond the base POSIX function set.
69 if host_machine.system() == 'sunos'
70   system_extensions = '__EXTENSIONS__'
71 else
72   system_extensions = '_GNU_SOURCE'
73 endif
74 configh_data.set(system_extensions, 1)
75 system_ext_define = '#define ' + system_extensions
76 configh_data.set_quoted('DFLT_XKB_CONFIG_ROOT', XKBCONFIGROOT)
77 configh_data.set_quoted('DFLT_XKB_CONFIG_EXTRA_PATH', XKBCONFIGEXTRAPATH)
78 configh_data.set_quoted('XLOCALEDIR', XLOCALEDIR)
79 configh_data.set_quoted('DEFAULT_XKB_RULES', get_option('default-rules'))
80 configh_data.set_quoted('DEFAULT_XKB_MODEL', get_option('default-model'))
81 configh_data.set_quoted('DEFAULT_XKB_LAYOUT', get_option('default-layout'))
82 if get_option('default-variant') != ''
83     configh_data.set_quoted('DEFAULT_XKB_VARIANT', get_option('default-variant'))
84 else
85     configh_data.set('DEFAULT_XKB_VARIANT', 'NULL')
86 endif
87 if get_option('default-options') != ''
88     configh_data.set_quoted('DEFAULT_XKB_OPTIONS', get_option('default-options'))
89 else
90     configh_data.set('DEFAULT_XKB_OPTIONS', 'NULL')
91 endif
92 if cc.has_header('unistd.h')
93     configh_data.set('HAVE_UNISTD_H', 1)
94 endif
95 if cc.links('int main(){if(__builtin_expect(1<0,0)){}}', name: '__builtin_expect')
96     configh_data.set('HAVE___BUILTIN_EXPECT', 1)
97 endif
98 if cc.has_header_symbol('unistd.h', 'eaccess', prefix: system_ext_define)
99     configh_data.set('HAVE_EACCESS', 1)
100 endif
101 if cc.has_header_symbol('unistd.h', 'euidaccess', prefix: system_ext_define)
102     configh_data.set('HAVE_EUIDACCESS', 1)
103 endif
104 if cc.has_header_symbol('sys/mman.h', 'mmap')
105     configh_data.set('HAVE_MMAP', 1)
106 endif
107 if cc.has_header_symbol('stdlib.h', 'mkostemp', prefix: system_ext_define)
108     configh_data.set('HAVE_MKOSTEMP', 1)
109 endif
110 if cc.has_header_symbol('fcntl.h', 'posix_fallocate', prefix: system_ext_define)
111     configh_data.set('HAVE_POSIX_FALLOCATE', 1)
112 endif
113 if cc.has_header_symbol('string.h', 'strndup', prefix: system_ext_define)
114     configh_data.set('HAVE_STRNDUP', 1)
115 endif
116 if cc.has_header_symbol('stdio.h', 'asprintf', prefix: system_ext_define)
117     configh_data.set('HAVE_ASPRINTF', 1)
118 elif cc.has_header_symbol('stdio.h', 'vasprintf', prefix: system_ext_define)
119     configh_data.set('HAVE_VASPRINTF', 1)
120 endif
121 if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix: system_ext_define)
122     configh_data.set('HAVE_SECURE_GETENV', 1)
123 elif cc.has_header_symbol('stdlib.h', '__secure_getenv', prefix: system_ext_define)
124     configh_data.set('HAVE___SECURE_GETENV', 1)
125 else
126     message('C library does not support secure_getenv, using getenv instead')
127 endif
128 have_getopt_long = cc.has_header_symbol('getopt.h', 'getopt_long',
129                                         prefix: '#define _GNU_SOURCE')
130 if not cc.has_header_symbol('limits.h', 'PATH_MAX', prefix: system_ext_define)
131     if host_machine.system() == 'windows'
132         # see https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation
133         configh_data.set('PATH_MAX', 260)
134     else
135         configh_data.set('PATH_MAX', 4096)
136     endif
137 endif
138
139 # Silence some security & deprecation warnings on MSVC
140 # for some unix/C functions we use.
141 # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=vs-2019
142 configh_data.set('_CRT_SECURE_NO_WARNINGS', 1)
143 configh_data.set('_CRT_NONSTDC_NO_WARNINGS', 1)
144 configh_data.set('_CRT_NONSTDC_NO_DEPRECATE', 1)
145 # Reduce unnecessary includes on MSVC.
146 configh_data.set('WIN32_LEAN_AND_MEAN', 1)
147
148 # Supports -Wl,--version-script?
149 have_version_script = cc.links(
150     'int main(){}',
151     args: '-Wl,--version-script=' + meson.source_root()/'xkbcommon.map',
152     name: '-Wl,--version-script',
153 )
154
155
156 # libxkbcommon.
157 # Note: we use some yacc extensions, which work with either GNU bison
158 # (preferred) or byacc (with backtracking enabled).
159 bison = find_program('bison', 'win_bison', required: false)
160 if bison.found()
161     yacc_gen = generator(
162         bison,
163         output: ['@BASENAME@.c', '@BASENAME@.h'],
164         arguments: ['--defines=@OUTPUT1@', '-o', '@OUTPUT0@', '-p', '_xkbcommon_', '@INPUT@'],
165     )
166 else
167     byacc = find_program('byacc', required: false)
168     if byacc.found()
169         yacc_gen = generator(
170             byacc,
171             output: ['@BASENAME@.c', '@BASENAME@.h'],
172             arguments: ['-H', '@OUTPUT1@', '-o', '@OUTPUT0@', '-p', '_xkbcommon_', '@INPUT@'],
173         )
174     else
175         error('Could not find a compatible YACC program (bison or byacc)')
176     endif
177 endif
178 libxkbcommon_sources = [
179     'src/compose/parser.c',
180     'src/compose/parser.h',
181     'src/compose/paths.c',
182     'src/compose/paths.h',
183     'src/compose/state.c',
184     'src/compose/table.c',
185     'src/compose/table.h',
186     'src/xkbcomp/action.c',
187     'src/xkbcomp/action.h',
188     'src/xkbcomp/ast.h',
189     'src/xkbcomp/ast-build.c',
190     'src/xkbcomp/ast-build.h',
191     'src/xkbcomp/compat.c',
192     'src/xkbcomp/expr.c',
193     'src/xkbcomp/expr.h',
194     'src/xkbcomp/include.c',
195     'src/xkbcomp/include.h',
196     'src/xkbcomp/keycodes.c',
197     'src/xkbcomp/keymap.c',
198     'src/xkbcomp/keymap-dump.c',
199     'src/xkbcomp/keywords.c',
200     yacc_gen.process('src/xkbcomp/parser.y'),
201     'src/xkbcomp/parser-priv.h',
202     'src/xkbcomp/rules.c',
203     'src/xkbcomp/rules.h',
204     'src/xkbcomp/scanner.c',
205     'src/xkbcomp/symbols.c',
206     'src/xkbcomp/types.c',
207     'src/xkbcomp/vmod.c',
208     'src/xkbcomp/vmod.h',
209     'src/xkbcomp/xkbcomp.c',
210     'src/xkbcomp/xkbcomp-priv.h',
211     'src/atom.c',
212     'src/atom.h',
213     'src/context.c',
214     'src/context.h',
215     'src/context-priv.c',
216     'src/darray.h',
217     'src/keysym.c',
218     'src/keysym.h',
219     'src/keysym-utf.c',
220     'src/ks_tables.h',
221     'src/keymap.c',
222     'src/keymap.h',
223     'src/keymap-priv.c',
224     'src/scanner-utils.h',
225     'src/state.c',
226     'src/text.c',
227     'src/text.h',
228     'src/utf8.c',
229     'src/utf8.h',
230     'src/utils.c',
231     'src/utils.h',
232 ]
233 libxkbcommon_link_args = []
234 if have_version_script
235     libxkbcommon_link_args += '-Wl,--version-script=' + meson.source_root()/'xkbcommon.map'
236 endif
237 libxkbcommon = library(
238     'xkbcommon',
239     'xkbcommon/xkbcommon.h',
240     libxkbcommon_sources,
241     link_args: libxkbcommon_link_args,
242     link_depends: 'xkbcommon.map',
243     gnu_symbol_visibility: 'hidden',
244     version: '0.0.0',
245     install: true,
246     include_directories: include_directories('src'),
247 )
248 install_headers(
249     'xkbcommon/xkbcommon.h',
250     'xkbcommon/xkbcommon-compat.h',
251     'xkbcommon/xkbcommon-compose.h',
252     'xkbcommon/xkbcommon-keysyms.h',
253     'xkbcommon/xkbcommon-names.h',
254     subdir: 'xkbcommon',
255 )
256 libxkbcommon_dep = declare_dependency(
257     link_with: libxkbcommon,
258 )
259 pkgconfig.generate(
260     libxkbcommon,
261     name: 'xkbcommon',
262     filebase: 'xkbcommon',
263     version: meson.project_version(),
264     description: 'XKB API common to servers and clients',
265 )
266
267
268 # libxkbcommon-x11.
269 if get_option('enable-x11')
270     xcb_dep = dependency('xcb', version: '>=1.10', required: false)
271     xcb_xkb_dep = dependency('xcb-xkb', version: '>=1.10', required: false)
272     if not xcb_dep.found() or not xcb_xkb_dep.found()
273         error('''X11 support requires xcb-xkb >= 1.10 which was not found.
274 You can disable X11 support with -Denable-x11=false.''')
275     endif
276
277     libxkbcommon_x11_sources = [
278         'src/x11/keymap.c',
279         'src/x11/state.c',
280         'src/x11/util.c',
281         'src/x11/x11-priv.h',
282         'src/context.h',
283         'src/context-priv.c',
284         'src/keymap.h',
285         'src/keymap-priv.c',
286         'src/atom.h',
287         'src/atom.c',
288     ]
289     libxkbcommon_x11_link_args = []
290     if have_version_script
291         libxkbcommon_x11_link_args += '-Wl,--version-script=' + meson.source_root()/'xkbcommon-x11.map'
292     endif
293     libxkbcommon_x11 = library(
294         'xkbcommon-x11',
295         'xkbcommon/xkbcommon-x11.h',
296         libxkbcommon_x11_sources,
297         link_args: libxkbcommon_x11_link_args,
298         link_depends: 'xkbcommon-x11.map',
299         gnu_symbol_visibility: 'hidden',
300         version: '0.0.0',
301         install: true,
302         include_directories: include_directories('src'),
303         link_with: libxkbcommon,
304         dependencies: [
305             xcb_dep,
306             xcb_xkb_dep,
307         ],
308     )
309     install_headers(
310         'xkbcommon/xkbcommon-x11.h',
311         subdir: 'xkbcommon',
312     )
313     libxkbcommon_x11_dep = declare_dependency(
314         link_with: libxkbcommon_x11,
315     )
316     pkgconfig.generate(
317         libxkbcommon_x11,
318         name: 'xkbcommon-x11',
319         filebase: 'xkbcommon-x11',
320         version: meson.project_version(),
321         description: 'XKB API common to servers and clients - X11 support',
322         requires: ['xkbcommon'],
323         requires_private: ['xcb>=1.10', 'xcb-xkb>=1.10'],
324     )
325 endif
326
327 # libxkbregistry
328 if get_option('enable-xkbregistry')
329     dep_libxml = dependency('libxml-2.0')
330     deps_libxkbregistry = [dep_libxml]
331     libxkbregistry_sources = [
332         'src/registry.c',
333         'src/utils.h',
334         'src/utils.c',
335         'src/util-list.h',
336         'src/util-list.c',
337     ]
338     libxkbregistry_link_args = []
339     if have_version_script
340         libxkbregistry_link_args += '-Wl,--version-script=' + meson.source_root()/'xkbregistry.map'
341     endif
342     libxkbregistry = library(
343         'xkbregistry',
344         'xkbcommon/xkbregistry.h',
345         libxkbregistry_sources,
346         link_args: libxkbregistry_link_args,
347         link_depends: 'xkbregistry.map',
348         gnu_symbol_visibility: 'hidden',
349         dependencies: deps_libxkbregistry,
350         version: '0.0.0',
351         install: true,
352         include_directories: include_directories('src'),
353     )
354     install_headers(
355         'xkbcommon/xkbregistry.h',
356         subdir: 'xkbcommon',
357     )
358     pkgconfig.generate(
359         libxkbregistry,
360         name: 'xkbregistry',
361         filebase: 'xkbregistry',
362         version: meson.project_version(),
363         description: 'XKB API to query available rules, models, layouts, variants and options',
364     )
365
366     dep_libxkbregistry = declare_dependency(
367                                 include_directories: include_directories('xkbcommon'),
368                                 link_with: libxkbregistry
369                                 )
370 endif
371
372 # Tests
373 test_env = environment()
374 test_env.set('XKB_LOG_LEVEL', 'debug')
375 test_env.set('XKB_LOG_VERBOSITY', '10')
376 test_env.set('top_srcdir', meson.source_root())
377 test_env.set('top_builddir', meson.build_root())
378
379 test_configh_data = configuration_data()
380 test_configh_data.set_quoted('TEST_XKB_CONFIG_ROOT', meson.source_root()/'test'/'data')
381 configure_file(output: 'test-config.h', configuration: test_configh_data)
382
383 # Some tests need to use unexported symbols, so we link them against
384 # an internal copy of libxkbcommon with all symbols exposed.
385 libxkbcommon_test_internal = static_library(
386     'xkbcommon-test-internal',
387     'test/common.c',
388     'test/test.h',
389     'test/evdev-scancodes.h',
390     libxkbcommon_sources,
391     include_directories: include_directories('src'),
392 )
393 test_dep = declare_dependency(
394     include_directories: include_directories('src'),
395     link_with: libxkbcommon_test_internal,
396 )
397 if get_option('enable-x11')
398     libxkbcommon_x11_internal = static_library(
399         'xkbcommon-x11-internal',
400         libxkbcommon_x11_sources,
401         include_directories: include_directories('src'),
402         link_with: libxkbcommon_test_internal,
403         dependencies: [
404             xcb_dep,
405             xcb_xkb_dep,
406         ],
407     )
408     x11_test_dep = declare_dependency(
409         link_with: libxkbcommon_x11_internal,
410         dependencies: [
411             test_dep,
412             xcb_dep,
413             xcb_xkb_dep,
414         ],
415     )
416 endif
417 test(
418     'keysym',
419     executable('test-keysym', 'test/keysym.c', dependencies: test_dep),
420     env: test_env,
421 )
422 test(
423     'keymap',
424     executable('test-keymap', 'test/keymap.c', dependencies: test_dep),
425     env: test_env,
426 )
427 test(
428     'filecomp',
429     executable('test-filecomp', 'test/filecomp.c', dependencies: test_dep),
430     env: test_env,
431 )
432 # TODO: This test currently uses some functions that don't exist on Windows.
433 if cc.get_id() != 'msvc'
434   test(
435       'context',
436       executable('test-context', 'test/context.c', dependencies: test_dep),
437       env: test_env,
438   )
439 endif
440 test(
441     'rules-file',
442     executable('test-rules-file', 'test/rules-file.c', dependencies: test_dep),
443     env: test_env,
444 )
445 test(
446     'rules-file-includes',
447     executable('test-rules-file-includes', 'test/rules-file-includes.c', dependencies: test_dep),
448     env: test_env,
449 )
450 test(
451     'stringcomp',
452     executable('test-stringcomp', 'test/stringcomp.c', dependencies: test_dep),
453     env: test_env,
454 )
455 test(
456     'buffercomp',
457     executable('test-buffercomp', 'test/buffercomp.c', dependencies: test_dep),
458     env: test_env,
459 )
460 test(
461     'log',
462     executable('test-log', 'test/log.c', dependencies: test_dep),
463     env: test_env,
464 )
465 test(
466     'atom',
467     executable('test-atom', 'test/atom.c', dependencies: test_dep),
468     env: test_env,
469 )
470 test(
471     'utf8',
472     executable('test-utf8', 'test/utf8.c', dependencies: test_dep),
473     env: test_env,
474 )
475 test(
476     'state',
477     executable('test-state', 'test/state.c', dependencies: test_dep),
478     env: test_env,
479 )
480 test(
481     'keyseq',
482     executable('test-keyseq', 'test/keyseq.c', dependencies: test_dep),
483     env: test_env,
484 )
485 test(
486     'rulescomp',
487     executable('test-rulescomp', 'test/rulescomp.c', dependencies: test_dep),
488     env: test_env,
489 )
490 test(
491     'compose',
492     executable('test-compose', 'test/compose.c', dependencies: test_dep),
493     env: test_env,
494 )
495 test(
496     'utils',
497     executable('test-utils', 'test/utils.c', dependencies: test_dep),
498     env: test_env,
499 )
500 test(
501     'symbols-leak-test',
502     find_program('test/symbols-leak-test.py'),
503     env: test_env,
504     suite: ['python-tests'],
505 )
506 if get_option('enable-x11')
507     test(
508         'x11',
509         executable('test-x11', 'test/x11.c', dependencies: x11_test_dep),
510         env: test_env,
511     )
512     # test/x11comp is meant to be run, but it is (temporarily?) disabled.
513     # See: https://github.com/xkbcommon/libxkbcommon/issues/30
514     executable('test-x11comp', 'test/x11comp.c', dependencies: x11_test_dep)
515 endif
516 if get_option('enable-xkbregistry')
517     test(
518         'registry',
519         executable('test-registry', 'test/registry.c',
520                    include_directories: include_directories('src'),
521                    dependencies: dep_libxkbregistry),
522         env: test_env,
523     )
524 endif
525
526 valgrind = find_program('valgrind', required: false)
527 if valgrind.found()
528     add_test_setup('valgrind',
529         exe_wrapper: [valgrind,
530                        '--leak-check=full',
531                        '--track-origins=yes',
532                        '--gen-suppressions=all',
533                        '--error-exitcode=99'],
534         timeout_multiplier : 10)
535 else
536     message('valgrind not found, disabling valgrind test setup')
537 endif
538
539
540 # Fuzzing target programs.
541 executable('fuzz-keymap', 'fuzz/keymap/target.c', dependencies: test_dep)
542 executable('fuzz-compose', 'fuzz/compose/target.c', dependencies: test_dep)
543
544 man_pages = []
545
546 # Tools
547 build_tools = have_getopt_long
548 if build_tools
549     libxkbcommon_tools_internal = static_library(
550         'tools-internal',
551         'tools/tools-common.h',
552         'tools/tools-common.c',
553         dependencies: libxkbcommon_dep,
554     )
555     tools_dep = declare_dependency(
556         include_directories: [include_directories('tools')],
557         link_with: libxkbcommon_tools_internal,
558     )
559
560     executable('xkbcli', 'tools/xkbcli.c',
561                dependencies: tools_dep, install: true)
562     install_man('tools/xkbcli.1')
563
564     executable('xkbcli-compile-keymap',
565                'tools/compile-keymap.c',
566                dependencies: tools_dep,
567                install: true,
568                install_dir: dir_libexec)
569     install_man('tools/xkbcli-compile-keymap.1')
570     # The same tool again, but with access to some private APIs.
571     executable('compile-keymap',
572                'tools/compile-keymap.c',
573                libxkbcommon_sources,
574                dependencies: [tools_dep],
575                c_args: ['-DENABLE_PRIVATE_APIS'],
576                include_directories: [include_directories('src')],
577                install: false)
578     configh_data.set10('HAVE_XKBCLI_COMPILE_KEYMAP', true)
579     executable('xkbcli-how-to-type',
580                'tools/how-to-type.c',
581                dependencies: tools_dep,
582                install: true,
583                install_dir: dir_libexec)
584     install_man('tools/xkbcli-how-to-type.1')
585     configh_data.set10('HAVE_XKBCLI_HOW_TO_TYPE', true)
586     if cc.has_header('linux/input.h')
587         executable('xkbcli-interactive-evdev',
588                    'tools/interactive-evdev.c',
589                    dependencies: tools_dep,
590                    install: true,
591                    install_dir: dir_libexec)
592         configh_data.set10('HAVE_XKBCLI_INTERACTIVE_EVDEV', true)
593         install_man('tools/xkbcli-interactive-evdev.1')
594     endif
595     if get_option('enable-x11')
596         x11_tools_dep = declare_dependency(
597             link_with: libxkbcommon_x11,
598             dependencies: [
599                 tools_dep,
600                 xcb_dep,
601                 xcb_xkb_dep,
602             ],
603         )
604         executable('xkbcli-interactive-x11',
605                    'tools/interactive-x11.c',
606                    dependencies: x11_tools_dep,
607                    install: true,
608                    install_dir: dir_libexec)
609         install_man('tools/xkbcli-interactive-x11.1')
610         configh_data.set10('HAVE_XKBCLI_INTERACTIVE_X11', true)
611     endif
612     if get_option('enable-wayland')
613         wayland_client_dep = dependency('wayland-client', version: '>=1.2.0', required: false)
614         wayland_protocols_dep = dependency('wayland-protocols', version: '>=1.12', required: false)
615         wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true)
616         if not wayland_client_dep.found() or not wayland_protocols_dep.found() or not wayland_scanner_dep.found()
617             error('''The Wayland xkbcli programs require wayland-client >= 1.2.0, wayland-protocols >= 1.7 which were not found.
618 You can disable the Wayland xkbcli programs with -Denable-wayland=false.''')
619         endif
620
621         wayland_scanner = find_program(wayland_scanner_dep.get_pkgconfig_variable('wayland_scanner'))
622         wayland_scanner_code_gen = generator(
623             wayland_scanner,
624             output: '@BASENAME@-protocol.c',
625             arguments: ['code', '@INPUT@', '@OUTPUT@'],
626         )
627         wayland_scanner_client_header_gen = generator(
628             wayland_scanner,
629             output: '@BASENAME@-client-protocol.h',
630             arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
631         )
632         wayland_protocols_datadir = wayland_protocols_dep.get_pkgconfig_variable('pkgdatadir')
633         xdg_shell_xml = wayland_protocols_datadir/'stable/xdg-shell/xdg-shell.xml'
634         xdg_shell_sources = [
635             wayland_scanner_code_gen.process(xdg_shell_xml),
636             wayland_scanner_client_header_gen.process(xdg_shell_xml),
637         ]
638         executable('xkbcli-interactive-wayland',
639                    'tools/interactive-wayland.c',
640                    xdg_shell_sources,
641                    dependencies: [tools_dep, wayland_client_dep],
642                    install: true,
643                    install_dir: dir_libexec)
644         install_man('tools/xkbcli-interactive-wayland.1')
645         configh_data.set10('HAVE_XKBCLI_INTERACTIVE_WAYLAND', true)
646     endif
647
648     if get_option('enable-xkbregistry')
649         configh_data.set10('HAVE_XKBCLI_LIST', true)
650         executable('xkbcli-list',
651                    'tools/registry-list.c',
652                    dependencies: dep_libxkbregistry,
653                    install: true,
654                    install_dir: dir_libexec)
655         install_man('tools/xkbcli-list.1')
656     endif
657
658     test('tool-option-parsing',
659          find_program('test/tool-option-parsing.py'),
660          env: test_env,
661          suite: ['python-tests'])
662 endif
663
664
665 # xkeyboard-config "verifier"
666 xkct_config = configuration_data()
667 xkct_config.set('MESON_BUILD_ROOT', meson.build_root())
668 xkct_config.set('XKB_CONFIG_ROOT', XKBCONFIGROOT)
669 configure_file(input: 'test/xkeyboard-config-test.py.in',
670                output: 'xkeyboard-config-test',
671                configuration: xkct_config)
672
673
674 # Benchmarks.
675 libxkbcommon_bench_internal = static_library(
676     'xkbcommon-bench-internal',
677     'bench/bench.c',
678     'bench/bench.h',
679     link_with: libxkbcommon_test_internal,
680 )
681 bench_dep = declare_dependency(
682     include_directories: include_directories('src'),
683     link_with: libxkbcommon_bench_internal,
684 )
685 bench_env = environment()
686 bench_env.set('top_srcdir', meson.source_root())
687 benchmark(
688     'key-proc',
689     executable('bench-key-proc', 'bench/key-proc.c', dependencies: bench_dep),
690     env: bench_env,
691 )
692 benchmark(
693     'rules',
694     executable('bench-rules', 'bench/rules.c', dependencies: bench_dep),
695     env: bench_env,
696 )
697 benchmark(
698     'rulescomp',
699     executable('bench-rulescomp', 'bench/rulescomp.c', dependencies: bench_dep),
700     env: bench_env,
701 )
702 benchmark(
703     'compose',
704     executable('bench-compose', 'bench/compose.c', dependencies: bench_dep),
705     env: bench_env,
706 )
707
708
709 # Documentation.
710 if get_option('enable-docs')
711     doxygen = find_program('doxygen', required: false)
712     if not doxygen.found()
713         error('''Documentation requires doxygen which was not found.
714 You can disable the documentation with -Denable-docs=false.''')
715     endif
716     doxygen_wrapper = find_program('scripts/doxygen-wrapper')
717
718     doxygen_input = [
719         'README.md',
720         'doc/doxygen-extra.css',
721         'doc/quick-guide.md',
722         'doc/compat.md',
723         'doc/user-configuration.md',
724         'doc/rules-format.md',
725         'xkbcommon/xkbcommon.h',
726         'xkbcommon/xkbcommon-names.h',
727         'xkbcommon/xkbcommon-x11.h',
728         'xkbcommon/xkbcommon-compose.h',
729         'xkbcommon/xkbregistry.h',
730     ]
731     doxygen_data = configuration_data()
732     doxygen_data.set('PACKAGE_NAME', meson.project_name())
733     doxygen_data.set('PACKAGE_VERSION', meson.project_version())
734     doxygen_data.set('INPUT', ' '.join(doxygen_input))
735     doxygen_data.set('OUTPUT_DIRECTORY', meson.build_root())
736     doxyfile = configure_file(
737         input: 'doc/Doxyfile.in',
738         output: 'Doxyfile',
739         configuration: doxygen_data,
740     )
741     # TODO: Meson should provide this.
742     docdir = get_option('datadir')/'doc'/meson.project_name()
743     custom_target(
744         'doc',
745         input: [doxyfile] + doxygen_input,
746         output: 'html',
747         command: [doxygen_wrapper, doxygen.path(), meson.build_root()/'Doxyfile', meson.source_root()],
748         install: true,
749         install_dir: docdir,
750         build_by_default: true,
751     )
752 endif
753
754 configure_file(output: 'config.h', configuration: configh_data)