common/tools/raptor/RaptorUnreciped.pm
changeset 383 52675b624b66
parent 242 51e429810aba
child 764 d00048f1b036
--- a/common/tools/raptor/RaptorUnreciped.pm	Mon Aug 24 15:09:22 2009 +0100
+++ b/common/tools/raptor/RaptorUnreciped.pm	Wed Aug 26 12:30:59 2009 +0100
@@ -33,30 +33,154 @@
 
 $buildlog_subtag_status->{name} = 'buildlog_subtag_status';
 $buildlog_subtag_status->{next_status} = {};
+$buildlog_subtag_status->{on_start} = 'RaptorUnreciped::on_start_buildlog_subtag';
+$buildlog_subtag_status->{on_end} = 'RaptorUnreciped::on_end_buildlog_subtag';
+
+my $filename = '';
+my $failure_item = 0;
 
 my $characters = '';
+my $store_chars = 1;
+
+my $CATEGORY_RAPTORUNRECIPED = 'raptor_unreciped';
+my $CATEGORY_RAPTORUNRECIPED_NORULETOMAKETARGET = 'no_rule_to_make_target';
+my $CATEGORY_RAPTORUNRECIPED_TARGETNOTREMADEFORERRORS = 'target_not_remade_for_errors';
+my $CATEGORY_RAPTORUNRECIPED_NOTHINGTOBEDONEFOR = 'nothing_to_be_done_for';
+my $CATEGORY_RAPTORUNRECIPED_IGNORINGOLDCOMMANDSFORTARGET = 'ignoring_old_commands_for_target';
+my $CATEGORY_RAPTORUNRECIPED_OVERRIDINGCOMMANDSFORTARGET = 'overriding_commands_for_target';
+
+sub process
+{
+	my ($text, $component, $phase, $recipe, $file, $line) = @_;
+
+	my $category = $CATEGORY_RAPTORUNRECIPED;	
+	my $severity = '';
+	my $subcategory = '';
+	
+	if ($text =~ m,make\.exe: \*\*\* No rule to make target,)
+	{
+		$severity = $RaptorCommon::SEVERITY_MAJOR;
+		my $subcategory = $CATEGORY_RAPTORUNRECIPED_NORULETOMAKETARGET;
+		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
+	}
+	elsif ($text =~ m,make\.exe: Target .* not remade because of errors,)
+	{
+		$severity = $RaptorCommon::SEVERITY_MINOR;
+		my $subcategory = $CATEGORY_RAPTORUNRECIPED_TARGETNOTREMADEFORERRORS;
+		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
+	}
+	elsif ($text =~ m,: warning: ignoring old commands for target,)
+	{
+		$severity = $RaptorCommon::SEVERITY_MINOR;
+		my $subcategory = $CATEGORY_RAPTORUNRECIPED_IGNORINGOLDCOMMANDSFORTARGET;
+		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
+	}
+	elsif ($text =~ m,: warning: overriding commands for target,)
+	{
+		$severity = $RaptorCommon::SEVERITY_MINOR;
+		my $subcategory = $CATEGORY_RAPTORUNRECIPED_OVERRIDINGCOMMANDSFORTARGET;
+		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
+	}
+	elsif ($text =~ m,make\.exe: Nothing to be done for .*,)
+	{
+		$severity = $RaptorCommon::SEVERITY_MINOR;
+		my $subcategory = $CATEGORY_RAPTORUNRECIPED_NOTHINGTOBEDONEFOR;
+		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
+	}
+	elsif ($text =~ m,^(true|false)$,)
+	{
+		# don't dump
+	}
+	else # log everything by default
+	{
+		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
+	}
+}
 
 sub on_start_buildlog
 {
-	my $filename = "$::basedir/unreciped.txt";
-	print "Writing unreciped file $filename\n" if (!-f$filename);
-	open(FILE, ">>$filename");
+	RaptorCommon::init();
+	
+	$filename = "$::basedir/raptor_unreciped.txt";
+	if (!-f$filename)
+	{
+		print "Writing unreciped file $filename\n";
+		open(FILE, ">$filename");
+		close(FILE);
+	}
 }
 
 sub on_chars_buildlog
 {
 	my ($ch) = @_;
 	
-	my $characters = $ch->{Data};
+	#print "on_chars_buildlog\n";
+	
+	if ($store_chars)
+	{
+		$characters .= $ch->{Data};
+		
+		#print "characters is now -->$characters<--\n";
+	}
+}
+
+sub on_end_buildlog_subtag
+{
+	$store_chars = 1;
+}
+
+sub process_characters
+{
+	#print "process_characters\n";
+	
+	$characters =~ s,^[\r\n]*,,;
+	$characters =~ s,[\r\n]*$,,;
+	
+	#print "characters is -->$characters<--\n";
 	
-	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
+	my @lines = split(/[\r\n]/, $characters);
+	for my $line (@lines)
+	{
+		if ($line =~ m,[^\s^\r^\n],)
+		{
+			#print "dumping chars\n";
+			
+			if ($failure_item == 0 and -f "$filename")
+			{
+				open(FILE, "$filename");
+				{
+					local $/ = undef;
+					my $filecontent = <FILE>;
+					$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s);
+				}
+				close(FILE);
+			}
+			
+			$failure_item++;
+							
+			open(FILE, ">>$filename");
+			print FILE "---failure_item_$failure_item\---\n";
+			print FILE "$line\n\n";
+			close(FILE);
+			
+			process($line, '', '', '', "raptor_unreciped.txt", $failure_item);
+		}
+	}
 	
-	#print "characters is now -->$characters<--\n";
+	$characters = '';
+	$store_chars = 0;
+}
+
+sub on_start_buildlog_subtag
+{
+	#print "on_start_buildlog_subtag\n";
+	
+	process_characters();
 }
 
 sub on_end_buildlog
 {
-	close(FILE);
+	process_characters();
 }