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