Blame SOURCES/0001-build-Avoid-the-doctemplates-hack.patch

d6fca2
From effb1e09dee263cdac4ec593e8caf316e6f01fe2 Mon Sep 17 00:00:00 2001
d6fca2
From: Emmanuele Bassi <ebassi@gnome.org>
d6fca2
Date: Tue, 11 Jan 2022 15:51:10 +0000
d6fca2
Subject: [PATCH] build: Avoid the doctemplates hack
d6fca2
MIME-Version: 1.0
d6fca2
Content-Type: text/plain; charset=UTF-8
d6fca2
Content-Transfer-Encoding: 8bit
d6fca2
d6fca2
The hack that copies the doctemplates directory into the build
d6fca2
directory has stopped working with newer versions of Meson; while it's
d6fca2
possible to copy files, custom_target() cannot depend on a directory.
d6fca2
Additionally, the dependency has always been broken.
d6fca2
d6fca2
Instead, we enumerate the template files—after all, it's not like they
d6fca2
change a lot—and then we list them as dependencies for the test targets.
d6fca2
d6fca2
Fixes: #414
d6fca2
---
d6fca2
 giscanner/doctemplates/devdocs/meson.build | 19 +++++++
d6fca2
 giscanner/doctemplates/mallard/meson.build | 63 ++++++++++++++++++++++
d6fca2
 giscanner/meson.build                      | 14 ++---
d6fca2
 tests/scanner/meson.build                  | 24 +++++----
d6fca2
 4 files changed, 98 insertions(+), 22 deletions(-)
d6fca2
 create mode 100644 giscanner/doctemplates/devdocs/meson.build
d6fca2
 create mode 100644 giscanner/doctemplates/mallard/meson.build
d6fca2
d6fca2
diff --git a/giscanner/doctemplates/devdocs/meson.build b/giscanner/doctemplates/devdocs/meson.build
d6fca2
new file mode 100644
d6fca2
index 00000000..2037182a
d6fca2
--- /dev/null
d6fca2
+++ b/giscanner/doctemplates/devdocs/meson.build
d6fca2
@@ -0,0 +1,19 @@
d6fca2
+doc_templates += files([
d6fca2
+  'Gjs/_doc.tmpl',
d6fca2
+  'Gjs/_index.tmpl',
d6fca2
+  'Gjs/_method.tmpl',
d6fca2
+  'Gjs/_methods.tmpl',
d6fca2
+  'Gjs/_properties.tmpl',
d6fca2
+  'Gjs/_signals.tmpl',
d6fca2
+  'Gjs/_staticmethods.tmpl',
d6fca2
+  'Gjs/_vfuncs.tmpl',
d6fca2
+  'Gjs/base.tmpl',
d6fca2
+  'Gjs/callback.tmpl',
d6fca2
+  'Gjs/class.tmpl',
d6fca2
+  'Gjs/default.tmpl',
d6fca2
+  'Gjs/enum.tmpl',
d6fca2
+  'Gjs/function.tmpl',
d6fca2
+  'Gjs/interface.tmpl',
d6fca2
+  'Gjs/method.tmpl',
d6fca2
+  'Gjs/namespace.tmpl',
d6fca2
+])
d6fca2
diff --git a/giscanner/doctemplates/mallard/meson.build b/giscanner/doctemplates/mallard/meson.build
d6fca2
new file mode 100644
d6fca2
index 00000000..5fe4e2af
d6fca2
--- /dev/null
d6fca2
+++ b/giscanner/doctemplates/mallard/meson.build
d6fca2
@@ -0,0 +1,63 @@
d6fca2
+base_templates = files([
d6fca2
+  'base.tmpl',
d6fca2
+  'class.tmpl',
d6fca2
+  'namespace.tmpl',
d6fca2
+])
d6fca2
+
d6fca2
+c_templates = files([
d6fca2
+  'C/callback.tmpl',
d6fca2
+  'C/class.tmpl',
d6fca2
+  'C/constructor.tmpl',
d6fca2
+  'C/default.tmpl',
d6fca2
+  'C/enum.tmpl',
d6fca2
+  'C/field.tmpl',
d6fca2
+  'C/function.tmpl',
d6fca2
+  'C/interface.tmpl',
d6fca2
+  'C/method.tmpl',
d6fca2
+  'C/namespace.tmpl',
d6fca2
+  'C/property.tmpl',
d6fca2
+  'C/record.tmpl',
d6fca2
+  'C/signal.tmpl',
d6fca2
+  'C/vfunc.tmpl',
d6fca2
+])
d6fca2
+
d6fca2
+gjs_templates = files([
d6fca2
+  'Gjs/callback.tmpl',
d6fca2
+  'Gjs/class.tmpl',
d6fca2
+  'Gjs/constructor.tmpl',
d6fca2
+  'Gjs/default.tmpl',
d6fca2
+  'Gjs/enum.tmpl',
d6fca2
+  'Gjs/field.tmpl',
d6fca2
+  'Gjs/function.tmpl',
d6fca2
+  'Gjs/interface.tmpl',
d6fca2
+  'Gjs/method.tmpl',
d6fca2
+  'Gjs/namespace.tmpl',
d6fca2
+  'Gjs/property.tmpl',
d6fca2
+  'Gjs/record.tmpl',
d6fca2
+  'Gjs/signal.tmpl',
d6fca2
+  'Gjs/vfunc.tmpl',
d6fca2
+])
d6fca2
+
d6fca2
+py_templates = files([
d6fca2
+  'Python/callback.tmpl',
d6fca2
+  'Python/class.tmpl',
d6fca2
+  'Python/constructor.tmpl',
d6fca2
+  'Python/default.tmpl',
d6fca2
+  'Python/enum.tmpl',
d6fca2
+  'Python/field.tmpl',
d6fca2
+  'Python/function.tmpl',
d6fca2
+  'Python/interface.tmpl',
d6fca2
+  'Python/method.tmpl',
d6fca2
+  'Python/namespace.tmpl',
d6fca2
+  'Python/property.tmpl',
d6fca2
+  'Python/record.tmpl',
d6fca2
+  'Python/signal.tmpl',
d6fca2
+  'Python/vfunc.tmpl',
d6fca2
+])
d6fca2
+
d6fca2
+doc_templates += [
d6fca2
+  base_templates,
d6fca2
+  c_templates,
d6fca2
+  gjs_templates,
d6fca2
+  py_templates,
d6fca2
+]
d6fca2
diff --git a/giscanner/meson.build b/giscanner/meson.build
d6fca2
index 41edcd44..3d7dc678 100644
d6fca2
--- a/giscanner/meson.build
d6fca2
+++ b/giscanner/meson.build
d6fca2
@@ -53,17 +53,9 @@ configure_file(input : '../girepository/gdump.c',
d6fca2
 
d6fca2
 install_subdir('doctemplates', install_dir: giscannerdir)
d6fca2
 
d6fca2
-# XXX: this doesn't track the input, but there is nothing to copy many files
d6fca2
-# in meson.
d6fca2
-doc_templates = custom_target('copy-templates',
d6fca2
-  input : 'doctemplates',
d6fca2
-  output : 'doctemplates',
d6fca2
-  command : [
d6fca2
-    python, '-c',
d6fca2
-      'import sys, shutil;' +
d6fca2
-      'shutil.rmtree(sys.argv[2], ignore_errors=True);' +
d6fca2
-      'shutil.copytree(sys.argv[1], sys.argv[2])',
d6fca2
-    '@INPUT@', '@OUTPUT@'])
d6fca2
+doc_templates = []
d6fca2
+subdir('doctemplates/devdocs')
d6fca2
+subdir('doctemplates/mallard')
d6fca2
 
d6fca2
 flex = find_program('flex', 'win_flex')
d6fca2
 bison = find_program('bison', 'win_bison')
d6fca2
diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
d6fca2
index 5176b957..b81b3fd5 100644
d6fca2
--- a/tests/scanner/meson.build
d6fca2
+++ b/tests/scanner/meson.build
d6fca2
@@ -525,19 +525,26 @@ foreach gir : test_girs
d6fca2
 endforeach
d6fca2
 
d6fca2
 if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
d6fca2
+  doctool_env = environment()
d6fca2
+  doctool_env.set('srcdir', meson.current_source_dir())
d6fca2
+  doctool_env.set('builddir', meson.current_build_dir())
d6fca2
+
d6fca2
   foreach language : ['C', 'Python', 'Gjs']
d6fca2
     regress_docs = custom_target(
d6fca2
       'generate-docs-' + language,
d6fca2
       input: regress_gir,
d6fca2
-      depends: [doc_templates],
d6fca2
+      depend_files: doc_templates,
d6fca2
       build_by_default: not cairo_deps_found,
d6fca2
+      env: doctool_env,
d6fca2
       output: 'Regress-1.0-' + language,
d6fca2
       command: [
d6fca2
         python, girdoctool,
d6fca2
         '--add-include-path=' + join_paths(build_root, 'gir'),
d6fca2
         '--add-include-path=' + meson.current_build_dir(),
d6fca2
         '--language', language,
d6fca2
-        '@INPUT@', '-o', '@OUTPUT@'],
d6fca2
+        '--templates-dir=' + join_paths(meson.current_source_dir(), '../../giscanner/doctemplates'),
d6fca2
+        '@INPUT@', '-o', '@OUTPUT@',
d6fca2
+      ],
d6fca2
     )
