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