[glib: 1/2] glib-genmarshal: close output file




commit f346b9c8ce0064aa090f585966227eb914d8b7c9
Author: Aleksandr Mezin <mezin alexander gmail com>
Date:   Wed Mar 3 06:20:15 2021 +0600

    glib-genmarshal: close output file
    
    Close output file to ensure all buffered output actually gets written.
    
    Otherwise, glib-genmarshal output is sometimes empty (for example, when trying
    to build gdk-pixbuf on Windows, with Meson installed from .msi package).
    
    argparse.FileType doesn't get closed automagically when the script exits:
    https://bugs.python.org/issue13824
    
    Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2341

 gobject/glib-genmarshal.in | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/gobject/glib-genmarshal.in b/gobject/glib-genmarshal.in
index 7380f24a8..20e08e47b 100755
--- a/gobject/glib-genmarshal.in
+++ b/gobject/glib-genmarshal.in
@@ -864,7 +864,7 @@ def generate_marshallers_body(outfile, retval, params,
         outfile.write('\n\n')
 
 
-if __name__ == '__main__':
+def parse_args():
     arg_parser = argparse.ArgumentParser(description='Generate signal marshallers for GObject')
     arg_parser.add_argument('--prefix', metavar='STRING',
                             default='g_cclosure_user_marshal',
@@ -945,6 +945,10 @@ if __name__ == '__main__':
         print(VERSION_STR)
         sys.exit(0)
 
+    return args
+
+
+def generate(args):
     # Backward compatibility hack; some projects use both arguments to
     # generate the marshallers prototype in the C source, even though
     # it's not really a supported use case. We keep this behaviour by
@@ -1067,3 +1071,10 @@ if __name__ == '__main__':
 
         if args.header:
             generate_header_postamble(args.output, prefix=args.prefix, use_pragma=args.pragma_once)
+
+
+if __name__ == '__main__':
+    args = parse_args()
+
+    with args.output:
+        generate(args)


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