[gobject-introspection/meson-doctool-feature-option] meson: change "doctool" from a boolean to a feature option



commit 8cfa7c5954dbb819938562d1022c9a0658a0f8a1
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Sep 28 17:29:35 2019 +0200

    meson: change "doctool" from a boolean to a feature option
    
    Similar to !180 this should prevent devs from not running all tests by
    accident.
    
    This also adds some checks for the required doctool dependencies, mako and markdown.

 meson.build               | 19 ++++++++++++++++++-
 meson_options.txt         |  2 +-
 tests/scanner/meson.build |  2 +-
 tools/meson.build         |  2 ++
 4 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 9025388f..8afe6878 100644
--- a/meson.build
+++ b/meson.build
@@ -160,7 +160,24 @@ else
   warning('Not building with cairo support, not all tests will be run')
 endif
 
-with_doctool = get_option('doctool')
+# doctool
+doctool_option = get_option('doctool')
+
+with_doctool = true
+if doctool_option.disabled()
+  with_doctool = false
+else
+  has_mako = run_command(python, ['-c', 'import mako']).returncode() == 0
+  has_markdown = run_command(python, ['-c', 'import markdown']).returncode() == 0
+  if not has_mako or not has_markdown
+    if doctool_option.enabled()
+      error('doctool requires markdown and mako')
+    else
+      with_doctool = false
+    endif
+  endif
+endif
+
 if not with_doctool
   warning('Not building with doctool support, not all tests will be run')
 endif
diff --git a/meson_options.txt b/meson_options.txt
index 445a68a4..d941f403 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,7 +2,7 @@ option('cairo', type: 'boolean', value : false,
   description: 'Use cairo for tests'
 )
 
-option('doctool', type: 'boolean', value : false,
+option('doctool', type: 'feature', value : 'auto',
   description: 'Install g-ir-doc-tool and run related tests'
 )
 
diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
index a028e3d2..4085d471 100644
--- a/tests/scanner/meson.build
+++ b/tests/scanner/meson.build
@@ -521,7 +521,7 @@ foreach gir : test_girs
   )
 endforeach
 
-if with_doctool and glib_dep.type_name() == 'pkgconfig'
+if has_girdoctool and glib_dep.type_name() == 'pkgconfig'
   foreach language : ['C', 'Python', 'Gjs']
     regress_docs = custom_target(
       'generate-docs-' + language,
diff --git a/tools/meson.build b/tools/meson.build
index 1fedaa53..418cf3ad 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -38,8 +38,10 @@ foreach tool : tools
 endforeach
 
 girscanner = tool_output[0]
+has_girdoctool = false
 if with_doctool
   girdoctool = tool_output[-1]
+  has_girdoctool = true
 endif
 
 custom_c_args = []


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]