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