diff options
-rwxr-xr-x | gir/update-glib-sources | 117 | ||||
-rw-r--r-- | giscanner/annotationmain.py | 8 | ||||
-rwxr-xr-x | misc/extract-gio-sources.sh | 10 | ||||
-rwxr-xr-x | misc/extract-gobject-sources.sh | 9 |
4 files changed, 123 insertions, 21 deletions
diff --git a/gir/update-glib-sources b/gir/update-glib-sources new file mode 100755 index 00000000..e7e5b46a --- /dev/null +++ b/gir/update-glib-sources @@ -0,0 +1,117 @@ +#!/usr/bin/python +# Because we want to avoid a circular build dependency +# between glib and gobject-introspection, this script +# extracts the headers and documentation comments from +# the GLib source tree, which we then commit. +# +# Run this script whenever GLib, GObject, Gio public API changes. +# Example: +# ./update-glib-sources code gio /src/checkout/glib > gio-2.0.c +# +# Copyright (C) 2010 Red Hat, Inc. +# Written by Colin Walters <walters@verbum.org> +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import sys +import optparse +import glob + +def usage(ecode): + print "Usage: %s MODE MODULE /path/to/glib/source" % (sys.argv[0], ) + print " MODE is one of \"headers\" or \"code\"" + print " MODULE is one of \"glib\" \"gobject\" \"gio\"" + print "Example: %s headers gobject" % (sys.argv[0], ) + sys.exit(ecode) + +def main(): + cwd = os.getcwd() + if not os.path.basename(cwd) == 'gir': + print "Must be run from gir/ directory" + sys.exit(1) + parser = optparse.OptionParser("%prog MODE MODULE") + if len(sys.argv) != 4: + usage(1) + mode = sys.argv[1] + if mode not in ['headers', 'code']: + usage(1) + module = sys.argv[2] + if module not in ['glib', 'gobject', 'gio']: + usage(1) + glibdir = sys.argv[3] + if not os.path.isfile(os.path.join(glibdir, 'glib-2.0.pc.in')): + print "\"%s\" doesn't look like a compiled GLib source tree" % (glibdir, ) + sys.exit(1) + flags = None + srcdir = None + if module == 'gio': + flags = ['-DGIO_COMPILATION', + '-I' + glibdir] + for path in ['glib', 'gobject', 'gmodule', 'gio']: + flags.append('-I' + os.path.join(glibdir, path)) + srcdir = os.path.join(glibdir, 'gio') + elif module == 'gobject': + flags = ['-DGOBJECT_COMPILATION', + '-I' + glibdir] + for path in ['glib', 'gobject', 'gmodule']: + flags.append('-I' + os.path.join(glibdir, path)) + srcdir = os.path.join(glibdir, 'gobject') + elif module == 'glib': + flags = ['-DGLIB_COMPILATION', + '-I' + glibdir] + for path in ['glib', 'gmodule']: + flags.append('-I' + os.path.join(glibdir, path)) + srcdir = os.path.join(glibdir, 'glib') + else: + assert False, "Should not be reached" + + if not srcdir.endswith('/'): + srcdir = srcdir + '/' + + if mode == 'code': + args = ['../g-ir-annotation-tool', '-e'] + args.extend(flags) + files = glob.glob(srcdir + '*.[ch]') + files.sort() + args.extend() + sys.stderr.write("Running %r\n" % (args, )) + sys.stderr.flush() + os.environ['UNINSTALLED_INTROSPECTION_SRCDIR'] = os.path.dirname(os.getcwd()) + os.execvp(args[0], args) + elif mode == 'headers': + headers = glob.glob(srcdir + '*.h') + headers.sort() + for header_filename in headers: + f = open(header_filename) + for line in f: + # All headers are in this single file + if line.startswith('#include <gio/'): + continue + sys.stdout.write(line) + f.close() + else: + assert False, "Should not be reached" + + sys.exit(1) + +if __name__ == '__main__': + main() diff --git a/giscanner/annotationmain.py b/giscanner/annotationmain.py index 2b45c149..8e42cba7 100644 --- a/giscanner/annotationmain.py +++ b/giscanner/annotationmain.py @@ -60,7 +60,11 @@ def annotation_main(args): ap = AnnotationParser() blocks = ap.parse(ss.get_comments()) print '/' + ('*' * 60) + '/' - print '/* THIS FILE IS GENERATED DO NOT EDIT */' + print ''' +/* GENERATED FILE - DO NOT EDIT + * See gobject-introspection/gir/extract-glib-sources to update. + */ +''' print '/' + ('*' * 60) + '/' print for block in blocks.values(): @@ -68,7 +72,7 @@ def annotation_main(args): print print print '/' + ('*' * 60) + '/' - print '/* THIS FILE IS GENERATED DO NOT EDIT */' + print '/* GENERATED FILE - DO NOT EDIT */' print '/' + ('*' * 60) + '/' return 0 diff --git a/misc/extract-gio-sources.sh b/misc/extract-gio-sources.sh deleted file mode 100755 index cf7dfe58..00000000 --- a/misc/extract-gio-sources.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -GLIBDIR=$1 -./g-ir-annotation-tool --extract \ - -DGIO_COMPILATION \ - -I$GLIBDIR \ - -I$GLIBDIR/glib \ - -I$GLIBDIR/gobject \ - -I$GLIBDIR/gmodule \ - -I$GLIBDIR/gio \ - $GLIBDIR/gio/*.c $GLIBDIR/gio/*.h diff --git a/misc/extract-gobject-sources.sh b/misc/extract-gobject-sources.sh deleted file mode 100755 index 9e7679e6..00000000 --- a/misc/extract-gobject-sources.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -GLIBDIR=$1 -tools/g-ir-annotation-tool --extract \ - -DGOBJECT_COMPILATION \ - -I$GLIBDIR \ - -I$GLIBDIR/glib \ - -I$GLIBDIR/gobject \ - -I$GLIBDIR/gmodule \ - $GLIBDIR/gobject/*.c $GLIBDIR/gobject/*.h |