Re: G-O-I under MinGW (was: Sbuild update 4.1.1)

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

 



>>> On 2014/04/16 at 02:57 PM, LRN <lrn1986@xxxxxxxxx> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 16.04.2014 16:43, Martin Schlemmer wrote:
>> Hi,
>> 
>>> gobject-introspection might fail to generate stuff (failure at 
>>> shutil.rmtree() in gdumpparser.py), especially on slow machines.
>>> Re-run the build from the last step. No new insights into this
>>> bug.
>>> 
>> 
>> Attached is an old patch (I used Dieterv's G-O-I branch) that fixes
>> this mostly for me.
>> 
>> From what I could determine at the time, either the Anti-Virus or
>> some other culprit still had the .exe locked, so the rm failed the
>> first time. Waiting (might make it longer for slower machines) on
>> failure seems to fix it.
>> 
>> 
> 
> I already have something similar[1] applied.
> 

On the G-O-I subject, and since you mentioned Webkit, there is another issue with Webkit and its generated DOM bindings when it comes to G-O-I.

At least here, the generated code have Win line endings, and this breaks the scanner. This happens in two ways:

- scannerlexer.l happily adds the CR's, but parse_comment_block() from annotationparser.py splits on LF, so the regex's scanning for comment blocks fails and results in no comment blocks being attached to functions, etc., causing introspectable="0" all over the place

- little less an issue, but because gcc's output in sourcescanner.py via a pipe, somewhere MSYS's line ending code get things wrong, and you end up with <CR><CR><LF> instead of just <CR><LF>. The only impact here is missing:

      <doc xml:whitespace="preserve">...</doc>

  bits, but I have not really tried to track the P.O.F. down, I just avoided the pipe.

What I did for these was:
- strip CR's in scannerlexer.l (if followed by a LF) - could probably fix it in annotationparser.py, but this seemed easier
- use gcc's -o argument instead of piping the output

The patch is against 1.36.0 is tested, the one against 1.38.0 is not with Webkit at least. If I get time I will update to the latest sources and see if anything new breaks.


Regards,
Martin




Vrywaringsklousule / Disclaimer:  http://www.nwu.ac.za/it/gov-man/disclaimer.html 

--- gobject-introspection-1.36.0/giscanner/scannerlexer.l	2014-03-11 09:50:11 +0200
+++ gobject-introspection-1.36.0.az/giscanner/scannerlexer.l	2014-01-14 18:50:24 +0200
@@ -239,7 +239,11 @@ parse_comment (GISourceScanner *scanner)
   while (c2 != EOF && !(c1 == '*' && c2 == '/'))
     {
       if (!skip)
-        g_string_append_c (string, c1);
+        if (c1 == '\r' && c2 == '\n')
+          /* Skip Windows line-feeds */
+          ;
+        else
+          g_string_append_c (string, c1);
 
       if (c1 == '\n')
         lineno++;
diff -uprN gobject-introspection-1.36.0/giscanner/sourcescanner.py gobject-introspection-1.36.0.az/giscanner/sourcescanner.py
--- gobject-introspection-1.36.0/giscanner/sourcescanner.py	2014-03-11 09:50:11 +0200
+++ gobject-introspection-1.36.0.az/giscanner/sourcescanner.py	2014-01-15 16:55:51 +0200
@@ -291,9 +291,14 @@ class SourceScanner(object):
         cpp_args += ['-E', '-C', '-I.', '-']
 
         cpp_args += self._cpp_options
+
+        # XXX: Use gcc's output switch instead of STDOUT, else Shell interaction
+        #      can cause mangling of line-endings (MINGW32/MSYS).
+        tmp = tempfile.mktemp()
+        cpp_args += ['-o', tmp]
+
         proc = subprocess.Popen(cpp_args,
-                                stdin=subprocess.PIPE,
-                                stdout=subprocess.PIPE)
+                                stdin=subprocess.PIPE)
 
         for define in defines:
             proc.stdin.write('#ifndef %s\n' % (define, ))
@@ -306,22 +311,12 @@ class SourceScanner(object):
             proc.stdin.write('#include <%s>\n' % (filename, ))
         proc.stdin.close()
 
-        tmp = tempfile.mktemp()
-        fp = open(tmp, 'w+')
-        while True:
-            data = proc.stdout.read(4096)
-            if data is None:
-                break
-            fp.write(data)
-            if len(data) < 4096:
-                break
-        fp.seek(0, 0)
-
         assert proc, 'Proc was none'
         proc.wait()
         if proc.returncode != 0:
             raise SystemExit('Error while processing the source.')
 
+        fp = open(tmp, 'r+')
         self._scanner.parse_file(fp.fileno())
         fp.close()
         os.unlink(tmp)
diff -uprN gobject-introspection-1.36.0/scannerlexer.c gobject-introspection-1.36.0.az/scannerlexer.c
--- gobject-introspection-1.36.0/scannerlexer.c	2014-03-11 09:50:10 +0200
+++ gobject-introspection-1.36.0.az/scannerlexer.c	2014-03-11 10:27:34 +0200
@@ -2754,7 +2754,11 @@ parse_comment (GISourceScanner *scanner)
   while (c2 != EOF && !(c1 == '*' && c2 == '/'))
     {
       if (!skip)
-        g_string_append_c (string, c1);
+        if (c1 == '\r' && c2 == '\n')
+          /* Skip Windows line-feeds */
+          ;
+        else
+          g_string_append_c (string, c1);
 
       if (c1 == '\n')
         lineno++;
diff -uprN gobject-introspection-1.38.0/giscanner/scannerlexer.l gobject-introspection-1.38.0.az/giscanner/scannerlexer.l
--- gobject-introspection-1.38.0/giscanner/scannerlexer.l	2013-07-10 18:13:23 +0200
+++ gobject-introspection-1.38.0.az/giscanner/scannerlexer.l	2014-03-11 16:37:17 +0200
@@ -248,7 +249,11 @@ parse_gtk_doc_comment (GISourceScanner *
   while (c2 != EOF && !(c1 == '*' && c2 == '/'))
     {
       if (!skip)
-        g_string_append_c (string, c1);
+        if (c1 == '\r' && c2 == '\n')
+          /* Skip Windows line-feeds */
+          ;
+        else
+          g_string_append_c (string, c1);
 
       if (c1 == '\n')
         lineno++;
diff -uprN gobject-introspection-1.38.0/giscanner/sourcescanner.py gobject-introspection-1.38.0.az/giscanner/sourcescanner.py
--- gobject-introspection-1.38.0/giscanner/sourcescanner.py	2013-07-10 18:13:23 +0200
+++ gobject-introspection-1.38.0.az/giscanner/sourcescanner.py	2014-03-11 16:37:17 +0200
@@ -291,9 +291,13 @@ class SourceScanner(object):
         cpp_args += ['-E', '-C', '-I.', '-']
         cpp_args += self._cpp_options
 
+        # XXX: Use gcc's output switch instead of STDOUT, else Shell interaction
+        #      can cause mangling of line-endings (MINGW32/MSYS).
+        tmp_name = tempfile.mktemp()
+        cpp_args += ['-o', tmp_name]
+
         proc = subprocess.Popen(cpp_args,
-                                stdin=subprocess.PIPE,
-                                stdout=subprocess.PIPE)
+                                stdin=subprocess.PIPE)
 
         for define in defines:
             proc.stdin.write('#ifndef %s\n' % (define, ))
@@ -302,22 +309,12 @@ class SourceScanner(object):
             proc.stdin.write('#include <%s>\n' % (filename, ))
         proc.stdin.close()
 
-        tmp_fd, tmp_name = tempfile.mkstemp()
-        fp = os.fdopen(tmp_fd, 'w+b')
-        while True:
-            data = proc.stdout.read(4096)
-            if data is None:
-                break
-            fp.write(data)
-            if len(data) < 4096:
-                break
-        fp.seek(0, 0)
-
         assert proc, 'Proc was none'
         proc.wait()
         if proc.returncode != 0:
             raise SystemExit('Error while processing the source.')
 
+        fp = open(tmp_name, 'r+b')
         self._scanner.parse_file(fp.fileno())
         fp.close()
         os.unlink(tmp_name)
diff -uprN gobject-introspection-1.38.0/scannerlexer.c gobject-introspection-1.38.0.az/scannerlexer.c
--- gobject-introspection-1.38.0/scannerlexer.c	2013-09-24 15:42:57 +0200
+++ gobject-introspection-1.38.0.az/scannerlexer.c	2014-03-11 16:37:17 +0200
@@ -2840,7 +2840,11 @@ parse_gtk_doc_comment (GISourceScanner *
   while (c2 != EOF && !(c1 == '*' && c2 == '/'))
     {
       if (!skip)
-        g_string_append_c (string, c1);
+        if (c1 == '\r' && c2 == '\n')
+          /* Skip Windows line-feeds */
+          ;
+        else
+          g_string_append_c (string, c1);
 
       if (c1 == '\n')
         lineno++;
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux