]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
* lib/Automake/Channels.pm (%_default_options): Add 'partial'.
authorAlexandre Duret-Lutz <adl@gnu.org>
Sun, 29 Sep 2002 14:51:25 +0000 (14:51 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sun, 29 Sep 2002 14:51:25 +0000 (14:51 +0000)
(_format_message): Rename as ...
(_format_sub_message): ... this.
(_format_message): New function, extracted from ...
(_print_message): ... here.  Honor the 'partial' option.
($partial): New variable.
* automake.in (handle_ltlibraries, check_ambiguous_conditional,
rule_define): Mark partial messages.

ChangeLog
automake.in
lib/Automake/Channels.pm

index 3ec77b799d1435db3545880a29b3f555622f3593..e4d8cf5ac0133d1800566c4396e15cf36666b359 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2002-09-29  Alexandre Duret-Lutz  <duret_g@epita.fr>
 
+       * lib/Automake/Channels.pm (%_default_options): Add 'partial'.
+       (_format_message): Rename as ...
+       (_format_sub_message): ... this.
+       (_format_message): New function, extracted from ...
+       (_print_message): ... here.  Honor the 'partial' option.
+       ($partial): New variable.
+       * automake.in (handle_ltlibraries, check_ambiguous_conditional,
+       rule_define): Mark partial messages.
+
        * automake.in (handle_ltlibraries): Record library locations in
        %liblocations, and print the previous declaration on error.
        * tests/libtool6.test: Check that the locations of the two
index 64a2899e8f13fe9f4104749b479d53fe5fd946b7..d8dda372ee5bd8047cf5c6e498b3aa762c624d6d 100755 (executable)
@@ -3372,7 +3372,7 @@ sub handle_ltlibraries
          if (defined $instdirs{$lib} && $instdirs{$lib} ne $dir)
            {
              err ($where, "`$lib' is already going to be installed in "
-                  . "`$instdirs{$lib}'");
+                  . "`$instdirs{$lib}'", partial => 1);
              err ($liblocations{$lib}, "`$lib' previously declared here");
            }
          else
@@ -6144,7 +6144,7 @@ sub check_ambiguous_conditional ($$$)
     conditional_ambiguous_p ($var, $cond, keys %{$var_value{$var}});
   if ($message)
     {
-      msg 'syntax', $where, "$message ...";
+      msg 'syntax', $where, "$message ...", partial => 1;
       msg_var ('syntax', $var, "... `$var' previously defined here");
       verb (macro_dump ($var));
     }
@@ -7585,7 +7585,7 @@ sub rule_define ($$$$$)
                  ## is legitimate. (This is phony.test.)
 
                  # msg ('syntax', $where,
-                 #      "redefinition of `$target'$condmsg...");
+                 #      "redefinition of `$target'$condmsg...", partial => 1);
                  # msg_cond_target ('syntax', $cond, $target,
                  #                "... `$target' previously defined here");
                }
@@ -7624,7 +7624,8 @@ sub rule_define ($$$$$)
              my $oldsource = $target_source{$target}{$cond};
              return () if $source eq $oldsource;
 
-             msg ('syntax', $where, "redefinition of `$target'$condmsg...");
+             msg ('syntax', $where, "redefinition of `$target'$condmsg...",
+                  partial => 1);
              msg_cond_target ('syntax', $cond, $target,
                               "... `$target' previously defined here");
              return ();
