uh_parser/RaptorError.pm
changeset 186 b76adfbc6648
parent 185 978ef35b4e5f
child 228 ba90e30c0f3c
equal deleted inserted replaced
185:978ef35b4e5f 186:b76adfbc6648
    34 $buildlog_error_status->{on_start} = 'RaptorError::on_start_buildlog_error';
    34 $buildlog_error_status->{on_start} = 'RaptorError::on_start_buildlog_error';
    35 $buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
    35 $buildlog_error_status->{on_end} = 'RaptorError::on_end_buildlog_error';
    36 $buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
    36 $buildlog_error_status->{on_chars} = 'RaptorError::on_chars_buildlog_error';
    37 
    37 
    38 my $filename = '';
    38 my $filename = '';
    39 my $failure_item = 0;
       
    40 
    39 
    41 my $characters = '';
    40 my $characters = '';
    42 
    41 
    43 my $CATEGORY_RAPTORERROR = 'raptor_error';
    42 my $CATEGORY_RAPTORERROR = 'raptor_error';
    44 my $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION = 'cannot_process_schema_version';
    43 my $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION = 'cannot_process_schema_version';
    51 my $CATEGORY_RAPTORERROR_COULDNOTEXPORT = 'missing_source_file';
    50 my $CATEGORY_RAPTORERROR_COULDNOTEXPORT = 'missing_source_file';
    52 my $CATEGORY_RAPTORERROR_MISSINGBLDINFFILE = 'missing_bld_inf_file';
    51 my $CATEGORY_RAPTORERROR_MISSINGBLDINFFILE = 'missing_bld_inf_file';
    53 
    52 
    54 sub process
    53 sub process
    55 {
    54 {
    56 	my ($text, $logfile, $component, $mmp, $phase, $recipe, $file, $line) = @_;
    55 	my ($text, $logfile, $component, $mmp, $phase, $recipe, $file) = @_;
       
    56 	
       
    57 	my $dumped = 1;
    57 	
    58 	
    58 	my $category = $CATEGORY_RAPTORERROR;
    59 	my $category = $CATEGORY_RAPTORERROR;
    59 	my $severity = '';
    60 	my $severity = '';
    60 	my $subcategory = '';
    61 	my $subcategory = '';
    61 	
    62 	
    62 	if ($text =~ m,Cannot process schema version .* of file,)
    63 	if ($text =~ m,Cannot process schema version .* of file,)
    63 	{
    64 	{
    64 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    65 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    65 		$subcategory = $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION;
    66 		$subcategory = $CATEGORY_RAPTORERROR_CANNOTPROCESSSCHEMAVERSION;
    66 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
    67 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
    67 	}
    68 	}
    68 	elsif ($text =~ m,No bld\.inf found at,)
    69 	elsif ($text =~ m,No bld\.inf found at,)
    69 	{
    70 	{
    70 		$severity = $RaptorCommon::SEVERITY_MAJOR;
    71 		$severity = $RaptorCommon::SEVERITY_MAJOR;
    71 		$subcategory = $CATEGORY_RAPTORERROR_NOBLDINFFOUND;
    72 		$subcategory = $CATEGORY_RAPTORERROR_NOBLDINFFOUND;
    72 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
    73 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
    73 	}
    74 	}
    74 	elsif ($text =~ m,Can't find mmp file,)
    75 	elsif ($text =~ m,Can't find mmp file,)
    75 	{
    76 	{
    76 		$severity = $RaptorCommon::SEVERITY_MAJOR;
    77 		$severity = $RaptorCommon::SEVERITY_MAJOR;
    77 		$subcategory = $CATEGORY_RAPTORERROR_CANTFINDMMPFILE;
    78 		$subcategory = $CATEGORY_RAPTORERROR_CANTFINDMMPFILE;
    78 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
    79 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
    79 	}
    80 	}
    80 	elsif ($text =~ m,The make-engine exited with errors,)
    81 	elsif ($text =~ m,The make-engine exited with errors,)
    81 	{
    82 	{
    82 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    83 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    83 		$subcategory = $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS;
    84 		$subcategory = $CATEGORY_RAPTORERROR_MAKEEXITEDWITHERRORS;
    84 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
    85 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
    85 	}
    86 	}
    86 	elsif ($text =~ m,tool .* from config .* did not return version .* as required,)
    87 	elsif ($text =~ m,tool .* from config .* did not return version .* as required,)
    87 	{
    88 	{
    88 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    89 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    89 		$subcategory = $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION;
    90 		$subcategory = $CATEGORY_RAPTORERROR_TOOLDIDNOTRETURNVERSION;
    90 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
    91 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
    91 	}
    92 	}
    92 	elsif ($text =~ m,Unknown build configuration '.*',)
    93 	elsif ($text =~ m,Unknown build configuration '.*',)
    93 	{
    94 	{
    94 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    95 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
    95 		$subcategory = $CATEGORY_RAPTORERROR_UNKNOWNBUILDCONFIG;
    96 		$subcategory = $CATEGORY_RAPTORERROR_UNKNOWNBUILDCONFIG;
    96 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
    97 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
    97 	}
    98 	}
    98 	elsif ($text =~ m,No build configurations given,)
    99 	elsif ($text =~ m,No build configurations given,)
    99 	{
   100 	{
   100 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
   101 		$severity = $RaptorCommon::SEVERITY_CRITICAL;
   101 		$subcategory = $CATEGORY_RAPTORERROR_NOBUILDCONFIGSGIVEN;
   102 		$subcategory = $CATEGORY_RAPTORERROR_NOBUILDCONFIGSGIVEN;
   102 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
   103 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
   103 	}
   104 	}
   104 	elsif ($text =~ m,Could not export .* to .* : \[Errno 2\] No such file or directory: .*,)
   105 	elsif ($text =~ m,Could not export .* to .* : \[Errno 2\] No such file or directory: .*,)
   105 	{
   106 	{
   106 		$severity = $RaptorCommon::SEVERITY_MAJOR;
   107 		$severity = $RaptorCommon::SEVERITY_MAJOR;
   107 		$subcategory = $CATEGORY_RAPTORERROR_COULDNOTEXPORT;
   108 		$subcategory = $CATEGORY_RAPTORERROR_COULDNOTEXPORT;
   108 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
   109 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
   109 	}
   110 	}
   110 	elsif ($text =~ m,win32/mingw/bin/cpp\.exe: .*bld\.inf:.*bld\.inf: No such file or directory,)
   111 	elsif ($text =~ m,win32/mingw/bin/cpp\.exe: .*bld\.inf:.*bld\.inf: No such file or directory,)
   111 	{
   112 	{
   112 		$severity = $RaptorCommon::SEVERITY_MAJOR;
   113 		$severity = $RaptorCommon::SEVERITY_MAJOR;
   113 		$subcategory = $CATEGORY_RAPTORERROR_MISSINGBLDINFFILE;
   114 		$subcategory = $CATEGORY_RAPTORERROR_MISSINGBLDINFFILE;
   114 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
   115 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
   115 	}
   116 	}
   116 	elsif ($text =~ m,^Preprocessor exception: ''Errors in .*bld\.inf'' : in command,)
   117 	elsif ($text =~ m,^Preprocessor exception: ''Errors in .*bld\.inf'' : in command,)
   117 	{
   118 	{
   118 		# don't dump
   119 		# don't dump
       
   120 		$dumped = 0;
   119 	}
   121 	}
   120 	elsif ($text =~ m,Source of export does not exist: .*,)
   122 	elsif ($text =~ m,Source of export does not exist: .*,)
   121 	{
   123 	{
   122 		# don't dump
   124 		# don't dump
       
   125 		$dumped = 0;
   123 	}
   126 	}
   124 	else # log everything by default
   127 	else # log everything by default
   125 	{
   128 	{
   126 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file, $line);
   129 		RaptorCommon::dump_fault($category, $subcategory, $severity, $logfile, $component, $mmp, $phase, $recipe, $file);
   127 	}
   130 	}
       
   131 	
       
   132 	return $dumped;
   128 }
   133 }
   129 
   134 
   130 sub on_start_buildlog
   135 sub on_start_buildlog
   131 {
   136 {
   132 	RaptorCommon::init();
   137 	RaptorCommon::init();
   162 	$characters =~ s,^[\r\n]*,,;
   167 	$characters =~ s,^[\r\n]*,,;
   163 	$characters =~ s,[\r\n]*$,,;
   168 	$characters =~ s,[\r\n]*$,,;
   164 	
   169 	
   165 	if ($characters =~ m,[^\s^\r^\n],)
   170 	if ($characters =~ m,[^\s^\r^\n],)
   166 	{	
   171 	{	
   167 		if ($failure_item == 0 and -f "$filename")
   172 		my $dumped = process($characters, $::current_log_file, '', '', '', '', "raptor_error.txt");
       
   173 		
       
   174 		if ($dumped)
   168 		{
   175 		{
   169 			open(FILE, "$filename");
   176 			open(FILE, ">>$filename");
   170 			{
   177 			print FILE "---failure_item_$::failure_item_number\---\n";
   171 				local $/ = undef;
   178 			print FILE "$characters\n\n";
   172 				my $filecontent = <FILE>;
       
   173 				$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s);
       
   174 			}
       
   175 			close(FILE);
   179 			close(FILE);
   176 		}
   180 		}
   177 		
       
   178 		$failure_item++;
       
   179 	
       
   180 		open(FILE, ">>$filename");
       
   181 		print FILE "---failure_item_$failure_item\---\n";
       
   182 		print FILE "$characters\n\n";
       
   183 		close(FILE);
       
   184 		
       
   185 		process($characters, $::current_log_file, '', '', '', '', "raptor_error.txt", $failure_item);
       
   186 	}
   181 	}
   187 	
   182 	
   188 	$characters = '';
   183 	$characters = '';
   189 }
   184 }
   190 
   185