GNOME Bugzilla – Bug 770175
Add command line argument to mkenums and genmarshal to write output to a file
Last modified: 2016-11-08 15:24:42 UTC
Currently glib-genmarshal and glib-mkenums write their results to stdout. This makes it hard to integrate with build tools that don't do stdout redirection. Make is also tricky because to use these reliably you need to do something like 'glib-mkenums [args] > tmpfile && mv tmpfile header.h'. Please make it possible to write to files directly by adding command line argument like '-o outputfile.h'.
Created attachment 333851 [details] [review] glib-mkenum: add --output option to write output to a file I also have a simpler variant that just writes the output straight to the file instead of using a temp file and renaming that later, in case anyone prefers that. I should add that my perl skills are pretty basic, but this seems to work for me at least.
Created attachment 333919 [details] [review] glib-mkenums: add --output option to write output to a file (No change, just fixed typo in commit message)
Created attachment 333920 [details] [review] glib-genmarshal: add --output option to write output to a file
Review of attachment 333919 [details] [review]: I don't really speak Perl anymore, but it looks OK.
Review of attachment 333920 [details] [review]: OK.
Review of attachment 333920 [details] [review]: ::: gobject/glib-genmarshal.c @@ +814,3 @@ + if (output_fn) + { + output_tmpfn = g_strconcat (output_fn, ".tmp", NULL); Why not use g_mkstemp() instead?
(In reply to Emmanuele Bassi (:ebassi) from comment #6) > + if (output_fn) > + { > + output_tmpfn = g_strconcat (output_fn, ".tmp", NULL); > > Why not use g_mkstemp() instead? Because we ultimately need a FILE * (for fout) and g_mkstemp() returns an fd integer which we'd then have to turn into a FILE * with fdopen(), which means some more work to handle portability and/or test on non-POSIX platforms. I think _fdopen() is available at least on newer MSVC though (MSVC 2015). I just went for the KISS approach for now, and that's also what's done in most Makefile rules as far as I know. Please let me know if you'd like me to change it.
Created attachment 335499 [details] [review] glib-genmarshal: add --output option to write output to a file (v2) Updated version using g_mkstemp() now. Tested on Linux and Windows.
Comment on attachment 333919 [details] [review] glib-mkenums: add --output option to write output to a file This was pushed a while back.
Comment on attachment 335499 [details] [review] glib-genmarshal: add --output option to write output to a file (v2) This was pushed a while back.