meson.build 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. configh_data.set10('HAVE_TOOLS', true)
  2. tools_dep = declare_dependency(
  3. include_directories: include_directories(
  4. '..', # required to #include "config.h" in subdirs
  5. '../include',
  6. '../src',
  7. '.',
  8. ),
  9. link_with: tools_shared_lib,
  10. dependencies: dep_libxkbcommon,
  11. )
  12. # Tool: export-keysyms
  13. export_keysym_dep = [tools_dep]
  14. if icu_dep.found()
  15. export_keysym_dep += [icu_dep]
  16. endif
  17. executable(
  18. 'export-keysyms',
  19. 'export-keysyms.c',
  20. link_with: libxkbcommon_test_internal,
  21. dependencies: export_keysym_dep,
  22. install: false,
  23. )
  24. # Tool: xkbcli
  25. executable(
  26. 'xkbcli',
  27. 'xkbcli.c',
  28. dependencies: tools_dep,
  29. install: true,
  30. )
  31. install_man('xkbcli.1')
  32. if get_option('enable-bash-completion')
  33. bash_completion_path = get_option('bash-completion-path')
  34. if bash_completion_path == ''
  35. bash_completion = dependency('bash-completion', required: false)
  36. if bash_completion.found()
  37. bash_completion_path = bash_completion.get_variable(
  38. pkgconfig: 'completionsdir',
  39. )
  40. else
  41. bash_completion_path = get_option('datadir') / 'bash-completion' / 'completions'
  42. endif
  43. endif
  44. install_data(
  45. 'xkbcli-bash-completion.sh',
  46. rename: 'xkbcli',
  47. install_dir: bash_completion_path,
  48. )
  49. endif
  50. if get_option('enable-zsh-completion')
  51. zsh_completion_path = get_option('zsh-completion-path')
  52. if zsh_completion_path == ''
  53. zsh_completion_path = get_option('datadir') / 'zsh' / 'site-functions'
  54. endif
  55. install_data(
  56. 'xkbcli-zsh-completion.zsh',
  57. rename: '_xkbcli',
  58. install_dir: zsh_completion_path,
  59. )
  60. install_data(
  61. 'xkb-model-zsh-completion.zsh',
  62. rename: '_xkb_model',
  63. install_dir: zsh_completion_path,
  64. )
  65. install_data(
  66. 'xkb-layout-zsh-completion.zsh',
  67. rename: '_xkb_layout',
  68. install_dir: zsh_completion_path,
  69. )
  70. install_data(
  71. 'xkb-variant-zsh-completion.zsh',
  72. rename: '_xkb_variant',
  73. install_dir: zsh_completion_path,
  74. )
  75. install_data(
  76. 'xkb-options-zsh-completion.zsh',
  77. rename: '_xkb_options',
  78. install_dir: zsh_completion_path,
  79. )
  80. endif
  81. # Tool: info
  82. executable(
  83. 'xkbcli-info',
  84. 'info.c',
  85. dependencies: tools_dep,
  86. install: true,
  87. install_dir: dir_libexec,
  88. )
  89. install_man('xkbcli-info.1')
  90. configh_data.set10('HAVE_XKBCLI_INFO', true)
  91. # Tool: compile-keymap
  92. xkbcli_compile_keymap = executable(
  93. 'xkbcli-compile-keymap',
  94. 'compile-keymap.c',
  95. dependencies: tools_dep,
  96. install: true,
  97. install_dir: dir_libexec,
  98. )
  99. install_man('xkbcli-compile-keymap.1')
  100. configh_data.set10('HAVE_XKBCLI_COMPILE_KEYMAP', true)
  101. # Tool: compose
  102. executable(
  103. 'xkbcli-compile-compose',
  104. 'compile-compose.c',
  105. '../src/compose/dump.c',
  106. dependencies: tools_dep,
  107. install: true,
  108. install_dir: dir_libexec,
  109. )
  110. install_man('xkbcli-compile-compose.1')
  111. configh_data.set10('HAVE_XKBCLI_COMPILE_COMPOSE', true)
  112. # Tool: how-to-type
  113. executable(
  114. 'xkbcli-how-to-type',
  115. 'how-to-type.c',
  116. dependencies: tools_dep,
  117. install: true,
  118. install_dir: dir_libexec,
  119. )
  120. install_man('xkbcli-how-to-type.1')
  121. configh_data.set10('HAVE_XKBCLI_HOW_TO_TYPE', true)
  122. # Tool: interactive-evdev
  123. if cc.has_header('linux/input.h')
  124. executable(
  125. 'xkbcli-interactive-evdev',
  126. 'interactive-evdev.c',
  127. dependencies: tools_dep,
  128. install: true,
  129. install_dir: dir_libexec,
  130. )
  131. configh_data.set10('HAVE_XKBCLI_INTERACTIVE_EVDEV', true)
  132. install_man('xkbcli-interactive-evdev.1')
  133. endif
  134. # Tools: interactive-x11
  135. if get_option('enable-x11')
  136. x11_tools_dep = declare_dependency(
  137. link_with: libxkbcommon_x11,
  138. dependencies: [
  139. tools_dep,
  140. xcb_dep,
  141. xcb_xkb_dep,
  142. ],
  143. )
  144. executable(
  145. 'xkbcli-interactive-x11',
  146. 'interactive-x11.c',
  147. dependencies: x11_tools_dep,
  148. install: true,
  149. install_dir: dir_libexec,
  150. )
  151. install_man('xkbcli-interactive-x11.1')
  152. configh_data.set10('HAVE_XKBCLI_INTERACTIVE_X11', true)
  153. executable(
  154. 'xkbcli-dump-keymap-x11',
  155. 'interactive-x11.c',
  156. dependencies: x11_tools_dep,
  157. c_args: ['-DKEYMAP_DUMP'],
  158. install: true,
  159. install_dir: dir_libexec,
  160. )
  161. install_man('xkbcli-dump-keymap-x11.1')
  162. configh_data.set10('HAVE_XKBCLI_DUMP_KEYMAP_X11', true)
  163. endif
  164. # Tools: interactive-wayland
  165. if get_option('enable-wayland')
  166. wayland_client_dep = dependency(
  167. 'wayland-client',
  168. version: '>=1.2.0',
  169. required: false,
  170. )
  171. wayland_protocols_dep = dependency(
  172. 'wayland-protocols',
  173. version: '>=1.15',
  174. required: false,
  175. )
  176. wayland_scanner_dep = dependency(
  177. 'wayland-scanner',
  178. required: false,
  179. native: true,
  180. )
  181. if not wayland_client_dep.found() or not wayland_protocols_dep.found() or not wayland_scanner_dep.found()
  182. error(
  183. '''The Wayland xkbcli programs require wayland-client and wayland-protocols which were not found.
  184. You can disable the Wayland xkbcli programs with -Denable-wayland=false.''',
  185. )
  186. endif
  187. if cc.has_header_symbol('wayland/wayland-client-protocol.h', \
  188. 'WL_KEYBOARD_KEY_STATE_REPEATED', \
  189. dependencies: wayland_client_dep)
  190. configh_data.set10('HAVE_WL_KEYBOARD_KEY_STATE_REPEATED', true)
  191. endif
  192. wayland_scanner = find_program(
  193. wayland_scanner_dep.get_variable(pkgconfig: 'wayland_scanner'),
  194. )
  195. wayland_scanner_code_gen = generator(
  196. wayland_scanner,
  197. output: '@BASENAME@-protocol.c',
  198. arguments: ['private-code', '@INPUT@', '@OUTPUT@'],
  199. )
  200. wayland_scanner_client_header_gen = generator(
  201. wayland_scanner,
  202. output: '@BASENAME@-client-protocol.h',
  203. arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
  204. )
  205. wayland_protocols_datadir = wayland_protocols_dep.get_variable(
  206. pkgconfig: 'pkgdatadir',
  207. )
  208. xdg_shell_xml = wayland_protocols_datadir / 'stable' / 'xdg-shell' / 'xdg-shell.xml'
  209. xdg_shell_sources = [
  210. wayland_scanner_code_gen.process(xdg_shell_xml),
  211. wayland_scanner_client_header_gen.process(xdg_shell_xml),
  212. ]
  213. xdg_decoration_xml = wayland_protocols_datadir / 'unstable' / 'xdg-decoration' / 'xdg-decoration-unstable-v1.xml'
  214. xdg_decoration_sources = [
  215. wayland_scanner_code_gen.process(xdg_decoration_xml),
  216. wayland_scanner_client_header_gen.process(xdg_decoration_xml),
  217. ]
  218. executable(
  219. 'xkbcli-interactive-wayland',
  220. 'interactive-wayland.c',
  221. xdg_shell_sources,
  222. xdg_decoration_sources,
  223. dependencies: [tools_dep, wayland_client_dep],
  224. install: true,
  225. install_dir: dir_libexec,
  226. )
  227. install_man('xkbcli-interactive-wayland.1')
  228. configh_data.set10('HAVE_XKBCLI_INTERACTIVE_WAYLAND', true)
  229. executable(
  230. 'xkbcli-dump-keymap-wayland',
  231. 'interactive-wayland.c',
  232. xdg_shell_sources,
  233. xdg_decoration_sources,
  234. dependencies: [tools_dep, wayland_client_dep],
  235. c_args: ['-DKEYMAP_DUMP'],
  236. install: true,
  237. install_dir: dir_libexec,
  238. )
  239. install_man('xkbcli-dump-keymap-wayland.1')
  240. configh_data.set10('HAVE_XKBCLI_DUMP_KEYMAP_WAYLAND', true)
  241. endif
  242. # Tool: interactive
  243. if (
  244. configh_data.get('HAVE_XKBCLI_INTERACTIVE_WAYLAND', 0) == 1
  245. or configh_data.get('HAVE_XKBCLI_INTERACTIVE_X11', 0) == 1
  246. or configh_data.get('HAVE_XKBCLI_INTERACTIVE_EVDEV', 0) == 1
  247. )
  248. executable(
  249. 'xkbcli-interactive',
  250. 'interactive.c',
  251. dependencies: tools_dep,
  252. install: true,
  253. install_dir: dir_libexec,
  254. )
  255. endif
  256. # Tool: dump-keymap
  257. if (
  258. configh_data.get('HAVE_XKBCLI_DUMP_KEYMAP_WAYLAND', 0) == 1
  259. or configh_data.get('HAVE_XKBCLI_DUMP_KEYMAP_X11', 0) == 1
  260. )
  261. executable(
  262. 'xkbcli-dump-keymap',
  263. 'interactive.c',
  264. c_args: ['-DKEYMAP_DUMP'],
  265. dependencies: tools_dep,
  266. install: true,
  267. install_dir: dir_libexec,
  268. )
  269. endif
  270. # Tool: list
  271. if get_option('enable-xkbregistry')
  272. configh_data.set10('HAVE_XKBCLI_LIST', true)
  273. executable(
  274. 'xkbcli-list',
  275. 'registry-list.c',
  276. dependencies: dep_libxkbregistry,
  277. include_directories: ['..', '.'],
  278. install: true,
  279. install_dir: dir_libexec,
  280. )
  281. install_man('xkbcli-list.1')
  282. endif
  283. # Tool: check-messages
  284. executable(
  285. 'xkb-check-messages',
  286. 'check-messages.c',
  287. 'messages.c',
  288. '../src/utils.c',
  289. dependencies: [tools_dep],
  290. install: false,
  291. )
  292. # Tool: introspection
  293. executable(
  294. 'introspection',
  295. 'introspection.c',
  296. '../src/utils.c',
  297. link_with: libxkbcommon_test_internal,
  298. dependencies: [tools_dep],
  299. install: false,
  300. )
  301. introspection_config = configuration_data()
  302. introspection_config.set('MESON_BUILD_ROOT', meson.current_build_dir())
  303. introspection_config.set('DEFAULT_XKB_RULES', get_option('default-rules'))
  304. introspection_config.set('DEFAULT_XKB_MODEL', get_option('default-model'))
  305. introspection_config.set('DEFAULT_XKB_LAYOUT', get_option('default-layout'))
  306. introspection_config.set(
  307. 'DEFAULT_XKB_VARIANT',
  308. get_option('default-variant'),
  309. )
  310. introspection_config.set(
  311. 'DEFAULT_XKB_OPTIONS',
  312. get_option('default-options'),
  313. )
  314. configure_file(
  315. input: 'introspection-query.py.in',
  316. output: 'introspection-query',
  317. configuration: introspection_config,
  318. )