@@ -7645,7 +7646,7 @@ sub rule_define ($$$$$)
       if ($owner == TARGET_USER)
        {
          # For user rules, just diagnose the ambiguity.
-         msg 'syntax', $where, "$message ...";
+         msg 'syntax', $where, "$message ...", partial => 1;
          msg_cond_target ('syntax', $ambig_cond, $target,
                           "... `$target' previously defined here");
          return ();
@@ -7681,7 +7682,7 @@ sub rule_define ($$$$$)
          # Warn, because our workaround is meaningless in this case.
          if (scalar @conds == 0)
            {
-             msg 'syntax', $where, "$message ...";
+             msg 'syntax', $where, "$message ...", partial => 1;
              msg_cond_target ('syntax', $ambig_cond, $target,
                               "... `$target' previously defined here");
              return ();
index 5b15d2e28ee7155cce94efcdb985c7625f1e4895..37201e8328d1eb4c832f2885da74751c648b2d5f 100644 (file)
@@ -193,6 +193,45 @@ A string to append to each message emitted through this channel.
 
 Die with a stack backtrace after displaying the message.
 
+=item C<partial =E<gt> 0>
+
+When set, indicates a partial message that should
+be output along with the next message with C<partial> unset.
+Several partial messages can be stacked this way.
+
+Duplicate filtering will apply to the I<global> message resulting from
+all I<partial> messages, using the options from the last (non-partial)
+message.  Linking associated messages is the main reason to use this
+option.
+
+For instance the following messages
+
+  msg 'channel', 'foo:2', 'redefinition of A ...';
+  msg 'channel', 'foo:1', '... A previously defined here';
+  msg 'channel', 'foo:3', 'redefinition of A ...';
+  msg 'channel', 'foo:1', '... A previously defined here';
+
+will result in
+
+ foo:2: redefinition of A ...
+ foo:1: ... A previously defined here
+ foo:3: redefinition of A ...
+
+where the duplicate "I<... A previously defined here>" has been
+filtered out.
+
+Linking these messages using C<partial> as follows will prevent the
+fourth message to disappear.
+
+  msg 'channel', 'foo:2', 'redefinition of A ...', partial => 1;
+  msg 'channel', 'foo:1', '... A previously defined here';
+  msg 'channel', 'foo:3', 'redefinition of A ...', partial => 1;
+  msg 'channel', 'foo:1', '... A previously defined here';
+
+Note that because the stack of C<partial> messages is printed with the
+first non-C<partial> message, most options of C<partial> messages will
+be ignored.
+
 =back
 
 =cut
@@ -212,6 +251,7 @@ use vars qw (%_default_options %_global_duplicate_messages
    header => '',
    footer => '',
    backtrace => 0,
+   partial => 0,
    );
 
 # Filled with output messages as keys, to detect duplicates.
@@ -320,43 +360,67 @@ sub channel_type ($)
   return '';
 }
 
-# _format_message ($LEADER, $MESSAGE)
-# -----------------------------------
+# _format_sub_message ($LEADER, $MESSAGE)
+# ---------------------------------------
 # Split $MESSAGE at new lines and add $LEADER to each line.
-sub _format_message ($$)
+sub _format_sub_message ($$)
 {
   my ($leader, $message) = @_;
   return $leader . join ("\n" . $leader, split ("\n", $message)) . "\n";
 }
 
-# _print_message ($LOCATION, $MESSAGE, %OPTIONS)
-# ----------------------------------------------
-# Format the message, check duplicates, and print it.
-sub _print_message ($$%)
+# _format_message ($LOCATION, $MESSAGE, %OPTIONS)
+# -----------------------------------------------
+# Format the message.  Return a string ready to print.
+sub _format_message ($$%)
 {
   my ($location, $message, %opts) = @_;
-
-  return 0 if ($opts{'silent'});
-
-  # Format the message.
   my $msg = '';
   if (ref $location)
     {
       # If $LOCATION is a reference, assume it's an instance of the
       # Automake::Location class and display contexts.
       my $loc = $location->get || $me;
-      $msg = _format_message ("$loc: ",
-                             $opts{'header'} . $message . $opts{'footer'});
+      $msg = _format_sub_message ("$loc: ", $opts{'header'}
+                                 . $message . $opts{'footer'});
       for my $pair ($location->get_contexts)
        {
-         $msg .= _format_message ($pair->[0] . ":   ", $pair->[1]);
+         $msg .= _format_sub_message ($pair->[0] . ":   ", $pair->[1]);
        }
     }
   else
     {
       $location ||= $me;
-      $msg = _format_message ("$location: ",
-                             $opts{'header'} . $message . $opts{'footer'});
+      $msg = _format_sub_message ("$location: ", $opts{'header'}
+                                 . $message . $opts{'footer'});
+    }
+  return $msg;
+}
+
+# Store partial messages here. (See the 'partial' option.)
+use vars qw ($partial);
+$partial = '';
+
+# _print_message ($LOCATION, $MESSAGE, %OPTIONS)
+# ----------------------------------------------
+# Format the message, check duplicates, and print it.
+sub _print_message ($$%)
+{
+  my ($location, $message, %opts) = @_;
+
+  return 0 if ($opts{'silent'});
+
+  my $msg = _format_message ($location, $message, %opts);
+  if ($opts{'partial'})
+    {
+      # Incomplete message.   Store, don't print.
+      $partial .= $msg;
+      return;
+    }
+  else
+    {
+      # Prefix with any partial message send so far.
+      $msg = $partial . $msg;
     }
 
   # Check for duplicate message if requested.
@@ -454,7 +518,7 @@ both print
 =cut
 
 
-use vars qw (@backlog %buffering);
+use vars qw (@backlog %buffering @chain);
 
 # See buffer_messages() and flush_messages() below.
 %buffering = ();       # The map of channel types to buffer.