This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gengtype improvements for plugins. patch 2/N [verbosity]


The second part of our series of patches add verbosity to gengtype. When
passed the -v flag (which can be given more than once), the gengtype
generator shows changed files (and also unchanged output files if passed
twice). 

The attached file relpatch02to01ter-verbosity.diff is a patch relative
to the latest patch we did send, that is to
http://gcc.gnu.org/ml/gcc-patches/2010-08/msg02058.html

This relative patch was obtained by 
diff -u -p -b gcc/gengtype.c gcc/gengtype.h \
     --from-file ../gcc-gengtype-01/

The corresponding gcc/ChangeLog entry is attached as
relpatch02to01ter-verbosity.ChangeLog

For convenience, I am also attaching the entire cumulated patch to trunk
r163612. It is not for reviewers, but for people wanting to test all our
patches at once quickly. The cumulated patch is against trunk r163612 as
an attached gzipped file all-patches-r163612-up-to-02.diff.gz

Ok for trunk?

Cheers.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***
--- ../gcc-gengtype-01/gengtype.c	2010-08-29 08:16:56.000000000 +0200
+++ gcc/gengtype.c	2010-08-29 08:17:58.000000000 +0200
@@ -163,6 +163,9 @@ char *write_state_filename;
 int do_dump;
 int do_debug;
 
+/* For verbose messages. */
+int verbosity_level;
+
 static outf_p create_file (const char *, const char *);
 
 static const char * get_file_basename (const char *);
@@ -1841,6 +1844,7 @@ static void
 close_output_files (void)
 {
   outf_p of;
+  int nbwrittenfiles = 0;
 
   for (of = output_files; of; of = of->next)
     {
@@ -1854,11 +1858,22 @@ close_output_files (void)
           fatal ("writing output file %s: %s", of->name, xstrerror (errno));
         if (fclose (newfile) != 0)
           fatal ("closing output file %s: %s", of->name, xstrerror (errno));
+	nbwrittenfiles++;
+	if (verbosity_level >= 1)
+	  printf ("gengtype write #%-3d %s\n", nbwrittenfiles, of->name);
+      }
+      else { 
+	/* output file remains unchanged. */
+	if (verbosity_level >= 2)
+	  printf ("gengtype keep %s\n", of->name);
       }
       free(of->buf);
       of->buf = NULL;
       of->bufused = of->buflength = 0;
-    }
+    };
+  
+  if (verbosity_level >= 1)
+    printf ("gengtype wrote %d files.\n", nbwrittenfiles);
 }
 
 struct flist {
@@ -4215,6 +4230,7 @@ static const struct option gengtype_long
 {
     { "help",      no_argument, NULL, 'h' },
     { "version",   no_argument, NULL, 'V' },
+    { "verbose",   no_argument, NULL, 'v' },
     { "dump",      no_argument, NULL, 'd' },
     { "debug",     no_argument, NULL, 'D' },
     { "plugin",    required_argument, NULL, 'P' },
@@ -4231,6 +4247,7 @@ print_usage (void)
 {
     printf ("Usage: %s\n", progname);
     printf ("\t -h | --help  \t# Give this help.\n");
+    printf ("\t -v | --verbose  \t# Increase verbosity. Can be given several times.\n");
     printf ("\t -D | --debug  \t# Lots of debug output to debug gengtype itself.\n");
     printf ("\t -V | --version  \t# Give version information.\n");
     printf ("\t -d | --dump  \t# Dump state for debugging.\n");
@@ -4267,6 +4284,9 @@ parse_program_options (int argc, char**a
 	case 'd': /* --dump */
 	    do_dump = 1;
 	    break;
+	case 'v': /* --verbose */
+	    verbosity_level++;
+	    break;
 	case 'D': /* --debug */
 	    do_debug = 1;
 	    break;
--- ../gcc-gengtype-01/gengtype.h	2010-08-29 08:16:56.000000000 +0200
+++ gcc/gengtype.h	2010-08-29 08:17:58.000000000 +0200
@@ -145,6 +145,9 @@ enum {
 };
 
 
+/* Level for verbose messages, e.g. output file generation... */
+extern int verbosity_level;
+
 /* For debugging purposes of gengtype itself!  */
 extern int do_dump;
 extern int do_debug;

Attachment: relpatch02to01ter-verbosity.ChangeLog
Description: Text document

Attachment: all-patches-r163612-up-to-02.diff.gz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]