From aa3efc8f1e889384fc3b33cd974ef8a66a52295e Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 23 Aug 2002 12:24:48 +0000 Subject: [PATCH] * 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. --- ChangeLog | 7 ++++++ automake.in | 12 ++++++++-- lib/Automake/Channels.pm | 51 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b20c721..0e962ff8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2002-08-23 Alexandre Duret-Lutz + * 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. diff --git a/automake.in b/automake.in index 757898a4..ddad1e3b 100755 --- a/automake.in +++ b/automake.in @@ -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') diff --git a/lib/Automake/Channels.pm b/lib/Automake/Channels.pm index b543c178..31361081 100644 --- a/lib/Automake/Channels.pm +++ b/lib/Automake/Channels.pm @@ -68,6 +68,7 @@ our @EXPORT = qw ($exit_code $warnings_are_errors ®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); @@ -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, C + +By default, when C 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 has been called, messages sent with +C 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 is +called, with the current channel options (not the options in effect, +at the time of C). So for instance if some channel was silenced +in the meantime, messages to this channels will not be print. + +C cancels the effect of C. Following +calls to C 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 -- 2.43.5