[PATCH v1 3/4] scripts: apibuild: parse 'Since' for macros

Victor Toso victortoso at redhat.com
Tue Apr 5 11:43:22 UTC 2022


This patch adds 'version' parameter to the generated XML API for
macros

It'll require, for new additions, to add a comment with the version
that the macro was added. An example bellow of code diff and
the change in the generated XML.

Note that the Since tag is removed from the comment as there is a
proper field for it in the XML.

```diff
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -2139,6 +2139,8 @@ int                     virDomainGetVcpus
 (virDomainPtr domain,
 * virDomainPinVcpu() APIs. VIR_COPY_CPUMAP macro extracts the cpumap of
 * the specified vcpu from cpumaps array and copies it into cpumap to be used
 * later by virDomainPinVcpu() API.
+ *
+ * Since 0.1.10
  */
 # define VIR_COPY_CPUMAP(cpumaps, maplen, vcpu, cpumap) \
     memcpy(cpumap, VIR_GET_CPUMAP(cpumaps, maplen, vcpu), maplen)
```

```xml
    <macro name='VIR_COPY_CPUMAP'
           file='libvirt-domain'
           params='cpumaps,maplen,vcpu,cpumap'
           raw='memcpy(cpumap, VIR_GET_CPUMAP(cpumaps, maplen, vcpu), maplen)'
           version='0.1.10'>
      <info><![CDATA[This macro is to be used in conjunction with
 virDomainGetVcpus() and virDomainPinVcpu() APIs. VIR_COPY_CPUMAP
 macro extracts the cpumap of the specified vcpu from cpumaps
 array and copies it into cpumap to be used later by virDomainPinVcpu()
 API.]]></info>
      ...
    </macro>
```

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 scripts/apibuild.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/scripts/apibuild.py b/scripts/apibuild.py
index bafde0e0ab..1235e75999 100755
--- a/scripts/apibuild.py
+++ b/scripts/apibuild.py
@@ -2265,11 +2265,15 @@ class docBuilder:
             output.write(" string='%s'" % strValue)
         else:
             output.write(" raw='%s'" % escape(rawValue))
+
+        (comment, since) = self.retrieve_comment_tags(name, desc)
+        if len(since) > 0:
+            output.write(" version='%s'" % escape(since))
         output.write(">\n")
 
-        if desc is not None and desc != "":
-            output.write("      <info><![CDATA[%s]]></info>\n" % (desc))
-            self.indexString(name, desc)
+        if comment is not None and comment != "":
+            output.write("      <info><![CDATA[%s]]></info>\n" % (comment))
+            self.indexString(name, comment)
         for arg in args:
             (name, desc) = arg
             if desc is not None and desc != "":
-- 
2.35.1



More information about the libvir-list mailing list