summaryrefslogtreecommitdiff
path: root/tools/upbc.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-08-02 00:14:45 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-08-02 00:14:45 -0700
commit10cdab28e983187a2c99c4bf66053954846f051d (patch)
tree9995d6c5e4ea3730f9969bec860666bff028a4cc /tools/upbc.c
parent62dbeee8f69902b87ef11d13cef54ae261d74e6f (diff)
Add a friendly comment at the top of auto-generated C files.
Diffstat (limited to 'tools/upbc.c')
-rw-r--r--tools/upbc.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/tools/upbc.c b/tools/upbc.c
index 8eec85c..414d129 100644
--- a/tools/upbc.c
+++ b/tools/upbc.c
@@ -372,10 +372,30 @@ static void add_submsgs(void *data, struct upb_msg *m, struct upb_strtable *t)
/* write_messages_c emits a .c file that contains the data of a protobuf,
* serialized as C structures. */
static void write_message_c(void *data, struct upb_msg *m,
- char *cident, char *hfile_name, FILE *stream)
+ char *cident, char *hfile_name,
+ int argc, char *argv[], char *infile_name,
+ FILE *stream)
{
- fputs("/* This file was generated by upbc (the upb compiler). "
- "Do not edit. */\n\n", stream),
+ fputs(
+ "/*\n"
+ " * This file is a data dump of a protocol buffer into a C structure.\n"
+ " * It was created by the upb compiler (upbc) with the following\n"
+ " * command-line:\n"
+ " *\n", stream);
+ fputs(" * ", stream);
+ for(int i = 0; i < argc; i++) {
+ fputs(argv[i], stream);
+ if(i < argc-1) fputs(" ", stream);
+ }
+ fputs("\n *\n", stream);
+ fprintf(stream, " * This file is a dump of '%s'.\n", infile_name);
+ fputs(
+ " * It contains exactly the same data, but in a C structure form\n"
+ " * instead of a serialized protobuf. This file contains no code,\n"
+ " * only data.\n"
+ " *\n"
+ " * This file was auto-generated. Do not edit. */\n\n", stream);
+
fprintf(stream, "#include \"%s\"\n\n", hfile_name);
/* Gather all strings into a giant string. Use a hash to prevent adding the
@@ -652,7 +672,7 @@ int main(int argc, char *argv[])
if(cident) {
FILE *c_file = fopen(c_filename, "w");
if(!c_file) error("Failed to open .h output file");
- write_message_c(fds, c.fds_msg, cident, h_filename, c_file);
+ write_message_c(fds, c.fds_msg, cident, h_filename, argc, argv, input_file, c_file);
fclose(c_file);
}
upb_context_free(&c);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback