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

[RFCv2 03/46] maint: Call xmlgen automatically when c-head-files change



Signed-off-by: Shi Lei <shi_lei massclouds com>
---
 scripts/meson.build  |  8 ++++++++
 src/conf/meson.build | 39 +++++++++++++++++++++++++++++++++++++++
 src/meson.build      |  6 ++++++
 tests/meson.build    |  1 +
 tools/meson.build    |  2 ++
 5 files changed, 56 insertions(+)

diff --git a/scripts/meson.build b/scripts/meson.build
index 59b3c9b..dad82a9 100644
--- a/scripts/meson.build
+++ b/scripts/meson.build
@@ -37,3 +37,11 @@ foreach name : scripts
   sname = name.split('.')[0].underscorify()
   set_variable('@0 _prog'.format(sname), find_program(name))
 endforeach
+
+xmlgen_self = files(
+  'xmlgen/main.py',
+  'xmlgen/directive.py',
+  'xmlgen/utils.py'
+)
+
+set_variable('virxmlgen_prog', find_program('xmlgen/main.py'))
diff --git a/src/conf/meson.build b/src/conf/meson.build
index 03b90aa..d82bffc 100644
--- a/src/conf/meson.build
+++ b/src/conf/meson.build
@@ -1,3 +1,39 @@
+xmlgen_input = [
+]
+
+xmlgen_output = []
+foreach name : xmlgen_input
+  xmlgen_output += '@0  generated c'.format(name.split('.')[0])
+  xmlgen_output += '@0  generated h'.format(name.split('.')[0])
+endforeach
+
+xmlgen_headers = []
+if xmlgen_output.length() > 0
+  xmlgen_objects = custom_target(
+    'virxmlgen',
+    input: xmlgen_self + xmlgen_input,
+    output: xmlgen_output,
+    command: [
+      meson_python_prog, python3_prog.path(), '-B', virxmlgen_prog.path(),
+      '-s', meson.source_root() / 'src',
+      '-b', meson.build_root() / 'src',
+      'generate', '-k', 'cpf',
+    ],
+  )
+
+  index = 0
+  foreach header : xmlgen_objects.to_list()
+    if index % 2 == 1
+      xmlgen_headers += header
+    endif
+    index += 1
+  endforeach
+else
+  xmlgen_objects = []
+endif
+
+xmlgen_dep = declare_dependency(sources: xmlgen_headers)
+
 netdev_conf_sources = [
   'netdev_bandwidth_conf.c',
   'netdev_vlan_conf.c',
@@ -87,6 +123,7 @@ device_conf_sources = [
 virt_conf_lib = static_library(
   'virt_conf',
   [
+    xmlgen_objects,
     chrdev_conf_sources,
     cpu_conf_sources,
     device_conf_sources,
@@ -108,3 +145,5 @@ virt_conf_lib = static_library(
 libvirt_libs += virt_conf_lib
 
 conf_inc_dir = include_directories('.')
+
+subdir_done()
diff --git a/src/meson.build b/src/meson.build
index 897b5ec..2362897 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -247,6 +247,12 @@ src_dep = declare_dependency(
 )
 
 subdir('conf')
+
+src_dep = declare_dependency(
+  dependencies: [ src_dep, xmlgen_dep ],
+  include_directories: [ conf_inc_dir ],
+)
+
 subdir('rpc')
 subdir('access')
 subdir('cpu')
diff --git a/tests/meson.build b/tests/meson.build
index ad13e2d..c23910b 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -17,6 +17,7 @@ tests_dep = declare_dependency(
     selinux_dep,
     xdr_dep,
     yajl_dep,
+    xmlgen_dep,
   ],
   include_directories: [
     conf_inc_dir,
diff --git a/tools/meson.build b/tools/meson.build
index b8c6802..788eed0 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -5,11 +5,13 @@ tools_dep = declare_dependency(
   dependencies: [
     libxml_dep,
     glib_dep,
+    xmlgen_dep,
   ],
   include_directories: [
     libvirt_inc,
     src_inc_dir,
     util_inc_dir,
+    conf_inc_dir,
     top_inc_dir,
   ],
   link_args: (
-- 
2.25.1



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