|
1 #!/usr/bin/perl |
|
2 |
|
3 # Copyright (c) 2009 Symbian Foundation Ltd |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of the License "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Symbian Foundation Ltd - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # Adds info form a file to a CSV |
|
16 |
|
17 use strict; |
|
18 |
|
19 main(); |
|
20 |
|
21 sub main() |
|
22 { |
|
23 my $csvfile = shift @ARGV; |
|
24 my $filelist = shift @ARGV; |
|
25 |
|
26 if(! -e $csvfile) |
|
27 { |
|
28 die "cannot find $csvfile\n"; |
|
29 } |
|
30 |
|
31 open(CSV,"<$csvfile") or die "Couldn't open $csvfile\n"; |
|
32 my $header = <CSV>; |
|
33 $header =~ s/\n//; |
|
34 print RESULTS $header.",status\n"; |
|
35 my @fields = split(',',$header); |
|
36 my $targetindex = 0; |
|
37 my $counter = 0; |
|
38 my $bldinfindex = 0; |
|
39 my $makefileindex = 0; |
|
40 my $typeindex = 0; |
|
41 my $extindex = 0; |
|
42 my %failed; |
|
43 my %bldinffiles; |
|
44 |
|
45 my %targets; |
|
46 |
|
47 foreach my $column (@fields) |
|
48 { |
|
49 if($column =~ m/target/) |
|
50 { |
|
51 $targetindex = $counter; |
|
52 } |
|
53 elsif($column =~ m/bldinf/) |
|
54 { |
|
55 $bldinfindex = $counter; |
|
56 } |
|
57 elsif($column =~ m/makefile/) |
|
58 { |
|
59 $makefileindex = $counter; |
|
60 } |
|
61 elsif($column =~ m/type/) |
|
62 { |
|
63 $typeindex = $counter; |
|
64 } |
|
65 elsif($column =~ m/extension/) |
|
66 { |
|
67 $extindex = $counter; |
|
68 } |
|
69 ++$counter; |
|
70 } |
|
71 # print "\ntarget:$targetindex\tbuildinf:$bldinfindex\n"; |
|
72 #header |
|
73 my $resultsfile = $csvfile."_collisions.csv"; |
|
74 open(RESULTS, ">$resultsfile") or die "Coudn't open $resultsfile"; |
|
75 |
|
76 print RESULTS "Collision,target,extension,type,source1,source2\n"; |
|
77 while(my $line = <CSV>) |
|
78 { |
|
79 $line =~ s/\n//; |
|
80 @fields = split(',',$line); |
|
81 my $target = $fields[$targetindex]; |
|
82 $target = lc($target); |
|
83 my $makefile = $fields[$makefileindex]; |
|
84 my $bldinf = $fields[$bldinfindex]; |
|
85 |
|
86 if(defined $targets{$target}) |
|
87 { |
|
88 my $currentmakefile = $targets{$target}; |
|
89 if($makefile eq "") |
|
90 { |
|
91 $makefile = $bldinf; |
|
92 } |
|
93 if (!($currentmakefile eq $makefile)) |
|
94 { |
|
95 my $type = $fields[$typeindex]; #DODGY - smoe custom makefiles also clash with export headers... |
|
96 my $ext = $fields[$extindex]; |
|
97 my $collision = "-"; |
|
98 if($type eq "export") |
|
99 { |
|
100 $collision = diffcollision($target,$currentmakefile,$makefile); |
|
101 } |
|
102 print RESULTS "$collision,$target,$ext,$type,$currentmakefile,$makefile\n"; |
|
103 } |
|
104 } |
|
105 else |
|
106 { |
|
107 if($makefile eq "") |
|
108 { |
|
109 $targets{$target} = $bldinf; |
|
110 } |
|
111 else |
|
112 { |
|
113 $targets{$target} = $makefile; |
|
114 } |
|
115 } |
|
116 } |
|
117 close RESULTS; |
|
118 close CSV; |
|
119 } |
|
120 |
|
121 sub diffcollision($$$) |
|
122 { |
|
123 my $target = shift; |
|
124 my $left = shift; |
|
125 my $right = shift; |
|
126 |
|
127 $target =~ s/\//\\/g; |
|
128 $left =~ s/\//\\/g; |
|
129 $right =~ s/\//\\/g; |
|
130 my $ret = "unknown"; |
|
131 if(!-e $target) |
|
132 { |
|
133 $ret = "missing"; |
|
134 } |
|
135 else |
|
136 { |
|
137 if(-e $left && -e $right) |
|
138 { |
|
139 my $leftdiff = 0; |
|
140 my $rightdiff = 0; |
|
141 open(DIFF,"diff $left $target|") or die "couldn't execute diff"; |
|
142 print "diff $left $target\n"; |
|
143 |
|
144 while(my $line = <DIFF>) |
|
145 { |
|
146 if($line =~ m/\S+/) |
|
147 { |
|
148 $leftdiff = 1; |
|
149 print "\t$line"; |
|
150 } |
|
151 } |
|
152 close DIFF; |
|
153 |
|
154 open(DIFF,"diff $right $target|") or die "couldn't execute diff"; |
|
155 print "diff $right $target\n"; |
|
156 while( my $line = <DIFF>) |
|
157 { |
|
158 if($line =~ m/\S+/) |
|
159 { |
|
160 $rightdiff = 1; |
|
161 print "\t$line"; |
|
162 } |
|
163 } |
|
164 close DIFF; |
|
165 |
|
166 if($leftdiff && !$rightdiff ) |
|
167 {$ret = "match right";} |
|
168 elsif($rightdiff && !$leftdiff) |
|
169 {$ret = "match left";} |
|
170 elsif($rightdiff && $leftdiff) |
|
171 {$ret = "match neither";} |
|
172 elsif(!$rightdiff && !$leftdiff) |
|
173 {$ret = "match both";} |
|
174 } |
|
175 |
|
176 |
|
177 } |
|
178 return $ret; |
|
179 } |