common/tools/raptor/RaptorWarning.pm
changeset 364 4dc3b5b1577c
parent 227 51e429810aba
child 374 52675b624b66
equal deleted inserted replaced
350:35ec0d29a3d8 364:4dc3b5b1577c
    25 $reset_status->{name} = 'reset_status';
    25 $reset_status->{name} = 'reset_status';
    26 $reset_status->{next_status} = {buildlog=>$buildlog_status};
    26 $reset_status->{next_status} = {buildlog=>$buildlog_status};
    27 
    27 
    28 $buildlog_status->{name} = 'buildlog_status';
    28 $buildlog_status->{name} = 'buildlog_status';
    29 $buildlog_status->{next_status} = {warning=>$buildlog_warning_status};
    29 $buildlog_status->{next_status} = {warning=>$buildlog_warning_status};
       
    30 $buildlog_status->{on_start} = 'RaptorWarning::on_start_buildlog';
    30 
    31 
    31 $buildlog_warning_status->{name} = 'buildlog_warning_status';
    32 $buildlog_warning_status->{name} = 'buildlog_warning_status';
    32 $buildlog_warning_status->{next_status} = {};
    33 $buildlog_warning_status->{next_status} = {};
    33 $buildlog_warning_status->{on_start} = 'RaptorWarning::on_start_buildlog_warning';
    34 $buildlog_warning_status->{on_start} = 'RaptorWarning::on_start_buildlog_warning';
    34 $buildlog_warning_status->{on_end} = 'RaptorWarning::on_end_buildlog_warning';
    35 $buildlog_warning_status->{on_end} = 'RaptorWarning::on_end_buildlog_warning';
    35 $buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
    36 $buildlog_warning_status->{on_chars} = 'RaptorWarning::on_chars_buildlog_warning';
    36 
    37 
       
    38 my $filename = '';
       
    39 
    37 my $characters = '';
    40 my $characters = '';
    38 
    41 
    39 my $category = $RaptorCommon::CATEGORY_RAPTORWARNING;
    42 my $category = $RaptorCommon::CATEGORY_RAPTORWARNING;
    40 
    43 
    41 sub process
    44 sub process
    42 {
    45 {
    43 	my ($text) = @_;
    46 	my ($text, $component, $phase, $recipe, $file, $line) = @_;
    44 	
    47 	
    45 	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
    48 	my $severity = $RaptorCommon::SEVERITY_UNKNOWN;
    46 	
    49 	
    47 	if ($text =~ m,unmatchable,)
    50 	if ($text =~ m,missing flag ENABLE_ABIV2_MODE,)
    48 	{
    51 	{
    49 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    52 		$severity = $RaptorCommon::SEVERITY_NORMAL;
    50 		
    53 		my $subcategory = $RaptorCommon::CATEGORY_RAPTORWARNING_MISSINGFLAGABIV2;
    51 		#dump_error($category, $severity, $text);
    54 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    52 		print "$category, $severity, $text\n";
    55 	}
       
    56 	else # log everything by default
       
    57 	{
       
    58 		$severity = $RaptorCommon::SEVERITY_NORMAL;
       
    59 		my $subcategory = '';
       
    60 		RaptorCommon::dump_fault($category, $subcategory, $severity, $component, $phase, $recipe, $file, $line);
    53 	}
    61 	}
    54 }
    62 }
    55 
    63 
       
    64 sub on_start_buildlog
       
    65 {
       
    66 	RaptorCommon::init();
       
    67 	
       
    68 	$filename = "$::basedir/warnings.txt";
       
    69 	if (!-f$filename)
       
    70 	{
       
    71 		print "Writing warnings file $filename\n";
       
    72 		open(FILE, ">$filename");
       
    73 		close(FILE);
       
    74 	}
       
    75 }
    56 sub on_start_buildlog_warning
    76 sub on_start_buildlog_warning
    57 {
    77 {
    58 	my $filename = "$::basedir/warnings.txt";
       
    59 	print "Writing warning file $filename\n" if (!-f$filename);
       
    60 	open(FILE, ">>$filename");
    78 	open(FILE, ">>$filename");
    61 }
    79 }
    62 
    80 
    63 sub on_chars_buildlog_warning
    81 sub on_chars_buildlog_warning
    64 {
    82 {
    73 
    91 
    74 sub on_end_buildlog_warning
    92 sub on_end_buildlog_warning
    75 {
    93 {
    76 	#print "on_end_buildlog_warning\n";
    94 	#print "on_end_buildlog_warning\n";
    77 	
    95 	
    78 	process($characters);
       
    79 	
       
    80 	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
    96 	print FILE $characters if ($characters =~ m,[^\s^\r^\n],);
    81 	print FILE "\n" if ($characters !~ m,[\r\n]$, );
    97 	print FILE "\n" if ($characters !~ m,[\r\n]$, );
       
    98 	close(FILE);
       
    99 	
       
   100 	# get the line number - not really optimized
       
   101 	my $linecount = 0;
       
   102 	open(FILE, "$filename");
       
   103 	for ($linecount = 0; <FILE>; $linecount++) { }
       
   104 	close(FILE);
       
   105 	
       
   106 	process($characters, '', '', '', "warnings.txt", $linecount);
    82 	
   107 	
    83 	$characters = '';
   108 	$characters = '';
    84 	
       
    85 	close(FILE);
       
    86 }
   109 }
    87 
   110 
    88 
   111 
    89 1;
   112 1;