[glib/wip/meson: 26/35] meson: Detect with-docs and with-man automatically



commit c6a0b31cbb5d6c5597584af415afce36348c65ba
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Tue Mar 21 16:38:47 2017 +0530

    meson: Detect with-docs and with-man automatically
    
    By default, only build man pages and gtk-doc if the build-deps were
    found. To force-enable, pass -Dwith-docs=yes and -Dwith-man=yes.
    
    Also use a foreach loop for man pages instead of listing them all
    manually

 docs/reference/gio/meson.build     |   86 +++++------------------------------
 docs/reference/glib/meson.build    |   36 +++++----------
 docs/reference/gobject/meson.build |   36 +++++----------
 meson.build                        |   11 ++---
 meson_options.txt                  |    4 +-
 5 files changed, 42 insertions(+), 131 deletions(-)
---
diff --git a/docs/reference/gio/meson.build b/docs/reference/gio/meson.build
index 57dcac3..7f04677 100644
--- a/docs/reference/gio/meson.build
+++ b/docs/reference/gio/meson.build
@@ -1,4 +1,4 @@
-if get_option('with-docs')
+if get_option('with-docs') != 'no'
   subdir('xml')
 
   ignore_headers = [
@@ -146,76 +146,16 @@ if get_option('with-docs')
 endif
 
 
-if get_option('with-man')
-  custom_target('gapplication-man',
-    input: 'gapplication.xml',
-    output: 'gapplication.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gio-querymodules-man',
-    input: 'gio-querymodules.xml',
-    output: 'gio-querymodules.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('glib-compile-schemas-man',
-    input: 'glib-compile-schemas.xml',
-    output: 'glib-compile-schemas.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('glib-compile-resources-man',
-    input: 'glib-compile-resources.xml',
-    output: 'glib-compile-resources.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gsettings-man',
-    input: 'gsettings.xml',
-    output: 'gsettings.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gresource-man',
-    input: 'gresource.xml',
-    output: 'gresource.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gdbus-man',
-    input: 'gdbus.xml',
-    output: 'gdbus.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gio',
-    input: 'gio.xml',
-    output: 'gio.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gdbus-codegen-man',
-    input: 'gdbus-codegen.xml',
-    output: 'gdbus-codegen.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
+if get_option('with-man') != 'no' and xsltproc.found()
+  manpages = ['gapplication', 'gio-querymodules', 'glib-compile-schemas',
+              'glib-compile-resources', 'gsettings', 'gresource', 'gdbus',
+              'gio', 'gdbus-codegen']
+  foreach page : manpages
+    custom_target(page + '-man',
+      input: page + '.xml',
+      output: page + '.1',
+      command: xsltproc_command,
+      install: true,
+      install_dir: man1_dir)
+  endforeach
 endif
diff --git a/docs/reference/glib/meson.build b/docs/reference/glib/meson.build
index b76b9e4..3babb3e 100644
--- a/docs/reference/glib/meson.build
+++ b/docs/reference/glib/meson.build
@@ -1,4 +1,4 @@
-if get_option('with-docs')
+if get_option('with-docs') != 'no'
   subdir('xml')
 
   ignore_headers = [
@@ -90,28 +90,14 @@ if get_option('with-docs')
                install: true)
 endif
 
-if get_option('with-man')
-  custom_target('glib-gettextize-man',
-    input: 'glib-gettextize.xml',
-    output: 'glib-gettextize.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gtester-man',
-    input: 'gtester.xml',
-    output: 'gtester.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gtester-report-man',
-    input: 'gtester-report.xml',
-    output: 'gtester-report.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
+if get_option('with-man') != 'no' and xsltproc.found()
+  manpages = ['glib-gettextize', 'gtester', 'gtester-report']
+  foreach page : manpages
+    custom_target(page + '-man',
+      input: page + '.xml',
+      output: page + '.1',
+      command: xsltproc_command,
+      install: true,
+      install_dir: man1_dir)
+  endforeach
 endif
diff --git a/docs/reference/gobject/meson.build b/docs/reference/gobject/meson.build
index fc3de24..f486a25 100644
--- a/docs/reference/gobject/meson.build
+++ b/docs/reference/gobject/meson.build
@@ -1,4 +1,4 @@
-if get_option('with-docs')
+if get_option('with-docs') != 'no'
   subdir('xml')
 
   ignore_headers = [
@@ -51,28 +51,14 @@ if get_option('with-docs')
   )
 endif
 
-if get_option('with-man')
-  custom_target('glib-mkenums-man',
-    input: 'glib-mkenums.xml',
-    output: 'glib-mkenums.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('glib-genmarshal-man',
-    input: 'glib-genmarshal.xml',
-    output: 'glib-genmarshal.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
-
-  custom_target('gobject-query-man',
-    input: 'gobject-query.xml',
-    output: 'gobject-query.1',
-    command: xsltproc_command,
-    install: true,
-    install_dir: man1_dir,
-  )
+if get_option('with-man') != 'no' and xsltproc.found()
+  manpages = ['glib-mkenums', 'glib-genmarshal', 'gobject-query']
+  foreach page : manpages
+    custom_target(page + '-man',
+      input: page + '.xml',
+      output: page + '.1',
+      command: xsltproc_command,
+      install: true,
+      install_dir: man1_dir)
+  endforeach
 endif
diff --git a/meson.build b/meson.build
index 02e09a4..b9e5609 100644
--- a/meson.build
+++ b/meson.build
@@ -1434,12 +1434,11 @@ configure_file(input : 'config.h.meson',
   output : 'config.h',
   configuration : glib_conf)
 
-if get_option('with-docs') and not meson.version().version_compare('>= 0.37.0')
-  error('In order to build docs you must have Meson >= 0.37.0')
-endif
-
-if get_option('with-man')
-  xsltproc = find_program('xsltproc')
+if get_option('with-man') != 'no'
+  xsltproc = find_program('xsltproc', required : false)
+  if not xsltproc.found() and get_option('with-man') == 'yes'
+    error('man pages enabled and xsltproc not found')
+  endif
   xsltproc_command = [
     xsltproc,
     '--nonet',
diff --git a/meson_options.txt b/meson_options.txt
index f622206..f70d54a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,5 +1,5 @@
-option('with-docs', type : 'boolean', value : false)
-option('with-man', type : 'boolean', value : true)
+option('with-docs', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
+option('with-man', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'auto')
 option('enable-libmount', type : 'combo', choices : ['auto', 'yes', 'no'], value : 'yes')
 option('enable-dtrace', type : 'boolean', value : false,
   description : 'include tracing support for dtrace')


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