common/tools/raptor/RaptorWarning.pm
changeset 374 52675b624b66
parent 364 4dc3b5b1577c
equal deleted inserted replaced
373:cc469b3fe547 374:52675b624b66
    34 $buildlog_warning_status->{on_start} = 'RaptorWarning::on_start_buildlog_warning';
    34 $buildlog_warning_status->{on_start} = 'RaptorWarning::on_start_buildlog_warning';
    35 $buildlog_warning_status->{on_end} = 'RaptorWarning::on_end_buildlog_warning';
    35 $buildlog_warning_status->{on_end} = 'RaptorWarning::on_end_buildlog_warning';
    36 $buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
    36 $buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
    37 
    37 
    38 my $filename = '';
    38 my $filename = '';
       
    39 my $failure_item = 0;
    39 
    40 
    40 my $characters = '';
    41 my $characters = '';
    41 
    42 
    42 my $category = $RaptorCommon::CATEGORY_RAPTORWARNING;
    43 my $CATEGORY_RAPTORWARNING = 'raptor_warning';
       
    44 my $CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2 = 'missing_enable_abiv2_mode';
    43 
    45 
    44 sub process
    46 sub process
    45 {
    47 {
    46 	my ($text, $component, $phase, $recipe, $file, $line) = @_;
    48 	my ($text, $component, $phase, $recipe, $file, $line) = @_;
    47 	
    49 	
    48 	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
    50 	my $category = $CATEGORY_RAPTORWARNING;
       
    51 	my $severity = '';
       
    52 	my $subcategory = '';
    49 	
    53 	
    50 	if ($text =~ m,missing flag ENABLE_ABIV2_MODE,)
    54 	if ($text =~ m,missing flag ENABLE_ABIV2_MODE,)
    51 	{
    55 	{
    52 		$severity = $RaptorCommon::SEVERITY_NORMAL;
    56 		$severity = $RaptorCommon::SEVERITY_MINOR;
    53 		my $subcategory = $RaptorCommon::CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2;
    57 		my $subcategory = $CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2;
    54 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    58 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    55 	}
    59 	}
    56 	else # log everything by default
    60 	else # log everything by default
    57 	{
    61 	{
    58 		$severity = $RaptorCommon::SEVERITY_NORMAL;
       
    59 		my $subcategory = '';
       
    60 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    62 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    61 	}
    63 	}
    62 }
    64 }
    63 
    65 
    64 sub on_start_buildlog
    66 sub on_start_buildlog
    65 {
    67 {
    66 	RaptorCommon::init();
    68 	RaptorCommon::init();
    67 	
    69 	
    68 	$filename = "$::basedir/warnings.txt";
    70 	$filename = "$::basedir/raptor_warning.txt";
    69 	if (!-f$filename)
    71 	if (!-f$filename)
    70 	{
    72 	{
    71 		print "Writing warnings file $filename\n";
    73 		print "Writing warnings file $filename\n";
    72 		open(FILE, ">$filename");
    74 		open(FILE, ">$filename");
    73 		close(FILE);
    75 		close(FILE);
    91 
    93 
    92 sub on_end_buildlog_warning
    94 sub on_end_buildlog_warning
    93 {
    95 {
    94 	#print "on_end_buildlog_warning\n";
    96 	#print "on_end_buildlog_warning\n";
    95 	
    97 	
    96 	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
    98 	$characters =~ s,^[\r\n]*,,;
    97 	print FILE "\n" if ($characters !~ m,[\r\n]$, );
    99 	$characters =~ s,[\r\n]*$,,;
    98 	close(FILE);
       
    99 	
   100 	
   100 	# get the line number - not really optimized
   101 	if ($characters =~ m,[^\s^\r^\n],)
   101 	my $linecount = 0;
   102 	{
   102 	open(FILE, "$filename");
   103 		if ($failure_item == 0 and -f "$filename")
   103 	for ($linecount = 0; <FILE>; $linecount++) { }
   104 		{
   104 	close(FILE);
   105 			open(FILE, "$filename");
       
   106 			{
       
   107 				local $/ = undef;
       
   108 				my $filecontent = <FILE>;
       
   109 				$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s);
       
   110 			}
       
   111 			close(FILE);
       
   112 		}
       
   113 		
       
   114 		$failure_item++;
   105 	
   115 	
   106 	process($characters, '', '', '', "warnings.txt", $linecount);
   116 		open(FILE, ">>$filename");
       
   117 		print FILE "---failure_item_$failure_item\---\n";
       
   118 		print FILE "$characters\n\n";
       
   119 		close(FILE);
       
   120 		
       
   121 		process($characters, '', '', '', "raptor_warning.txt", $failure_item);
       
   122 	}
   107 	
   123 	
   108 	$characters = '';
   124 	$characters = '';
   109 }
   125 }
   110 
   126 
   111 
   127