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.
# 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.
&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')
®ister_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);
=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) = @_;
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))
{
%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