summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2011-06-23 18:41:28 -0400
committerColin Walters <walters@verbum.org>2011-06-23 18:41:28 -0400
commit54adf28ba2f6f039c723648a097770479d086874 (patch)
tree395e891fb9000a67e164fe97ad9a19c112592836 /misc
parent158db28b46eb1e9b24705bf8e9c3e6ca69ae54b4 (diff)
downloadgobject-introspection-54adf28ba2f6f039c723648a097770479d086874.tar.gz
update-glib-annotations.py: Merge annotation extraction scripts
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/update-gio-annotations.py28
-rwxr-xr-xmisc/update-glib-annotations.py104
-rwxr-xr-xmisc/update-gobject-annotations.py26
3 files changed, 94 insertions, 64 deletions
diff --git a/misc/update-gio-annotations.py b/misc/update-gio-annotations.py
deleted file mode 100755
index 9588dd39..00000000
--- a/misc/update-gio-annotations.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import sys
-
-if __name__ == '__main__':
- srcdir = sys.argv[1]
- sources = []
- projname = 'gio'
- subdir = os.path.join(srcdir, projname)
- headersfile = os.path.join(subdir, projname + '-public-headers.txt')
- f = open(headersfile)
- line = f.read()
- f.close()
- 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))
- os.execv('./g-ir-annotation-tool',
- ['./g-ir-annotation-tool', '--extract', '-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)
diff --git a/misc/update-glib-annotations.py b/misc/update-glib-annotations.py
index 63d83fa8..97e5f9db 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)
+
diff --git a/misc/update-gobject-annotations.py b/misc/update-gobject-annotations.py
deleted file mode 100755
index 47bd1ed8..00000000
--- a/misc/update-gobject-annotations.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import sys
-
-if __name__ == '__main__':
- srcdir = sys.argv[1]
- sources = []
- projname = 'gobject'
- subdir = os.path.join(srcdir, projname)
- headersfile = os.path.join(subdir, projname + '-public-headers.txt')
- f = open(headersfile)
- line = f.read()
- f.close()
- 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))
- os.execv('./g-ir-annotation-tool',
- ['./g-ir-annotation-tool', '--extract', '-DGOBJECT_COMPILATION',
- '-I' + srcdir,
- '-I' + os.path.join(srcdir, 'glib'),
- '-I' + os.path.join(srcdir, 'gobject'),
- '-I' + os.path.join(srcdir, 'gmodule')] + sources)