[PATCH] meson: Detect rst2html5 and rst2man only when needed

Ivan Teterevkov posted 1 patch 1 week, 4 days ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20220113084056.57038-1-ivan.teterevkov@nutanix.com
docs/meson.build | 41 +++++++++++++++++++++++++++++++++++++++++
meson.build      | 31 -------------------------------
2 files changed, 41 insertions(+), 31 deletions(-)

[PATCH] meson: Detect rst2html5 and rst2man only when needed

Posted by Ivan Teterevkov 1 week, 4 days ago
Detect these commands in docs/meson.build, i.e. only when
users enable documentation.

Signed-off-by: Ivan Teterevkov <ivan.teterevkov@nutanix.com>
---
 docs/meson.build | 41 +++++++++++++++++++++++++++++++++++++++++
 meson.build      | 31 -------------------------------
 2 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/docs/meson.build b/docs/meson.build
index 3e912f21ad..50c12cc3c2 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -171,6 +171,47 @@ docs_lxc_api_xml = docs_api_generated[1]
 docs_qemu_api_xml = docs_api_generated[2]
 docs_admin_api_xml = docs_api_generated[3]
 
+docs_programs_groups = [
+  { 'name': 'rst2html5', 'prog': [ 'rst2html5', 'rst2html5.py', 'rst2html5-3' ] },
+  { 'name': 'rst2man', 'prog': [ 'rst2man', 'rst2man.py', 'rst2man-3' ] },
+]
+
+foreach item : docs_programs_groups
+  prog = find_program(item.get('prog'), dirs: libvirt_sbin_path)
+  varname = item.get('name').underscorify()
+  conf.set_quoted(varname.to_upper(), prog.path())
+  set_variable('@0@_prog'.format(varname), prog)
+endforeach
+
+# There are two versions of rst2html5 in the wild: one is the version
+# coming from the docutils package, and the other is the one coming
+# from the rst2html5 package. These versions are subtly different,
+# and the libvirt documentation can only be successfully generated
+# using the docutils version. Every now and then, users will report
+# build failures that can be traced back to having the wrong version
+# installed.
+#
+# The only reliable way to tell the two binaries apart seems to be
+# looking look at their version information: the docutils version
+# will report
+#
+#   rst2html5 (Docutils ..., Python ..., on ...)
+#
+# whereas the rst2html5 version will report
+#
+#   rst2html5 ... (Docutils ..., Python ..., on ...)
+#
+# with the additional bit of information being the version number for
+# the rst2html5 package itself.
+#
+# Use this knowledge to detect the version that we know doesn't work
+# for building libvirt and reject it
+rst2html5_version = run_command(rst2html5_prog, '--version')
+rst2html5_version = rst2html5_version.stdout().split(' ')
+if rst2html5_version[1] != '(Docutils'
+  error('Please uninstall the rst2html5 package and install the docutils package')
+endif
+
 docs_rst2html5_gen = generator(
   rst2html5_prog,
   output: '@BASENAME@.html.in',
diff --git a/meson.build b/meson.build
index 214a3f05eb..0d98f13d5e 100644
--- a/meson.build
+++ b/meson.build
@@ -788,8 +788,6 @@ required_programs = [
 
 required_programs_groups = [
   { 'name': 'rpcgen', 'prog': [ 'rpcgen', 'portable-rpcgen' ] },
-  { 'name': 'rst2html5', 'prog': [ 'rst2html5', 'rst2html5.py', 'rst2html5-3' ] },
-  { 'name': 'rst2man', 'prog': [ 'rst2man', 'rst2man.py', 'rst2man-3' ] },
 ]
 
 if host_machine.system() == 'freebsd'
@@ -810,35 +808,6 @@ foreach item : required_programs_groups
   set_variable('@0@_prog'.format(varname), prog)
 endforeach
 
-# There are two versions of rst2html5 in the wild: one is the version
-# coming from the docutils package, and the other is the one coming
-# from the rst2html5 package. These versions are subtly different,
-# and the libvirt documentation can only be successfully generated
-# using the docutils version. Every now and then, users will report
-# build failures that can be traced back to having the wrong version
-# installed.
-#
-# The only reliable way to tell the two binaries apart seems to be
-# looking look at their version information: the docutils version
-# will report
-#
-#   rst2html5 (Docutils ..., Python ..., on ...)
-#
-# whereas the rst2html5 version will report
-#
-#   rst2html5 ... (Docutils ..., Python ..., on ...)
-#
-# with the additional bit of information being the version number for
-# the rst2html5 package itself.
-#
-# Use this knowledge to detect the version that we know doesn't work
-# for building libvirt and reject it
-rst2html5_version = run_command(rst2html5_prog, '--version')
-rst2html5_version = rst2html5_version.stdout().split(' ')
-if rst2html5_version[1] != '(Docutils'
-  error('Please uninstall the rst2html5 package and install the docutils package')
-endif
-
 # optional programs
 
 optional_programs = [
-- 
2.35.0-rc0

Re: [PATCH] meson: Detect rst2html5 and rst2man only when needed

Posted by Andrea Bolognani 1 week, 4 days ago
On Thu, Jan 13, 2022 at 08:40:56AM +0000, Ivan Teterevkov wrote:
> +++ b/meson.build
> @@ -788,8 +788,6 @@ required_programs = [
>
>  required_programs_groups = [
>    { 'name': 'rpcgen', 'prog': [ 'rpcgen', 'portable-rpcgen' ] },
> -  { 'name': 'rst2html5', 'prog': [ 'rst2html5', 'rst2html5.py', 'rst2html5-3' ] },
> -  { 'name': 'rst2man', 'prog': [ 'rst2man', 'rst2man.py', 'rst2man-3' ] },
>  ]

I wonder if we could avoid looking for rpcgen unless the remote
driver is enabled? I'm not entirely sure that would work, and the
benefits of a remote-less build are less obvious.

Anyway, your patch is

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

I'll push it once 8.0.0 has been released.

Congratulations on your first contribution to libvirt :)

-- 
Andrea Bolognani / Red Hat / Virtualization