]> sourceware.org Git - automake.git/commitdiff
* lib/Automake/Channels.pm (buffering, backlog): New variables.
authorAlexandre Duret-Lutz <adl@gnu.org>
Fri, 23 Aug 2002 12:24:48 +0000 (12:24 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Fri, 23 Aug 2002 12:24:48 +0000 (12:24 +0000)
(buffer_messages, flush_messages): New functions.
(@EXPORT): Add buffer_messages and flush_messages.
* automake.in (generate_makefile): Call buffer_messages and
flush_messages to buffer warnings until AUTOMAKE_OPTIONS has
been read.

ChangeLog
automake.in
lib/Automake/Channels.pm

index 5b20c7210d536cacc96cf569b67f626420f611b0..0e962ff8b3d87c514156aefa3203331ce817024c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2002-08-23  Alexandre Duret-Lutz  <duret_g@epita.fr>
 
+       * lib/Automake/Channels.pm (buffering, backlog): New variables.
+       (buffer_messages, flush_messages): New functions.
+       (@EXPORT): Add buffer_messages and flush_messages.
+       * automake.in (generate_makefile): Call buffer_messages and
+       flush_messages to buffer warnings until AUTOMAKE_OPTIONS has
+       been read.
+
        * automake.in (read_am_file): File computation of path to
        included file, when $(top_srcdir) is not used.
        * tests/include2.test: Augment.
index 757898a48cb96e26bae7d603711df1726672fc86..ddad1e3b1b818dcc4bc12bacb26be8a1c150f237 100755 (executable)
@@ -1529,6 +1529,10 @@ sub generate_makefile
 
     # Any warning setting now local to this Makefile.am.
     &dup_channel_setup;
+    # AUTOMAKE_OPTIONS can contains -W flags to disable or enable
+    # warnings for this file.  So hold any warning issued before
+    # we have processed AUTOMAKE_OPTIONS.
+    &buffer_messages ('warning');
 
     # Name of input file ("Makefile.am") and output file
     # ("Makefile.in").  These have no directory components.
@@ -1549,9 +1553,13 @@ sub generate_makefile
     &read_main_am_file ($makefile . '.am');
     if (&handle_options)
     {
-       # Fatal error.  Just return, so we can continue with next file.
-       return;
+      # Process buffered warnings.
+      &flush_messages;
+      # Fatal error.  Just return, so we can continue with next file.
+      return;
     }
+    # Process buffered warnings.
+    &flush_messages;
 
     # There are a few install-related variables that you should not define.
     foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
index b543c178f73fc63b0a17104bbc7e5bf920ad3b50..31361081ebbbabe4393d415e06142ef6e81b310d 100644 (file)
@@ -68,6 +68,7 @@ our @EXPORT = qw ($exit_code $warnings_are_errors
                  &register_channel &msg &exists_channel &channel_type
                  &setup_channel &setup_channel_type
                   &dup_channel_setup &drop_channel_setup
+                 &buffer_messages &flush_messages
                  US_GLOBAL US_LOCAL
                  UP_NONE UP_TEXT UP_LOC_TEXT);
 
@@ -429,6 +430,10 @@ both print
 
 =cut
 
+# See buffer_messages() and flush_messages() below.
+our %buffering = ();           # The map of channel types to buffer.
+our @backlog = ();             # The buffer of messages.
+
 sub msg ($$;$%)
 {
   my ($channel, $location, $message, %options) = @_;
@@ -444,6 +449,12 @@ sub msg ($$;$%)
   my %opts = %{$channels{$channel}};
   _merge_options (%opts, %options);
 
+  if (exists $buffering{$opts{'type'}})
+    {
+      push @backlog, [@_];
+      return;
+    }
+
   # Print the message if needed.
   if (_print_message ($location, $message, %opts))
     {
@@ -525,6 +536,46 @@ sub drop_channel_setup ()
   %channels = %$saved;
 }
 
+=item C<buffer_messages (@types)>, C<flush_messages ()>
+
+By default, when C<msg> is called, messages are processed immediately.
+
+Sometimes it is necessary to delay the output of messages.
+For instance you might want to make diagnostics before
+channels have been completly configured.
+
+After C<buffer_messages(@types)> has been called, messages sent with
+C<msg> to a channel whose type is listed in C<@types> will be stored in a
+list for later processing.
+
+This backlog of messages is processed when C<flush_messages> is
+called, with the current channel options (not the options in effect,
+at the time of C<msg>).  So for instance if some channel was silenced
+in the meantime, messages to this channels will not be print.
+
+C<flush_messages> cancels the effect of C<buffer_messages>.  Following
+calls to C<msg> are processed immediately as usual.
+
+=cut
+
+sub buffer_messages (@)
+{
+  foreach my $type (@_)
+    {
+      $buffering{$type} = 1;
+    }
+}
+
+sub flush_messages ()
+{
+  %buffering = ();
+  foreach my $args (@backlog)
+    {
+      &msg (@$args);
+    }
+  @backlog = ();
+}
+
 =back
 
 =head1 HISTORY
This page took 0.0442 seconds and 5 git commands to generate.