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



commit 441f6ea4ca3ecee79bc1baae59874cdb7b1143f1
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.

 .gitlab-ci.yml                 |  4 ++--
 .gitlab-ci/test-msys2-meson.sh |  2 +-
 meson.build                    | 19 ++++++++++++++++++-
 meson_options.txt              |  2 +-
 tests/scanner/meson.build      |  2 +-
 tools/meson.build              |  2 ++
 6 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 72d6f7a1..542d9912 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,7 +16,7 @@ fedora-x86_64-meson:
     CFLAGS: "-Werror"
   script:
     - python3 -m pip install --user mako markdown
-    - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Ddoctool=true -Dgtk_doc=true -Dcairo=true 
-Dpython=python3 _build .
+    - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Ddoctool=enabled -Dgtk_doc=true 
-Dcairo=true -Dpython=python3 _build .
     - cd _build
     - ninja
     - meson test --print-errorlogs --suite=gobject-introspection --no-suite=glib
@@ -43,7 +43,7 @@ fedora-x86_64-python3.5:
     PYENV_VERSION: "3.5.6"
   script:
     - python3 -m pip install --user mako markdown
-    - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Ddoctool=true -Dgtk_doc=true -Dcairo=true 
-Dpython=python3 _build .
+    - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Ddoctool=enabled -Dgtk_doc=true 
-Dcairo=true -Dpython=python3 _build .
     - cd _build
     - ninja
     - meson test --print-errorlogs --suite=gobject-introspection --no-suite=glib
diff --git a/.gitlab-ci/test-msys2-meson.sh b/.gitlab-ci/test-msys2-meson.sh
index ce1768c4..56d44a62 100644
--- a/.gitlab-ci/test-msys2-meson.sh
+++ b/.gitlab-ci/test-msys2-meson.sh
@@ -38,7 +38,7 @@ export PATH="$HOME/.local/bin:$PATH"
 # Passing the full interpreter path works around the issue
 PYTHON="$(which python3)"
 export CFLAGS="-Werror"
-meson -Dcairo=true -Ddoctool=true -Dpython="${PYTHON}" --buildtype debug _build
+meson -Dcairo=true -Ddoctool=enabled -Dpython="${PYTHON}" --buildtype debug _build
 cd _build
 ninja
 
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]