[gobject-introspection] update-glib-annotations.py: Attempt to make work for srcdir!=builddir



commit fcb89c77f1f9c2819ed3cf9e7bb66cf142d1080d
Author: Colin Walters <walters verbum org>
Date:   Fri Jul 22 17:51:38 2011 -0400

    update-glib-annotations.py: Attempt to make work for srcdir!=builddir
    
    This doesn't quite work yet because we need to know from glib which
    files are in srcdir and which are in builddir.
    
    Also add some debugging prints.

 misc/update-glib-annotations.py |   39 ++++++++++++++++++++++++---------------
 1 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/misc/update-glib-annotations.py b/misc/update-glib-annotations.py
index 97e5f9d..315b43c 100755
--- a/misc/update-glib-annotations.py
+++ b/misc/update-glib-annotations.py
@@ -16,6 +16,17 @@ for d in possible_builddirs:
 assert builddir is not None
 annotation_tool_base_args = [os.path.join(builddir, 'g-ir-annotation-tool'), '--extract']
 
+def directory_includes(dirs, srcdir, builddir):
+    result = []
+    result.append('-I' + srcdir)
+    if srcdir != builddir:
+        result.append('-I' + builddir)
+    for name in dirs:
+        result.append('-I' + os.path.join(srcdir, name))
+        if srcdir != builddir:
+            result.append('-I' + os.path.join(builddir, name))
+    return result
+
 def extract_glib_annotations(srcdir, builddir, outfile):
     projname = 'glib'
     headersfile = os.path.join(builddir, projname, projname + '-public-headers.txt')
@@ -33,10 +44,7 @@ def extract_glib_annotations(srcdir, builddir, outfile):
         if sourcename.endswith('.c'):
             sources.append(os.path.join(subdir, sourcename))
     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,
+                                 ['-DGLIB_COMPILATION'] + directory_includes(['glib', 'gmodule'], srcdir, builddir) + sources,
                                  stdout=outfile)
 
 def extract_gobject_annotations(srcdir, builddir, outfile):
@@ -54,11 +62,7 @@ def extract_gobject_annotations(srcdir, builddir, outfile):
         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,
+                                 ['-DGOBJECT_COMPILATION'] + directory_includes(['glib', 'gobject', 'gmodule'], srcdir, builddir) + sources,
                                  stdout=outfile)
 
 def extract_gio_annotations(srcdir, builddir, outfile):
@@ -77,12 +81,7 @@ def extract_gio_annotations(srcdir, builddir, outfile):
             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,
+                                  '-DGIO_COMPILATION'] + directory_includes(['glib', 'gmodule', 'gobject', 'gio'], srcdir, builddir) + sources,
                                  stdout=outfile)
 
 if __name__ == '__main__':
@@ -92,21 +91,31 @@ if __name__ == '__main__':
     else:
         builddir = srcdir
 
+    print "Using source directory: %r build directory: %r" % (srcdir, builddir)
+
     srcname = '../gir/glib-2.0.c'
     srcfile = open(srcname + '.tmp', 'w')
     extract_glib_annotations(srcdir, builddir, srcfile)
     srcfile.close()
     os.rename(srcname + '.tmp', srcname)
 
+    print "Updated %r" % (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)
 
+    print "Updated %r" % (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)
 
+    print "Updated %r" % (srcname, )
+
+    print "Done; run \"git diff\" to see any changes."
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]