0004-build-Avoid-the-doctemplates-hack.patch 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. From 0504b26ec2adb13dfdff51679d84ad2f69af5918 Mon Sep 17 00:00:00 2001
  2. From: Emmanuele Bassi <ebassi@gnome.org>
  3. Date: Tue, 11 Jan 2022 15:51:10 +0000
  4. Subject: [PATCH] build: Avoid the doctemplates hack
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The hack that copies the doctemplates directory into the build
  9. directory has stopped working with newer versions of Meson; while it's
  10. possible to copy files, custom_target() cannot depend on a directory.
  11. Additionally, the dependency has always been broken.
  12. Instead, we enumerate the template files—after all, it's not like they
  13. change a lot—and then we list them as dependencies for the test targets.
  14. Fixes: #414
  15. Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
  16. [james.hilliard1@gmail.com: backport from upstream commit
  17. effb1e09dee263cdac4ec593e8caf316e6f01fe2]
  18. ---
  19. giscanner/doctemplates/devdocs/meson.build | 19 +++++++
  20. giscanner/doctemplates/mallard/meson.build | 63 ++++++++++++++++++++++
  21. giscanner/meson.build | 14 ++---
  22. tests/scanner/meson.build | 24 +++++----
  23. 4 files changed, 98 insertions(+), 22 deletions(-)
  24. create mode 100644 giscanner/doctemplates/devdocs/meson.build
  25. create mode 100644 giscanner/doctemplates/mallard/meson.build
  26. diff --git a/giscanner/doctemplates/devdocs/meson.build b/giscanner/doctemplates/devdocs/meson.build
  27. new file mode 100644
  28. index 00000000..2037182a
  29. --- /dev/null
  30. +++ b/giscanner/doctemplates/devdocs/meson.build
  31. @@ -0,0 +1,19 @@
  32. +doc_templates += files([
  33. + 'Gjs/_doc.tmpl',
  34. + 'Gjs/_index.tmpl',
  35. + 'Gjs/_method.tmpl',
  36. + 'Gjs/_methods.tmpl',
  37. + 'Gjs/_properties.tmpl',
  38. + 'Gjs/_signals.tmpl',
  39. + 'Gjs/_staticmethods.tmpl',
  40. + 'Gjs/_vfuncs.tmpl',
  41. + 'Gjs/base.tmpl',
  42. + 'Gjs/callback.tmpl',
  43. + 'Gjs/class.tmpl',
  44. + 'Gjs/default.tmpl',
  45. + 'Gjs/enum.tmpl',
  46. + 'Gjs/function.tmpl',
  47. + 'Gjs/interface.tmpl',
  48. + 'Gjs/method.tmpl',
  49. + 'Gjs/namespace.tmpl',
  50. +])
  51. diff --git a/giscanner/doctemplates/mallard/meson.build b/giscanner/doctemplates/mallard/meson.build
  52. new file mode 100644
  53. index 00000000..5fe4e2af
  54. --- /dev/null
  55. +++ b/giscanner/doctemplates/mallard/meson.build
  56. @@ -0,0 +1,63 @@
  57. +base_templates = files([
  58. + 'base.tmpl',
  59. + 'class.tmpl',
  60. + 'namespace.tmpl',
  61. +])
  62. +
  63. +c_templates = files([
  64. + 'C/callback.tmpl',
  65. + 'C/class.tmpl',
  66. + 'C/constructor.tmpl',
  67. + 'C/default.tmpl',
  68. + 'C/enum.tmpl',
  69. + 'C/field.tmpl',
  70. + 'C/function.tmpl',
  71. + 'C/interface.tmpl',
  72. + 'C/method.tmpl',
  73. + 'C/namespace.tmpl',
  74. + 'C/property.tmpl',
  75. + 'C/record.tmpl',
  76. + 'C/signal.tmpl',
  77. + 'C/vfunc.tmpl',
  78. +])
  79. +
  80. +gjs_templates = files([
  81. + 'Gjs/callback.tmpl',
  82. + 'Gjs/class.tmpl',
  83. + 'Gjs/constructor.tmpl',
  84. + 'Gjs/default.tmpl',
  85. + 'Gjs/enum.tmpl',
  86. + 'Gjs/field.tmpl',
  87. + 'Gjs/function.tmpl',
  88. + 'Gjs/interface.tmpl',
  89. + 'Gjs/method.tmpl',
  90. + 'Gjs/namespace.tmpl',
  91. + 'Gjs/property.tmpl',
  92. + 'Gjs/record.tmpl',
  93. + 'Gjs/signal.tmpl',
  94. + 'Gjs/vfunc.tmpl',
  95. +])
  96. +
  97. +py_templates = files([
  98. + 'Python/callback.tmpl',
  99. + 'Python/class.tmpl',
  100. + 'Python/constructor.tmpl',
  101. + 'Python/default.tmpl',
  102. + 'Python/enum.tmpl',
  103. + 'Python/field.tmpl',
  104. + 'Python/function.tmpl',
  105. + 'Python/interface.tmpl',
  106. + 'Python/method.tmpl',
  107. + 'Python/namespace.tmpl',
  108. + 'Python/property.tmpl',
  109. + 'Python/record.tmpl',
  110. + 'Python/signal.tmpl',
  111. + 'Python/vfunc.tmpl',
  112. +])
  113. +
  114. +doc_templates += [
  115. + base_templates,
  116. + c_templates,
  117. + gjs_templates,
  118. + py_templates,
  119. +]
  120. diff --git a/giscanner/meson.build b/giscanner/meson.build
  121. index 41edcd44..3d7dc678 100644
  122. --- a/giscanner/meson.build
  123. +++ b/giscanner/meson.build
  124. @@ -53,17 +53,9 @@ configure_file(input : '../girepository/gdump.c',
  125. install_subdir('doctemplates', install_dir: giscannerdir)
  126. -# XXX: this doesn't track the input, but there is nothing to copy many files
  127. -# in meson.
  128. -doc_templates = custom_target('copy-templates',
  129. - input : 'doctemplates',
  130. - output : 'doctemplates',
  131. - command : [
  132. - python, '-c',
  133. - 'import sys, shutil;' +
  134. - 'shutil.rmtree(sys.argv[2], ignore_errors=True);' +
  135. - 'shutil.copytree(sys.argv[1], sys.argv[2])',
  136. - '@INPUT@', '@OUTPUT@'])
  137. +doc_templates = []
  138. +subdir('doctemplates/devdocs')
  139. +subdir('doctemplates/mallard')
  140. flex = find_program('flex', 'win_flex')
  141. bison = find_program('bison', 'win_bison')
  142. diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
  143. index 5176b957..b81b3fd5 100644
  144. --- a/tests/scanner/meson.build
  145. +++ b/tests/scanner/meson.build
  146. @@ -525,19 +525,26 @@ foreach gir : test_girs
  147. endforeach
  148. if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
  149. + doctool_env = environment()
  150. + doctool_env.set('srcdir', meson.current_source_dir())
  151. + doctool_env.set('builddir', meson.current_build_dir())
  152. +
  153. foreach language : ['C', 'Python', 'Gjs']
  154. regress_docs = custom_target(
  155. 'generate-docs-' + language,
  156. input: regress_gir,
  157. - depends: [doc_templates],
  158. + depend_files: doc_templates,
  159. build_by_default: not cairo_deps_found,
  160. + env: doctool_env,
  161. output: 'Regress-1.0-' + language,
  162. command: [
  163. python, girdoctool,
  164. '--add-include-path=' + join_paths(build_root, 'gir'),
  165. '--add-include-path=' + meson.current_build_dir(),
  166. '--language', language,
  167. - '@INPUT@', '-o', '@OUTPUT@'],
  168. + '--templates-dir=' + join_paths(meson.current_source_dir(), '../../giscanner/doctemplates'),
  169. + '@INPUT@', '-o', '@OUTPUT@',
  170. + ],
  171. )
  172. if cairo_deps_found
  173. @@ -546,10 +553,7 @@ if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
  174. python,
  175. args: [gi_tester, 'Regress-1.0-' + language],
  176. depends: [regress_docs],
  177. - env: [
  178. - 'srcdir=' + meson.current_source_dir(),
  179. - 'builddir=' + meson.current_build_dir(),
  180. - ],
  181. + env: doctool_env,
  182. )
  183. endif
  184. endforeach
  185. @@ -557,9 +561,10 @@ if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
  186. regress_sections = custom_target(
  187. 'generate-docs-sections',
  188. input: regress_gir,
  189. - depends: [doc_templates],
  190. + depend_files: [doc_templates],
  191. build_by_default: not cairo_deps_found,
  192. output: 'Regress-1.0-sections.txt',
  193. + env: doctool_env,
  194. command: [
  195. python, girdoctool,
  196. '--add-include-path=' + join_paths(build_root, 'gir'),
  197. @@ -574,10 +579,7 @@ if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
  198. python,
  199. args: [gi_tester, 'Regress-1.0-sections.txt'],
  200. depends: [regress_sections],
  201. - env: [
  202. - 'srcdir=' + meson.current_source_dir(),
  203. - 'builddir=' + meson.current_build_dir(),
  204. - ],
  205. + env: doctool_env,
  206. )
  207. endif
  208. endif
  209. --
  210. 2.25.1