d6fca2
 
d6fca2
     if cairo_deps_found
d6fca2
@@ -546,10 +553,7 @@ if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
d6fca2
         python,
d6fca2
         args: [gi_tester, 'Regress-1.0-' + language],
d6fca2
         depends: [regress_docs],
d6fca2
-        env: [
d6fca2
-          'srcdir=' + meson.current_source_dir(),
d6fca2
-          'builddir=' + meson.current_build_dir(),
d6fca2
-        ],
d6fca2
+        env: doctool_env,
d6fca2
       )
d6fca2
     endif
d6fca2
   endforeach
d6fca2
@@ -557,9 +561,10 @@ if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
d6fca2
   regress_sections = custom_target(
d6fca2
     'generate-docs-sections',
d6fca2
     input: regress_gir,
d6fca2
-    depends: [doc_templates],
d6fca2
+    depend_files: [doc_templates],
d6fca2
     build_by_default: not cairo_deps_found,
d6fca2
     output: 'Regress-1.0-sections.txt',
d6fca2
+    env: doctool_env,
d6fca2
     command: [
d6fca2
       python, girdoctool,
d6fca2
       '--add-include-path=' + join_paths(build_root, 'gir'),
d6fca2
@@ -574,10 +579,7 @@ if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
d6fca2
       python,
d6fca2
       args: [gi_tester, 'Regress-1.0-sections.txt'],
d6fca2
       depends: [regress_sections],
d6fca2
-      env: [
d6fca2
-        'srcdir=' + meson.current_source_dir(),
d6fca2
-        'builddir=' + meson.current_build_dir(),
d6fca2
-      ],
d6fca2
+      env: doctool_env,
d6fca2
     )
d6fca2
   endif
d6fca2
 endif
d6fca2
-- 
d6fca2
2.37.3
d6fca2