From 54adf28ba2f6f039c723648a097770479d086874 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 23 Jun 2011 18:41:28 -0400 Subject: 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(-) delete mode 100755 misc/update-gio-annotations.py delete mode 100755 misc/update-gobject-annotations.py (limited to 'misc') 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) -- cgit v1.2.1