[libvirt PATCH 317/351] meson: docs: build api XML files

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 docs/Makefile.am    | 55 ---------------------------------------------
 docs/meson.build    | 32 ++++++++++++++++++++++++++
 scripts/apibuild.py | 26 +++++++++++++--------
 src/meson.build     | 16 +++++++++----
 4 files changed, 61 insertions(+), 68 deletions(-)

diff --git a/docs/Makefile.am b/docs/Makefile.am
index 6d97ed55c5b..1237b4c47cc 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -297,13 +297,6 @@ dot_html = \
 htmldir = $(HTML_DIR)
 html_DATA = $(dot_html)
 
-apidir = $(pkgdatadir)/api
-api_DATA = \
-       libvirt-api.xml \
-       libvirt-qemu-api.xml \
-       libvirt-lxc-api.xml \
-       libvirt-admin-api.xml
-
 schemadir = $(pkgdatadir)/schemas
 schema_DATA = $(wildcard $(srcdir)/schemas/*.rng)
 
@@ -392,51 +385,3 @@ check-html:
 	$(XMLLINT) --nonet --noout html/*.html
 
 check-local: check-html
-
-python_generated_files = $(api_DATA)
-
-APIBUILD=$(top_srcdir)/scripts/apibuild.py
-APIBUILD_STAMP=apibuild.py.stamp
-
-$(python_generated_files): $(APIBUILD_STAMP)
-
-$(APIBUILD_STAMP): $(top_srcdir)/scripts/apibuild.py \
-		$(top_srcdir)/include/libvirt/libvirt.h \
-		$(top_srcdir)/include/libvirt/libvirt-common.h.in \
-		$(top_srcdir)/include/libvirt/libvirt-domain-checkpoint.h \
-		$(top_srcdir)/include/libvirt/libvirt-domain-snapshot.h \
-		$(top_srcdir)/include/libvirt/libvirt-domain.h \
-		$(top_srcdir)/include/libvirt/libvirt-event.h \
-		$(top_srcdir)/include/libvirt/libvirt-host.h \
-		$(top_srcdir)/include/libvirt/libvirt-interface.h \
-		$(top_srcdir)/include/libvirt/libvirt-network.h \
-		$(top_srcdir)/include/libvirt/libvirt-nodedev.h \
-		$(top_srcdir)/include/libvirt/libvirt-nwfilter.h \
-		$(top_srcdir)/include/libvirt/libvirt-secret.h \
-		$(top_srcdir)/include/libvirt/libvirt-storage.h \
-		$(top_srcdir)/include/libvirt/libvirt-stream.h \
-		$(top_srcdir)/include/libvirt/libvirt-lxc.h \
-		$(top_srcdir)/include/libvirt/libvirt-qemu.h \
-		$(top_srcdir)/include/libvirt/libvirt-admin.h \
-		$(top_srcdir)/include/libvirt/virterror.h \
-		$(top_srcdir)/src/libvirt.c \
-		$(top_srcdir)/src/libvirt-domain-checkpoint.c \
-		$(top_srcdir)/src/libvirt-domain-snapshot.c \
-		$(top_srcdir)/src/libvirt-domain.c \
-		$(top_srcdir)/src/libvirt-host.c \
-		$(top_srcdir)/src/libvirt-interface.c \
-		$(top_srcdir)/src/libvirt-network.c \
-		$(top_srcdir)/src/libvirt-nodedev.c \
-		$(top_srcdir)/src/libvirt-nwfilter.c \
-		$(top_srcdir)/src/libvirt-secret.c \
-		$(top_srcdir)/src/libvirt-storage.c \
-		$(top_srcdir)/src/libvirt-stream.c \
-		$(top_srcdir)/src/libvirt-lxc.c \
-		$(top_srcdir)/src/libvirt-qemu.c \
-		$(top_srcdir)/src/admin/libvirt-admin.c \
-		$(top_srcdir)/src/util/virerror.c \
-		$(top_srcdir)/src/util/virevent.c \
-		$(top_srcdir)/src/util/virtypedparam-public.c
-	$(AM_V_GEN)srcdir=$(srcdir) builddir=$(builddir) \
-		$(RUNUTF8) $(PYTHON) $(APIBUILD)
-	touch $@
diff --git a/docs/meson.build b/docs/meson.build
index 529a1c003a7..c67e114751e 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -28,3 +28,35 @@ docs_assets = [
 ]
 
 install_data(docs_assets, install_dir: docs_html_dir)
+
+docs_api_generated = custom_target(
+  'generate-api',
+  output: [
+    'libvirt-api.xml',
+    'libvirt-lxc-api.xml',
+    'libvirt-qemu-api.xml',
+    'libvirt-admin-api.xml',
+  ],
+  command: [
+    meson_python_prog,
+    apibuild_prog,
+    meson.current_source_dir(),
+    meson.current_build_dir(),
+  ],
+  install: true,
+  install_dir: pkgdatadir / 'api',
+  depend_files: [
+    libvirt_common_h_in,
+    libvirt_include,
+    driver_sources,
+    libvirt_qemu_sources,
+    libvirt_lxc_sources,
+    admin_sources,
+    util_public_sources,
+  ],
+)
+
+docs_api_xml = docs_api_generated[0]
+docs_lxc_api_xml = docs_api_generated[1]
+docs_qemu_api_xml = docs_api_generated[2]
+docs_admin_api_xml = docs_api_generated[3]
diff --git a/scripts/apibuild.py b/scripts/apibuild.py
index 7cac9b136b4..58ae76d29cf 100755
--- a/scripts/apibuild.py
+++ b/scripts/apibuild.py
@@ -12,6 +12,7 @@ import os
 import sys
 import glob
 import re
+import argparse
 
 quiet = True
 warnings = 0
@@ -2404,13 +2405,11 @@ class app:
         warnings = warnings + 1
         print(msg)
 
-    def rebuild(self, name):
+    def rebuild(self, name, srcdir, builddir):
         if name not in ["libvirt", "libvirt-qemu", "libvirt-lxc", "libvirt-admin"]:
             self.warning("rebuild() failed, unknown module %s" % name)
             return None
         builder = None
-        srcdir = os.path.abspath((os.environ["srcdir"]))
-        builddir = os.path.abspath((os.environ["builddir"]))
         if glob.glob(srcdir + "/../src/libvirt.c") != []:
             if not quiet:
                 print("Rebuilding API description for %s" % name)
@@ -2438,15 +2437,24 @@ class app:
 
 
 if __name__ == "__main__":
+    parser = argparse.ArgumentParser(description="XML API builder")
+    parser.add_argument("srcdir", type=str, help="path to docs source dir")
+    parser.add_argument("builddir", type=str, help="path to docs build dir")
+    parser.add_argument("-d", "--debug", type=str, help="path to source file")
+
+    args = parser.parse_args()
+
     app = app()
-    if len(sys.argv) > 1:
+
+    if args.debug:
         debug = 1
-        app.parse(sys.argv[1])
+        app.parse(args.debug)
     else:
-        app.rebuild("libvirt")
-        app.rebuild("libvirt-qemu")
-        app.rebuild("libvirt-lxc")
-        app.rebuild("libvirt-admin")
+        app.rebuild("libvirt", args.srcdir, args.builddir)
+        app.rebuild("libvirt-qemu", args.srcdir, args.builddir)
+        app.rebuild("libvirt-lxc", args.srcdir, args.builddir)
+        app.rebuild("libvirt-admin", args.srcdir, args.builddir)
+
     if warnings > 0:
         sys.exit(2)
     else:
diff --git a/src/meson.build b/src/meson.build
index 946c124079a..b8ad300e558 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -271,7 +271,7 @@ subdir('vmware')
 subdir('vz')
 
 
-driver_sources = [
+driver_sources = files(
   'driver.c',
   'libvirt.c',
   'libvirt-domain.c',
@@ -285,7 +285,7 @@ driver_sources = [
   'libvirt-secret.c',
   'libvirt-storage.c',
   'libvirt-stream.c',
-]
+  )
 
 driver_headers = [
   'driver-hypervisor.h',
@@ -415,9 +415,13 @@ libvirt_qemu_syms_flags = '@0@@1@'.format(
   libvirt_qemu_syms_path,
 )
 
+libvirt_qemu_sources = files(
+  'libvirt-qemu.c',
+)
+
 libvirt_qemu_lib = shared_library(
   'virt-qemu',
-  'libvirt-qemu.c',
+  libvirt_qemu_sources,
   dependencies: [
     src_dep,
   ],
@@ -463,9 +467,13 @@ libvirt_lxc_syms_flags = '@0@@1@'.format(
   libvirt_lxc_syms_path,
 )
 
+libvirt_lxc_sources = files(
+  'libvirt-lxc.c',
+)
+
 libvirt_lxc_lib = shared_library(
   'virt-lxc',
-  'libvirt-lxc.c',
+  libvirt_lxc_sources,
   dependencies: [
     apparmor_dep,
     selinux_dep,
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux