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