From patchwork Sun Aug 29 06:39:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basile Starynkevitch X-Patchwork-Id: 62932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 52B46B710C for ; Sun, 29 Aug 2010 16:40:13 +1000 (EST) Received: (qmail 10734 invoked by alias); 29 Aug 2010 06:40:11 -0000 Received: (qmail 10715 invoked by uid 22791); 29 Aug 2010 06:40:09 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-120-saturday.nerim.net (HELO maiev.nerim.net) (62.4.16.120) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 29 Aug 2010 06:40:02 +0000 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by maiev.nerim.net (Postfix) with ESMTP id 61911B8176; Sun, 29 Aug 2010 08:39:59 +0200 (CEST) Received: from glinka.lesours ([192.168.0.1]) by hector.lesours with esmtp (Exim 4.72) (envelope-from ) id 1OpbYc-0006Hf-Uw; Sun, 29 Aug 2010 08:39:58 +0200 Subject: Re: gengtype improvements for plugins. patch 2/N [verbosity] From: Basile Starynkevitch Reply-To: basile@starynkevitch.net To: jeremie.salvucci@free.fr Cc: gcc-patches@gcc.gnu.org In-Reply-To: <1283062592.3067.50.camel@glinka> References: <1283012591.3067.17.camel@glinka> <20100828170603.GA1108@gmx.de> <1283016347.3067.43.camel@glinka> <1283062592.3067.50.camel@glinka> Date: Sun, 29 Aug 2010 08:39:55 +0200 Message-ID: <1283063995.3067.63.camel@glinka> Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. --- ../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;