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