From 18d3131f9a332096825c09106a931c427246ddb7 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 5 Aug 2021 22:43:54 +0300 Subject: [PATCH] meson: Implement developer documentation build Signed-off-by: Povilas Kanapickas --- doc/dtrace/meson.build | 64 ++++++++++++++++++++++++++++++++++++++ doc/meson.build | 39 +++++++++++++++++++++++ hw/dmx/doc/meson.build | 37 ++++++++++++++++++++++ hw/dmx/meson.build | 2 +- hw/xfree86/doc/meson.build | 35 +++++++++++++++++++++ hw/xfree86/meson.build | 2 ++ meson.build | 58 ++++++++++++++++++++++++++++++++++ meson_options.txt | 7 +++++ 8 files changed, 243 insertions(+), 1 deletion(-) create mode 100644 doc/dtrace/meson.build create mode 100644 doc/meson.build create mode 100644 hw/dmx/doc/meson.build create mode 100644 hw/xfree86/doc/meson.build diff --git a/doc/dtrace/meson.build b/doc/dtrace/meson.build new file mode 100644 index 000000000..09b606990 --- /dev/null +++ b/doc/dtrace/meson.build @@ -0,0 +1,64 @@ + +if build_docs + basename = 'Xserver-DTrace' + + input_xml = basename + '.xml' + + custom_target( + basename + '.html', + output: basename + '.html', + input: [input_xml], + command: [xmlto] + docs_xmlto_search_flags + [ + '-x', join_paths(doc_stylesheet_srcdir, 'xorg-xhtml.xsl'), + '--stringparam', 'target.database.document=' + join_paths(doc_sgml_path, 'X11/dbs/masterdb.html.xml'), + '--stringparam', 'current.docid=' + basename, + '-o', meson.current_build_dir(), + 'xhtml-nochunks', '@INPUT0@'], + build_by_default: true, + install: true, + install_dir: join_paths(get_option('datadir'), 'doc/xorg-server'), + ) + + if build_docs_pdf + foreach format : ['ps', 'pdf'] + output_fn = basename + '.' + format + custom_target( + output_fn, + output: output_fn, + input: [input_xml], + command: [xmlto] + docs_xmlto_search_flags + [ + '-x', join_paths(doc_stylesheet_srcdir, 'xorg-fo.xsl'), + '--stringparam', 'img.src.path=' + meson.current_build_dir(), + '--stringparam', 'target.database.document=' + join_paths(doc_sgml_path, 'X11/dbs/masterdb.pdf.xml'), + '--stringparam', 'current.docid=' + basename, + '-o', meson.current_build_dir(), + '--with-fop', format, '@INPUT0@'], + build_by_default: true, + install: true, + install_dir: join_paths(get_option('datadir'), 'doc/xorg-server'), + ) + endforeach + endif + + foreach format_data : [['html', 'xorg-xhtml.xsl'], ['pdf', 'xorg-fo.xsl']] + format = format_data[0] + stylesheet = format_data[1] + output_fn = basename + '.' + format + '.db' + custom_target( + output_fn, + output: output_fn, + input: [input_xml], + command: [xsltproc] + docs_xslt_search_flags + [ + '--stringparam', 'targets.filename', output_fn, + '--stringparam', 'collect.xref.targets', 'only', + '--stringparam', 'olink.base.uri', basename + '.' + format, + '--nonet', + '--output', join_paths(meson.current_build_dir(), output_fn), + '--xinclude', join_paths(doc_stylesheet_srcdir, stylesheet), + '@INPUT0@'], + build_by_default: true, + install: true, + install_dir: join_paths(get_option('datadir'), 'doc/xorg-server'), + ) + endforeach +endif diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 000000000..5a4faa9a4 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,39 @@ + +if build_docs_devel + foreach basename : ['Xserver-spec', 'Xinput'] + + input_xml = basename + '.xml' + + custom_target( + basename + '.html', + output: basename + '.html', + input: [input_xml], + command: [xmlto] + docs_xmlto_search_flags + [ + '-x', join_paths(doc_stylesheet_srcdir, 'xorg-xhtml.xsl'), + '-o', meson.current_build_dir(), + 'xhtml-nochunks', '@INPUT0@'], + build_by_default: true, + install: false, + ) + + if build_docs_pdf + foreach format : ['ps', 'pdf'] + output_fn = basename + '.' + format + custom_target( + output_fn, + output: output_fn, + input: [input_xml], + command: [xmlto] + docs_xmlto_search_flags + [ + '-x', join_paths(doc_stylesheet_srcdir, 'xorg-fo.xsl'), + '--stringparam', 'img.src.path=' + meson.current_build_dir(), + '-o', meson.current_build_dir(), + '--with-fop', format, '@INPUT0@'], + build_by_default: true, + install: false, + ) + endforeach + endif + endforeach +endif + +subdir('dtrace') diff --git a/hw/dmx/doc/meson.build b/hw/dmx/doc/meson.build new file mode 100644 index 000000000..8cdc4c004 --- /dev/null +++ b/hw/dmx/doc/meson.build @@ -0,0 +1,37 @@ + +if build_docs_devel + foreach basename : ['dmx', 'scaled'] + + input_xml = basename + '.xml' + + custom_target( + basename + '.html', + output: basename + '.html', + input: [input_xml], + command: [xmlto] + docs_xmlto_search_flags + [ + '-x', join_paths(doc_stylesheet_srcdir, 'xorg-xhtml.xsl'), + '-o', meson.current_build_dir(), + 'xhtml-nochunks', '@INPUT0@'], + build_by_default: true, + install: false, + ) + + if build_docs_pdf + foreach format : ['ps', 'pdf'] + output_fn = basename + '.' + format + custom_target( + output_fn, + output: output_fn, + input: [input_xml], + command: [xmlto] + docs_xmlto_search_flags + [ + '-x', join_paths(doc_stylesheet_srcdir, 'xorg-fo.xsl'), + '--stringparam', 'img.src.path=' + meson.current_build_dir(), + '-o', meson.current_build_dir(), + '--with-fop', format, '@INPUT0@'], + build_by_default: true, + install: false, + ) + endforeach + endif + endforeach +endif diff --git a/hw/dmx/meson.build b/hw/dmx/meson.build index d075e5c40..c7f20c71a 100644 --- a/hw/dmx/meson.build +++ b/hw/dmx/meson.build @@ -27,7 +27,7 @@ srcs = [ subdir('config') subdir('input') subdir('examples') -# XXX: subdir('doc') +subdir('doc') # XXX: subdir('doxygen') install_man(configure_file( diff --git a/hw/xfree86/doc/meson.build b/hw/xfree86/doc/meson.build new file mode 100644 index 000000000..df1d5e215 --- /dev/null +++ b/hw/xfree86/doc/meson.build @@ -0,0 +1,35 @@ + +if build_docs_devel + basename = 'ddxDesign' + input_xml = basename + '.xml' + + custom_target( + basename + '.html', + output: basename + '.html', + input: [input_xml], + command: [xmlto] + docs_xmlto_search_flags + [ + '-x', join_paths(doc_stylesheet_srcdir, 'xorg-xhtml.xsl'), + '-o', meson.current_build_dir(), + 'xhtml-nochunks', '@INPUT0@'], + build_by_default: true, + install: false, + ) + + if build_docs_pdf + foreach format : ['ps', 'pdf'] + output_fn = basename + '.' + format + custom_target( + output_fn, + output: output_fn, + input: [input_xml], + command: [xmlto] + docs_xmlto_search_flags + [ + '-x', join_paths(doc_stylesheet_srcdir, 'xorg-fo.xsl'), + '--stringparam', 'img.src.path=' + meson.current_build_dir(), + '-o', meson.current_build_dir(), + '--with-fop', format, '@INPUT0@'], + build_by_default: true, + install: false, + ) + endforeach + endif +endif diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build index 7d3693fba..29ea31568 100644 --- a/hw/xfree86/meson.build +++ b/hw/xfree86/meson.build @@ -230,3 +230,5 @@ install_man(configure_file( output: 'gtf.1', configuration: manpage_config, )) + +subdir('doc') diff --git a/meson.build b/meson.build index a2cdd552f..9201428a8 100644 --- a/meson.build +++ b/meson.build @@ -6,6 +6,8 @@ project('xserver', 'c', version: '21.0.99.1', meson_version: '>= 0.47.0', ) +release_date = '2021-07-05' + add_project_arguments('-DHAVE_DIX_CONFIG_H', language: ['c', 'objc']) cc = meson.get_compiler('c') @@ -689,6 +691,50 @@ manpage_config.set('modulepath', module_dir) manpage_config.set('suid_wrapper_dir', join_paths(get_option('prefix'), 'libexec')) manpage_config.set('default_font_path', default_font_path) +require_docs = get_option('docs') == 'true' +require_devel_docs = get_option('devel-docs') == 'true' +require_docs_pdf = (require_docs or require_devel_docs) and get_option('docs-pdf') == 'true' + +sgml_doctools_dep = dependency('xorg-sgml-doctools', + required: require_docs or require_devel_docs) +xmlto = find_program('xmlto', required: require_docs or require_devel_docs) +xsltproc = find_program('xsltproc', required: require_docs or require_devel_docs) +fop = find_program('fop', required: require_docs_pdf) + +build_docs = (get_option('docs') != 'false' and + sgml_doctools_dep.found() and + xmlto.found()) + +build_docs_devel = (get_option('devel-docs') != 'false' and + sgml_doctools_dep.found() and + xmlto.found()) + +build_docs_pdf = (get_option('docs-pdf') != 'false' and + (build_docs or build_docs_devel) and + fop.found()) + +if build_docs or build_docs_devel + doc_sgml_path = sgml_doctools_dep.get_pkgconfig_variable('sgmlrootdir') + doc_stylesheet_srcdir = join_paths(doc_sgml_path, 'X11') + + # once we bump meson dependency to 0.56.0 we can use + # meson.project_build_root() instead of meson.build_root() + + # Meson does not and will not support functions so we are copy-pasting + # documentation build code around which is unfortunate + # See https://mesonbuild.com/FAQ.html#why-doesnt-meson-have-user-defined-functionsmacros + + docs_xmlto_search_flags = [ + '--searchpath', doc_stylesheet_srcdir, + '--searchpath', meson.build_root(), + ] + + docs_xslt_search_flags = [ + '--path', doc_stylesheet_srcdir, + '--path', meson.build_root(), + ] +endif + # Include must come first, as it sets up dix-config.h subdir('include') @@ -728,6 +774,7 @@ endif if build_xorg or get_option('xephyr') subdir('exa') endif +subdir('doc') # Common static libraries of all X servers libxserver = [ @@ -825,3 +872,14 @@ if build_xorg install_data('xorg-server.m4', install_dir: join_paths(get_option('datadir'), 'aclocal')) endif + +if build_docs or build_docs_devel + docxmlconfig = configuration_data() + docxmlconfig.set('PACKAGE_VERSION', meson.project_version()) + docxmlconfig.set('RELEASE_DATE', release_date) + configure_file( + input: 'xserver.ent.in', + output: 'xserver.ent', + configuration: docxmlconfig + ) +endif diff --git a/meson_options.txt b/meson_options.txt index cad3e3920..5977ddc13 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -131,3 +131,10 @@ option('libunwind', type: 'boolean', value: false, description: 'Use libunwind for backtrace reporting') option('xwayland-path', type: 'string', description: 'Directory containing Xwayland executable') + +option('docs', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', + description: 'Build documentation') +option('devel-docs', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', + description: 'Build development documentation') +option('docs-pdf', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', + description: 'Whether to build PDF version of documentation. Setting is ignored if documentation is not built.')