[gobject-introspection] update-glib-annotations.py: Merge annotation extraction scripts
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] update-glib-annotations.py: Merge annotation extraction scripts
- Date: Fri, 24 Jun 2011 14:21:36 +0000 (UTC)
commit 54adf28ba2f6f039c723648a097770479d086874
Author: Colin Walters <walters verbum org>
Date: Thu Jun 23 18:41:28 2011 -0400
update-glib-annotations.py: Merge annotation extraction scripts
misc/update-gio-annotations.py | 28 ----------
misc/update-glib-annotations.py | 104 ++++++++++++++++++++++++++++++++----
misc/update-gobject-annotations.py | 26 ---------
3 files changed, 94 insertions(+), 64 deletions(-)
---
diff --git a/misc/update-glib-annotations.py b/misc/update-glib-annotations.py
index 63d83fa..97e5f9d 100755
--- a/misc/update-glib-annotations.py
+++ b/misc/update-glib-annotations.py
@@ -1,17 +1,29 @@
#!/usr/bin/env python
+# Scan glib sources.
+# e.g.:
+# ./update-glib-annotations.py ../../glib ../../glib/_build
import os
import sys
+import subprocess
-if __name__ == '__main__':
- srcdir = sys.argv[1]
- sources = []
+possible_builddirs = ['../_build/', '..']
+builddir = None
+for d in possible_builddirs:
+ if os.path.isfile(os.path.join(d, 'g-ir-annotation-tool')):
+ builddir = d
+ break
+assert builddir is not None
+annotation_tool_base_args = [os.path.join(builddir, 'g-ir-annotation-tool'), '--extract']
+
+def extract_glib_annotations(srcdir, builddir, outfile):
projname = 'glib'
+ headersfile = os.path.join(builddir, projname, projname + '-public-headers.txt')
subdir = os.path.join(srcdir, projname)
- headersfile = os.path.join(subdir, projname + '-public-headers.txt')
f = open(headersfile)
line = f.read()
f.close()
+ sources = []
for headername in line.split(' '):
headername = headername.strip()
if headername == 'gi18n-lib.h':
@@ -20,9 +32,81 @@ if __name__ == '__main__':
for sourcename in os.listdir(subdir):
if sourcename.endswith('.c'):
sources.append(os.path.join(subdir, sourcename))
- os.execv('./g-ir-annotation-tool',
- ['./g-ir-annotation-tool', '--extract',
- '-DGLIB_COMPILATION',
- '-I' + srcdir,
- '-I' + os.path.join(srcdir, 'glib'),
- '-I' + os.path.join(srcdir, 'gmodule')] + sources)
+ return subprocess.check_call(annotation_tool_base_args +
+ ['-DGLIB_COMPILATION',
+ '-I' + srcdir,
+ '-I' + os.path.join(srcdir, 'glib'),
+ '-I' + os.path.join(srcdir, 'gmodule')] + sources,
+ stdout=outfile)
+
+def extract_gobject_annotations(srcdir, builddir, outfile):
+ projname = 'gobject'
+ headersfile = os.path.join(builddir, projname, projname + '-public-headers.txt')
+ subdir = os.path.join(srcdir, projname)
+ f = open(headersfile)
+ line = f.read()
+ f.close()
+ sources = []
+ for headername in line.split(' '):
+ headername = headername.strip()
+ sources.append(os.path.join(subdir, headername))
+ for sourcename in os.listdir(subdir):
+ if sourcename.endswith('.c'):
+ sources.append(os.path.join(subdir, sourcename))
+ return subprocess.check_call(annotation_tool_base_args +
+ ['-DGOBJECT_COMPILATION',
+ '-I' + srcdir,
+ '-I' + os.path.join(srcdir, 'glib'),
+ '-I' + os.path.join(srcdir, 'gobject'),
+ '-I' + os.path.join(srcdir, 'gmodule')] + sources,
+ stdout=outfile)
+
+def extract_gio_annotations(srcdir, builddir, outfile):
+ projname = 'gio'
+ headersfile = os.path.join(builddir, projname, projname + '-public-headers.txt')
+ subdir = os.path.join(srcdir, projname)
+ f = open(headersfile)
+ line = f.read()
+ f.close()
+ sources = []
+ for headername in line.split(' '):
+ headername = headername.strip()
+ sources.append(os.path.join(subdir, headername))
+ for sourcename in os.listdir(subdir):
+ if sourcename.endswith('.c'):
+ sources.append(os.path.join(subdir, sourcename))
+ return subprocess.check_call(annotation_tool_base_args +
+ ['-DGOBJECT_COMPILATION',
+ '-DGIO_COMPILATION',
+ '-I' + srcdir,
+ '-I' + os.path.join(srcdir, 'glib'),
+ '-I' + os.path.join(srcdir, 'gobject'),
+ '-I' + os.path.join(srcdir, 'gio'),
+ '-I' + os.path.join(srcdir, 'gmodule')] + sources,
+ stdout=outfile)
+
+if __name__ == '__main__':
+ srcdir = sys.argv[1]
+ if len(sys.argv) == 3:
+ builddir = sys.argv[2]
+ else:
+ builddir = srcdir
+
+ srcname = '../gir/glib-2.0.c'
+ srcfile = open(srcname + '.tmp', 'w')
+ extract_glib_annotations(srcdir, builddir, srcfile)
+ srcfile.close()
+ os.rename(srcname + '.tmp', srcname)
+
+ srcname = '../gir/gobject-2.0.c'
+ srcfile = open(srcname + '.tmp', 'w')
+ extract_gobject_annotations(srcdir, builddir, srcfile)
+ srcfile.close()
+ os.rename(srcname + '.tmp', srcname)
+
+ srcname = '../gir/gio-2.0.c'
+ srcfile = open(srcname + '.tmp', 'w')
+ extract_gio_annotations(srcdir, builddir, srcfile)
+ srcfile.close()
+ os.rename(srcname + '.tmp', srcname)
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]