After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770175 - Add command line argument to mkenums and genmarshal to write output to a file
Add command line argument to mkenums and genmarshal to write output to a file
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-08-20 19:07 UTC by Jussi Pakkanen
Modified: 2016-11-08 15:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
glib-mkenum: add --output option to write output to a file (2.82 KB, patch)
2016-08-21 22:29 UTC, Tim-Philipp Müller
none Details | Review
glib-mkenums: add --output option to write output to a file (2.83 KB, patch)
2016-08-22 15:45 UTC, Tim-Philipp Müller
committed Details | Review
glib-genmarshal: add --output option to write output to a file (3.35 KB, patch)
2016-08-22 15:46 UTC, Tim-Philipp Müller
none Details | Review
glib-genmarshal: add --output option to write output to a file (v2) (3.46 KB, patch)
2016-09-14 08:51 UTC, Tim-Philipp Müller
committed Details | Review

Description Jussi Pakkanen 2016-08-20 19:07:11 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'.
Comment 1 Tim-Philipp Müller 2016-08-21 22:29:24 UTC
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.
Comment 2 Tim-Philipp Müller 2016-08-22 15:45:51 UTC
Created attachment 333919 [details] [review]
glib-mkenums: add --output option to write output to a file

(No change, just fixed typo in commit message)
Comment 3 Tim-Philipp Müller 2016-08-22 15:46:20 UTC
Created attachment 333920 [details] [review]
glib-genmarshal: add --output option to write output to a file
Comment 4 Colin Walters 2016-08-23 19:02:36 UTC
Review of attachment 333919 [details] [review]:

I don't really speak Perl anymore, but it looks OK.
Comment 5 Colin Walters 2016-08-23 19:04:00 UTC
Review of attachment 333920 [details] [review]:

OK.
Comment 6 Emmanuele Bassi (:ebassi) 2016-08-23 21:13:15 UTC
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?
Comment 7 Tim-Philipp Müller 2016-08-23 21:50:52 UTC
(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.
Comment 8 Tim-Philipp Müller 2016-09-14 08:51:42 UTC
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 9 Tim-Philipp Müller 2016-11-08 15:24:35 UTC
Comment on attachment 333919 [details] [review]
glib-mkenums: add --output option to write output to a file

This was pushed a while back.
Comment 10 Tim-Philipp Müller 2016-11-08 15:24:42 UTC
Comment on attachment 335499 [details] [review]
glib-genmarshal: add --output option to write output to a file (v2)

This was pushed a while back.