mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
apibuild: Introduce app class
All top-level functions have been moved to this class. On top of that, the app.warning() method has been defined, so that calls to it - already present in rebuild() - can actually succeed.
This commit is contained in:
parent
ccaceab7bd
commit
4a98ebb07c
@ -2584,57 +2584,65 @@ class docBuilder:
|
|||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
|
|
||||||
def rebuild(name):
|
class app:
|
||||||
if name not in ["libvirt", "libvirt-qemu", "libvirt-lxc", "libvirt-admin"]:
|
def warning(self, msg):
|
||||||
self.warning("rebuild() failed, unknown module %s") % name
|
global warnings
|
||||||
return None
|
warnings = warnings + 1
|
||||||
builder = None
|
print msg
|
||||||
srcdir = os.path.abspath((os.environ["srcdir"]))
|
|
||||||
builddir = os.path.abspath((os.environ["builddir"]))
|
def rebuild(self, name):
|
||||||
if srcdir == builddir:
|
if name not in ["libvirt", "libvirt-qemu", "libvirt-lxc", "libvirt-admin"]:
|
||||||
builddir = None
|
self.warning("rebuild() failed, unknown module %s") % name
|
||||||
if glob.glob(srcdir + "/../src/libvirt.c") != [] :
|
return None
|
||||||
if not quiet:
|
builder = None
|
||||||
print "Rebuilding API description for %s" % name
|
srcdir = os.path.abspath((os.environ["srcdir"]))
|
||||||
dirs = [srcdir + "/../src",
|
builddir = os.path.abspath((os.environ["builddir"]))
|
||||||
srcdir + "/../src/util",
|
if srcdir == builddir:
|
||||||
srcdir + "/../include/libvirt"]
|
builddir = None
|
||||||
if builddir:
|
if glob.glob(srcdir + "/../src/libvirt.c") != [] :
|
||||||
dirs.append(builddir + "/../include/libvirt")
|
if not quiet:
|
||||||
if glob.glob(srcdir + "/../include/libvirt/libvirt.h") == [] :
|
print "Rebuilding API description for %s" % name
|
||||||
dirs.append("../include/libvirt")
|
dirs = [srcdir + "/../src",
|
||||||
builder = docBuilder(name, srcdir, dirs, [])
|
srcdir + "/../src/util",
|
||||||
elif glob.glob("src/libvirt.c") != [] :
|
srcdir + "/../include/libvirt"]
|
||||||
if not quiet:
|
if builddir:
|
||||||
print "Rebuilding API description for %s" % name
|
dirs.append(builddir + "/../include/libvirt")
|
||||||
builder = docBuilder(name, srcdir,
|
if glob.glob(srcdir + "/../include/libvirt/libvirt.h") == [] :
|
||||||
["src", "src/util", "include/libvirt"],
|
dirs.append("../include/libvirt")
|
||||||
[])
|
builder = docBuilder(name, srcdir, dirs, [])
|
||||||
else:
|
elif glob.glob("src/libvirt.c") != [] :
|
||||||
self.warning("rebuild() failed, unable to guess the module")
|
if not quiet:
|
||||||
return None
|
print "Rebuilding API description for %s" % name
|
||||||
builder.scan()
|
builder = docBuilder(name, srcdir,
|
||||||
builder.analyze()
|
["src", "src/util", "include/libvirt"],
|
||||||
builder.serialize()
|
[])
|
||||||
return builder
|
else:
|
||||||
|
self.warning("rebuild() failed, unable to guess the module")
|
||||||
|
return None
|
||||||
|
builder.scan()
|
||||||
|
builder.analyze()
|
||||||
|
builder.serialize()
|
||||||
|
return builder
|
||||||
|
|
||||||
|
#
|
||||||
|
# for debugging the parser
|
||||||
|
#
|
||||||
|
def parse(self, filename):
|
||||||
|
parser = CParser(filename)
|
||||||
|
idx = parser.parse()
|
||||||
|
return idx
|
||||||
|
|
||||||
#
|
|
||||||
# for debugging the parser
|
|
||||||
#
|
|
||||||
def parse(filename):
|
|
||||||
parser = CParser(filename)
|
|
||||||
idx = parser.parse()
|
|
||||||
return idx
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
app = app()
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
debug = 1
|
debug = 1
|
||||||
parse(sys.argv[1])
|
app.parse(sys.argv[1])
|
||||||
else:
|
else:
|
||||||
rebuild("libvirt")
|
app.rebuild("libvirt")
|
||||||
rebuild("libvirt-qemu")
|
app.rebuild("libvirt-qemu")
|
||||||
rebuild("libvirt-lxc")
|
app.rebuild("libvirt-lxc")
|
||||||
rebuild("libvirt-admin")
|
app.rebuild("libvirt-admin")
|
||||||
if warnings > 0:
|
if warnings > 0:
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user