Added find_collisions.pl Updated the readme.txt for instructions.
authorMatt Davies <mattd@symbian.org>
Tue, 19 May 2009 16:12:17 +0100
changeset 124 71122b8e1c7b
parent 123 c222f4b27ad7
child 125 c2478fad90aa
child 145 fc757bffbe1d
Added find_collisions.pl Updated the readme.txt for instructions.
common/tools/analysis/find_collisions.pl
common/tools/analysis/readme.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/analysis/find_collisions.pl	Tue May 19 16:12:17 2009 +0100
@@ -0,0 +1,179 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+# 
+# Contributors:
+#
+# Description:
+# Adds info form a file to a CSV
+
+use strict;
+
+main();
+
+sub main()
+{
+  my $csvfile = shift @ARGV;
+  my $filelist = shift @ARGV;
+
+  if(! -e $csvfile)
+  {
+    die "cannot find $csvfile\n";
+  }
+
+  open(CSV,"<$csvfile") or die "Couldn't open $csvfile\n";
+  my $header = <CSV>;
+  $header =~ s/\n//;
+  print RESULTS $header.",status\n";
+  my @fields = split(',',$header);
+  my $targetindex = 0;
+  my $counter = 0;
+  my $bldinfindex = 0;
+  my $makefileindex = 0;
+  my $typeindex = 0;
+  my $extindex = 0;
+  my %failed;
+  my %bldinffiles;
+  
+  my %targets;
+  
+  foreach my $column (@fields)
+  {
+      if($column =~ m/target/)
+      {
+          $targetindex = $counter;
+      }
+      elsif($column =~ m/bldinf/)
+      {
+        $bldinfindex = $counter;
+      }
+      elsif($column =~ m/makefile/)
+      {
+        $makefileindex = $counter;
+      }
+      elsif($column =~ m/type/)
+      {
+        $typeindex = $counter;
+      }
+      elsif($column =~ m/extension/)
+      {
+        $extindex = $counter;
+      }
+      ++$counter;
+  }
+#        print "\ntarget:$targetindex\tbuildinf:$bldinfindex\n";
+    #header
+  my $resultsfile = $csvfile."_collisions.csv"; 
+  open(RESULTS, ">$resultsfile") or die "Coudn't open $resultsfile";
+  
+  print RESULTS "Collision,target,extension,type,source1,source2\n";
+  while(my $line = <CSV>)
+      {
+      $line =~ s/\n//;
+      @fields = split(',',$line);
+      my $target = $fields[$targetindex];
+      $target = lc($target);
+      my $makefile = $fields[$makefileindex];
+      my $bldinf =   $fields[$bldinfindex];
+                
+      if(defined $targets{$target})
+        {
+          my $currentmakefile = $targets{$target};
+          if($makefile eq "")
+          {
+            $makefile = $bldinf;
+          }
+          if (!($currentmakefile eq $makefile))
+            {
+            my $type = $fields[$typeindex]; #DODGY - smoe custom makefiles also clash with export headers...
+            my $ext = $fields[$extindex];
+            my $collision = "-";
+            if($type eq "export")
+            {
+              $collision = diffcollision($target,$currentmakefile,$makefile);
+            }   
+            print RESULTS "$collision,$target,$ext,$type,$currentmakefile,$makefile\n";
+            }
+        }
+      else
+        {
+          if($makefile eq "")
+          {
+             $targets{$target} = $bldinf;
+          }
+          else
+          {
+            $targets{$target} = $makefile;
+          }  
+        }      
+      }
+  close RESULTS;    
+  close CSV;
+}
+
+sub diffcollision($$$)
+{
+  my $target = shift;
+  my $left = shift;
+  my $right = shift;
+  
+  $target =~ s/\//\\/g;
+  $left  =~ s/\//\\/g;
+  $right =~ s/\//\\/g;  
+  my $ret = "unknown";
+  if(!-e $target)
+  {
+    $ret = "missing";
+  }
+  else
+  {
+    if(-e $left && -e $right)
+    {
+      my $leftdiff = 0;
+      my $rightdiff = 0;
+      open(DIFF,"diff $left $target|") or die "couldn't execute diff";
+      print "diff $left $target\n";
+      
+      while(my $line = <DIFF>)
+      {
+        if($line =~ m/\S+/)
+        {
+          $leftdiff = 1;
+          print "\t$line";
+        }
+      }
+      close DIFF;
+
+      open(DIFF,"diff $right $target|") or die "couldn't execute diff";
+      print "diff $right $target\n";
+      while( my $line = <DIFF>)
+      {
+        if($line =~ m/\S+/)
+        {
+          $rightdiff = 1;
+         print "\t$line";
+        }
+      }
+      close DIFF;
+
+     if($leftdiff && !$rightdiff )
+        {$ret = "match right";}
+     elsif($rightdiff && !$leftdiff)
+        {$ret = "match left";}
+     elsif($rightdiff && $leftdiff)
+        {$ret = "match neither";}
+     elsif(!$rightdiff && !$leftdiff)
+        {$ret = "match both";}                  
+    }
+  
+    
+  }
+  return $ret; 
+}
\ No newline at end of file
--- a/common/tools/analysis/readme.txt	Tue May 19 16:02:09 2009 +0100
+++ b/common/tools/analysis/readme.txt	Tue May 19 16:12:17 2009 +0100
@@ -1,13 +1,23 @@
+Update 20090519 by MattD
 
+Can now run parselistdirs.pl from anywhere witout lots of intermediate output files:
+perl parselistdirs.pl <logs_dir> (<output_dir>)
+Note that it will still put most of it's output to the console as before. The second dir is optional.
 
+Added find_collisions.pl
+Prefers to be run from the root on the build machine (as it's looking for files to compare)
+It's a hacked up version of merge_csv.pl
+Usage:
+perl find_collisions.pl what_results.log >collision_result.txt
+It creates a CSV based on the name of the file passed to it (ie what_results.log_collisions.csv)
+
+Yes, They are all quick and dirty.
+
+Older stuff:
 
 F:\6.2\generated\parselistdirs.pl - creates sets from the listdirs outputs...
-
 F:\6.2\generated\parsewhatlog.pl - creates a CSV-style log from the whatlogs.
-
 F:\6.2\generated\merge_csv.pl - takes the output CSV from parsewhatlog.pl and merges in the output of parselistdirs.pl
-
-
 in generated>
 perl parselistdirs.pl ..\ >list_results.log
 perl parsewhatlog.pl ..\ >what_results.log