sbsv1/abld/genutil/err_formatter.pl
author jjkang
Fri, 25 Jun 2010 18:11:34 +0800
changeset 600 6d08f4a05d93
parent 599 fa7a3cc6effd
permissions -rw-r--r--
add deprecated files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# err_formatter.pm
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
# This tool is asked to invoke the Lada compiler and reformat the errors/warnings from CW
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
# style to Visual Studio error/warning reporting style.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
# 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    18
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    19
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    20
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    21
use FindBin;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
my $command = join(' ', @ARGV);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
open PIPE, "$command 2>&1 | ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    25
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
my $nextLineOfInterest = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
my $new_error_line=();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
my $comp_msg=();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
my $error_token=();
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
# The error/warning format for CW compiler for the option 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
# -msgstyle parseable is as follows:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
# ToolName|ToolType|MsgType (FileName|Linenumber|digit|digit|digit|digit)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
# = AtToken
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
# > ErrorMsg
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
# In the above format, the symbols '|', '(', ')', '=' and '>' occur always
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
# and this tool assumes there presence.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
# Also, in the above, 
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
#	'ToolName' here is mwccsym2.exe
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
#	'ToolType' here is Compiler
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
#	'MsgType' is either Error or Warning
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
#	'FileName' is the file that caused the compiler error/warning
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
#	'Linenumber' is the line at which the error/warning is reported
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
#	'AtToken' is the token at which the error/warning was reported.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
#	'ErrorMsg' is the error message and it amrks the end of this error/warning.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
my @msgs;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
while(<PIPE>)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
	if( $nextLineOfInterest == 1)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
		if($_ =~ /^>(.*)/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
			$comp_msg .= $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
			$new_error_line .= "$comp_msg ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
			$new_error_line .= ": $error_token" if($error_token);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
			push @msgs, $new_error_line;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
			
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
			$nextLineOfInterest = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
			$comp_msg = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
			$error_token = "";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
			next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
		if($_ =~ /^=(.*)/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
			$error_token = $1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
			next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
		if($_ =~ /\((.*)\|([0-9]+)\|([0-9]+)\|([0-9]+)\|([0-9]+)\|([0-9]+)\)/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
		{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
######### $1 is file name
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
######### $2 is line number
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
			$new_error_line = $1."(";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
			$new_error_line .= $2;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
			$new_error_line .= ")";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
			$new_error_line .= ": ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
			next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
		}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
	if($_ =~ /Compiler\|Error/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
		$comp_msg = "Error: ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
		$nextLineOfInterest = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    92
	elsif($_ =~ /Compiler\|Warning/)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    93
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    94
		$comp_msg = "Warning: ";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    95
		$nextLineOfInterest = 1;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    96
		next;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    97
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    98
	else
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    99
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   100
		$nextLineOfInterest = 0;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   101
		push @msgs, $_;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   102
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   103
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   104
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   105
close PIPE;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   106
my $msg;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   107
foreach $msg (@msgs)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   108
{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   109
	print "$msg\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   110
}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
   111