From 5e78edf6e09373938a796cf44fb38d2309d04b4d Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Mon, 27 Jun 2022 12:59:34 -0400
Subject: Switch to meson build system

---
 doc/c/Doxyfile        | 33 --------------------------------
 doc/c/Doxyfile.in     | 36 +++++++++++++++++++++++++++++++++++
 doc/c/api/meson.build |  6 ++++++
 doc/c/meson.build     | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
 doc/c/wscript         | 41 ----------------------------------------
 doc/c/xml/meson.build | 18 ++++++++++++++++++
 6 files changed, 112 insertions(+), 74 deletions(-)
 delete mode 100644 doc/c/Doxyfile
 create mode 100644 doc/c/Doxyfile.in
 create mode 100644 doc/c/api/meson.build
 create mode 100644 doc/c/meson.build
 delete mode 100644 doc/c/wscript
 create mode 100644 doc/c/xml/meson.build

(limited to 'doc/c')

diff --git a/doc/c/Doxyfile b/doc/c/Doxyfile
deleted file mode 100644
index 600e0e94..00000000
--- a/doc/c/Doxyfile
+++ /dev/null
@@ -1,33 +0,0 @@
-PROJECT_NAME           = Serd
-PROJECT_BRIEF          = "A lightweight C library for working with RDF data"
-
-QUIET                  = YES
-WARN_AS_ERROR          = NO
-WARN_IF_UNDOCUMENTED   = NO
-WARN_NO_PARAMDOC       = NO
-
-JAVADOC_AUTOBRIEF      = YES
-
-CASE_SENSE_NAMES       = YES
-HIDE_IN_BODY_DOCS      = YES
-REFERENCES_LINK_SOURCE = NO
-
-GENERATE_HTML          = NO
-GENERATE_LATEX         = NO
-GENERATE_XML           = YES
-XML_PROGRAMLISTING     = NO
-SHOW_FILES             = NO
-
-MACRO_EXPANSION        = YES
-PREDEFINED             = SERD_ALLOCATED \
-                         SERD_API \
-                         SERD_CONST_FUNC= \
-                         SERD_DEPRECATED_BY(x)= \
-                         SERD_DISABLE_DEPRECATED \
-                         SERD_NONNULL= \
-                         SERD_NULLABLE= \
-                         SERD_PURE_FUNC=
-
-INPUT                  = ../../include/serd/serd.h
-
-OUTPUT_DIRECTORY       = .
diff --git a/doc/c/Doxyfile.in b/doc/c/Doxyfile.in
new file mode 100644
index 00000000..12d0440b
--- /dev/null
+++ b/doc/c/Doxyfile.in
@@ -0,0 +1,36 @@
+PROJECT_NAME           = Serd
+PROJECT_BRIEF          = "A lightweight C library for working with RDF data"
+
+QUIET                  = YES
+WARN_AS_ERROR          = YES
+WARN_IF_UNDOCUMENTED   = NO
+WARN_NO_PARAMDOC       = NO
+
+JAVADOC_AUTOBRIEF      = YES
+
+FULL_PATH_NAMES        = NO
+CASE_SENSE_NAMES       = YES
+HIDE_IN_BODY_DOCS      = YES
+REFERENCES_LINK_SOURCE = NO
+
+GENERATE_HTML          = NO
+GENERATE_LATEX         = NO
+GENERATE_XML           = YES
+XML_PROGRAMLISTING     = NO
+SHOW_FILES             = NO
+
+MACRO_EXPANSION        = YES
+PREDEFINED             = SERD_ALLOCATED \
+                         SERD_API \
+                         SERD_CONST_FUNC= \
+                         SERD_DEPRECATED_BY(x)= \
+                         SERD_DISABLE_DEPRECATED \
+                         SERD_NONNULL= \
+                         SERD_NULLABLE= \
+                         SERD_PURE_FUNC=
+
+RECURSIVE              = YES
+STRIP_FROM_PATH        = @SERD_SRCDIR@
+INPUT                  = @SERD_SRCDIR@/include
+
+OUTPUT_DIRECTORY       = @DOX_OUTPUT@
diff --git a/doc/c/api/meson.build b/doc/c/api/meson.build
new file mode 100644
index 00000000..bc75345a
--- /dev/null
+++ b/doc/c/api/meson.build
@@ -0,0 +1,6 @@
+c_serd_rst = custom_target(
+  'serd.rst',
+  command: [dox_to_sphinx, '-f', '@INPUT0@', '@OUTDIR@'],
+  input: [c_index_xml] + c_rst_files,
+  output: 'serd.rst',
+)
diff --git a/doc/c/meson.build b/doc/c/meson.build
new file mode 100644
index 00000000..ee104b13
--- /dev/null
+++ b/doc/c/meson.build
@@ -0,0 +1,52 @@
+config = configuration_data()
+config.set('SERD_VERSION', meson.project_version())
+config.set('SERD_SRCDIR', serd_src_root)
+config.set('SERD_TITLE', get_option('title'))
+
+conf_py = configure_file(
+  configuration: config,
+  input: files('../conf.py.in'),
+  output: 'conf.py',
+)
+
+configure_file(
+  copy: true,
+  input: files('../summary.rst'),
+  output: 'summary.rst',
+)
+
+c_rst_files = files(
+  'index.rst',
+  'overview.rst',
+)
+
+foreach f : c_rst_files
+  configure_file(copy: true, input: f, output: '@PLAINNAME@')
+endforeach
+
+subdir('xml')
+subdir('api')
+
+# TODO: Add install_tag: 'doc' after requiring meson 0.60.0
+
+custom_target(
+  'singlehtml',
+  build_by_default: true,
+  command: [sphinx_build, '-M', 'singlehtml', '@OUTDIR@', '@OUTDIR@',
+            '-E', '-q', '-t', 'singlehtml'],
+  input: [c_rst_files, c_serd_rst, c_index_xml],
+  install: true,
+  install_dir: docdir / versioned_name,
+  output: 'singlehtml',
+)
+
+custom_target(
+  'html',
+  build_by_default: true,
+  command: [sphinx_build, '-M', 'html', '@OUTDIR@', '@OUTDIR@',
+            '-E', '-q', '-t', 'html'],
+  input: [c_rst_files, c_serd_rst, c_index_xml],
+  install: true,
+  install_dir: docdir / versioned_name,
+  output: 'html',
+)
diff --git a/doc/c/wscript b/doc/c/wscript
deleted file mode 100644
index 9a524e3a..00000000
--- a/doc/c/wscript
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env python
-
-def build(bld):
-    dox_to_sphinx = bld.path.find_node("../../scripts/dox_to_sphinx.py")
-    index_xml = bld.path.get_bld().make_node("xml/index.xml")
-
-    files = [
-        ("../../resources/serd.svg", "sphinx/_static/serd.svg"),
-        ("../summary.rst", "sphinx/summary.rst"),
-        ("index.rst", "sphinx/index.rst"),
-        ("overview.rst", "sphinx/overview.rst"),
-    ]
-
-    # Run Doxygen to generate XML documentation
-    bld(features="doxygen", doxyfile="Doxyfile")
-
-    # Substitute variables to make Sphinx configuration file
-    bld(features="subst",
-        source="../conf.py.in",
-        target="sphinx/conf.py",
-        SERD_VERSION=bld.env.SERD_VERSION)
-
-    # Copy static documentation files to Sphinx build directory
-    for f in files:
-        bld(features="subst", is_copy=True, source=f[0], target=f[1])
-
-    # Generate Sphinx markup from Doxygen XML
-    bld.add_group()
-    bld(rule="${PYTHON} " + dox_to_sphinx.abspath() + " -f ${SRC} ${TGT}",
-        source=index_xml,
-        target="sphinx/api/")
-
-    doc_dir = bld.env.DOCDIR + "/serd-%s/" % bld.env.SERD_MAJOR_VERSION
-
-    # Run Sphinx to generate HTML documentation
-    for builder in ["html", "singlehtml"]:
-        bld(features="sphinx",
-            sphinx_source=bld.path.get_bld().make_node("sphinx"),
-            sphinx_output_format=builder,
-            sphinx_options=["-E", "-q", "-t", builder],
-            install_path=doc_dir + "c/%s/" % builder)
diff --git a/doc/c/xml/meson.build b/doc/c/xml/meson.build
new file mode 100644
index 00000000..a49e2754
--- /dev/null
+++ b/doc/c/xml/meson.build
@@ -0,0 +1,18 @@
+doxygen = find_program('doxygen')
+
+config = configuration_data()
+config.set('SERD_SRCDIR', serd_src_root)
+config.set('DOX_OUTPUT', meson.current_build_dir() / '..')
+
+c_doxyfile = configure_file(
+  configuration: config,
+  input: files('../Doxyfile.in'),
+  output: 'Doxyfile',
+)
+
+c_index_xml = custom_target(
+  'index.xml',
+  command: [doxygen, '@INPUT0@'],
+  input: [c_doxyfile] + c_headers,
+  output: 'index.xml',
+)
-- 
cgit v1.2.1