meson.build 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. # Sphinx build
  2. sphinx = find_program('sphinx-build-3', 'sphinx-build', required : false)
  3. if not sphinx.found()
  4. error('Program "sphinx-build" not found or not executable. Try building with -Ddocumentation=false')
  5. endif
  6. yq = find_program('yq', required : false)
  7. if not yq.found()
  8. warning('Program "yq" not found or not executable. Dependency list will not be built.')
  9. endif
  10. sphinx_config = configuration_data()
  11. sphinx_config.set('PROJECT_NAME', meson.project_name())
  12. sphinx_config.set('PROJECT_VERSION', meson.project_version())
  13. sphinx_config.set('BUILDDIR', meson.current_build_dir())
  14. sphinx_config.set('HTTP_DOC_LINK', doc_url)
  15. git_version_page = vcs_tag(command : ['git', 'log', '-1', '--format=%H'],
  16. fallback : 'unknown',
  17. input : 'git_version.py.in',
  18. output : 'git_version.py',
  19. replace_string: '__GIT_VERSION__')
  20. sphinx_conf_py = configure_file(input : 'conf.py.in',
  21. output : 'conf.py',
  22. configuration : sphinx_config)
  23. # 404 replacements for old URLs
  24. # The switch to sphinx caused a few pages to be renamed, sphinx uses
  25. # filename.html whereas doxygen used whatever the @page foo was. So old docs
  26. # *mostly* used underscores, now we're consistent with dashes.
  27. # We can't use htaccess on the server, so let's auto-generate a 404 list
  28. # with a basic page telling users that the link has moved. This can be
  29. # removed in a few months, towards the end of 2018.
  30. #
  31. # File list is: [current-sphinx-input-file, old-generated-page]
  32. # If they're the same they'll be ignored.
  33. src_404s = [
  34. [ 'absolute-axes.rst', 'absolute_axes.html'],
  35. [ 'absolute-coordinate-ranges.rst', 'absolute_coordinate_ranges.html'],
  36. [ 'architecture.rst', 'architecture.html'],
  37. [ 'building.rst', 'building_libinput.html'],
  38. [ 'button-debouncing.rst', 'button_debouncing.html'],
  39. [ 'clickpad-softbuttons.rst', 'clickpad_softbuttons.html'],
  40. [ 'configuration.rst', 'config_options.html'],
  41. [ 'contributing.rst', 'contributing.html'],
  42. [ 'development.rst', 'development.html'],
  43. [ 'device-configuration-via-udev.rst', 'udev_config.html'],
  44. [ 'device-quirks.rst', 'device-quirks.html'],
  45. [ 'faqs.rst', 'faq.html'],
  46. [ 'features.rst', 'features.html'],
  47. [ 'gestures.rst', 'gestures.html'],
  48. [ 'incorrectly-enabled-hires.rst', 'incorrectly-enabled-hires.html'],
  49. [ 'middle-button-emulation.rst', 'middle_button_emulation.html'],
  50. [ 'normalization-of-relative-motion.rst', 'motion_normalization.html'],
  51. [ 'palm-detection.rst', 'palm_detection.html'],
  52. [ 'pointer-acceleration.rst', 'pointer-acceleration.html'],
  53. [ 'reporting-bugs.rst', 'reporting_bugs.html'],
  54. [ 'scrolling.rst', 'scrolling.html'],
  55. [ 'seats.rst', 'seats.html'],
  56. [ 'switches.rst', 'switches.html'],
  57. [ 't440-support.rst', 't440_support.html'],
  58. [ 'tablet-support.rst', 'tablet-support.html'],
  59. [ 'tapping.rst', 'tapping.html'],
  60. [ 'test-suite.rst', 'test-suite.html'],
  61. [ 'timestamps.rst', 'timestamps.html'],
  62. [ 'tools.rst', 'tools.html'],
  63. [ 'touchpad-jitter.rst', 'touchpad_jitter.html'],
  64. [ 'touchpad-jumping-cursors.rst', 'touchpad_jumping_cursor.html'],
  65. [ 'touchpad-pressure.rst', 'touchpad_pressure.html'],
  66. [ 'touchpads.rst', 'touchpads.html'],
  67. [ 'trackpoints.rst', 'trackpoints.html'],
  68. [ 'troubleshooting.rst', 'troubleshooting.html'],
  69. [ 'what-is-libinput.rst', 'what_is_libinput.html'],
  70. ]
  71. dst_404s = []
  72. foreach s404 : src_404s
  73. target = s404[0]
  74. oldpage = s404[1]
  75. tname = target.split('.rst')[0]
  76. oname = oldpage.split('.html')[0]
  77. if tname != oname
  78. config_404 = configuration_data()
  79. config_404.set('TARGET', '@0@.html'.format(tname))
  80. c = configure_file(input : '404.rst',
  81. output : '@0@.rst'.format(oname),
  82. configuration : config_404)
  83. dst_404s += [c]
  84. endif
  85. endforeach
  86. src_rst = files(
  87. # dot drawings
  88. 'dot/seats-sketch.gv',
  89. 'dot/seats-sketch-libinput.gv',
  90. 'dot/libinput-contexts.gv',
  91. 'dot/libinput-stack-wayland.gv',
  92. 'dot/libinput-stack-xorg.gv',
  93. 'dot/libinput-stack-gnome.gv',
  94. 'dot/evemu.gv',
  95. 'dot/libinput-record.gv',
  96. 'dot/plugin-stack.gv',
  97. # svgs
  98. 'svg/button-debouncing-wave-diagram.svg',
  99. 'svg/button-scrolling.svg',
  100. 'svg/clickfinger.svg',
  101. 'svg/clickfinger-distance.svg',
  102. 'svg/edge-scrolling.svg',
  103. 'svg/gesture-2fg-ambiguity.svg',
  104. 'svg/palm-detection.svg',
  105. 'svg/pinch-gestures.svg',
  106. 'svg/pinch-gestures-softbuttons.svg',
  107. 'svg/ptraccel-custom.svg',
  108. 'svg/ptraccel-linear.svg',
  109. 'svg/ptraccel-low-dpi.svg',
  110. 'svg/ptraccel-touchpad.svg',
  111. 'svg/ptraccel-trackpoint.svg',
  112. 'svg/software-buttons.svg',
  113. 'svg/software-buttons-conditions.svg',
  114. 'svg/software-buttons-thumbpress.svg',
  115. 'svg/software-buttons-visualized.svg',
  116. 'svg/swipe-gestures.svg',
  117. 'svg/tablet-area.svg',
  118. 'svg/tablet-axes.svg',
  119. 'svg/tablet-cintiq24hd-modes.svg',
  120. 'svg/tablet-eraser-invert.svg',
  121. 'svg/tablet-eraser-button.svg',
  122. 'svg/tablet-interfaces.svg',
  123. 'svg/tablet-intuos-modes.svg',
  124. 'svg/tablet-left-handed.svg',
  125. 'svg/tablet-out-of-bounds.svg',
  126. 'svg/tablet-touch-arbitration.svg',
  127. 'svg/tablet.svg',
  128. 'svg/tap-n-drag.svg',
  129. 'svg/thumb-detection.svg',
  130. 'svg/top-software-buttons.svg',
  131. 'svg/touchscreen-gestures.svg',
  132. 'svg/trackpoint-delta-illustration.svg',
  133. 'svg/twofinger-scrolling.svg',
  134. # rst files
  135. 'absolute-axes.rst',
  136. 'absolute-coordinate-ranges.rst',
  137. 'architecture.rst',
  138. 'building.rst',
  139. 'button-debouncing.rst',
  140. 'clickpad-softbuttons.rst',
  141. 'clickpad-with-right-button.rst',
  142. 'contributing.rst',
  143. 'device-configuration-via-udev.rst',
  144. 'device-quirks.rst',
  145. 'drag-3fg.rst',
  146. 'faqs.rst',
  147. 'gestures.rst',
  148. 'incorrectly-enabled-hires.rst',
  149. 'ignoring-devices.rst',
  150. 'middle-button-emulation.rst',
  151. 'normalization-of-relative-motion.rst',
  152. 'palm-detection.rst',
  153. 'lua-plugins.rst',
  154. 'pointer-acceleration.rst',
  155. 'reporting-bugs.rst',
  156. 'scrolling.rst',
  157. 'seats.rst',
  158. 'switches.rst',
  159. 't440-support.rst',
  160. 'tablet-support.rst',
  161. 'tapping.rst',
  162. 'test-suite.rst',
  163. 'timestamps.rst',
  164. 'tablet-debugging.rst',
  165. 'tools.rst',
  166. 'touchpad-jumping-cursors.rst',
  167. 'touchpad-pressure.rst',
  168. 'touchpad-pressure-debugging.rst',
  169. 'touchpad-jitter.rst',
  170. 'touchpad-thumb-detection.rst',
  171. 'touchpads.rst',
  172. 'trackpoints.rst',
  173. 'trackpoint-configuration.rst',
  174. 'what-is-libinput.rst',
  175. 'wheel-api.rst',
  176. 'features.rst',
  177. 'development.rst',
  178. 'troubleshooting.rst',
  179. 'configuration.rst',
  180. )
  181. src_sphinx = []
  182. foreach f : src_rst
  183. sf = configure_file(input: f,
  184. output: '@PLAINNAME@',
  185. copy : true)
  186. src_sphinx += [ sf ]
  187. endforeach
  188. configure_file(input: 'index.rst',
  189. output: 'index.rst',
  190. configuration: sphinx_config)
  191. dependencies_config = configuration_data()
  192. if yq.found()
  193. distributions = ['fedora', 'ubuntu', 'debian', 'arch', 'alpine']
  194. foreach distro : distributions
  195. yq_filter = '.distributions[] | select(.name == "@0@") | .packages | join(" ")'.format(distro)
  196. deps = run_command(yq, '-r', yq_filter,
  197. dir_gitlab_ci / 'config.yml',
  198. check: true).stdout()
  199. dependencies_config.set('@0@_PACKAGES'.format(distro.to_upper()), deps)
  200. endforeach
  201. endif
  202. configure_file(input: 'dependencies.rst',
  203. output: 'dependencies.rst',
  204. configuration: dependencies_config)
  205. # do not use -j, it breaks on Ubuntu
  206. sphinx_output_dir = 'Documentation'
  207. custom_target('sphinx',
  208. input : [ sphinx_conf_py, git_version_page ] + src_sphinx + dst_404s,
  209. output : [ sphinx_output_dir ],
  210. command : [ sphinx, '-q', '-b', 'html',
  211. '-d', meson.current_build_dir() / 'doctrees',
  212. meson.current_build_dir(), sphinx_output_dir],
  213. build_by_default : true)