williamr/summarise_rnd_binaries.pl
changeset 2 a600c1a596f7
equal deleted inserted replaced
1:4a4ca5a019bb 2:a600c1a596f7
       
     1 #! 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 # Perl script to summarise the R&D binaries listing
       
    16 
       
    17 use strict;
       
    18 
       
    19 my %grouped_by_basename;
       
    20 my $line;
       
    21 
       
    22 while ($line=<>)
       
    23   {
       
    24   # 2009-04-30 11:26:58 D....            0            0  epoc32\cshlpcmp_template
       
    25   # 2009-03-20 22:22:18 .....        72192        16307  epoc32\cshlpcmp_template\cshelp2000.dot
       
    26   
       
    27   next if (length($line) < 54);
       
    28   
       
    29   my $dir_attribute = substr($line, 20, 1);  
       
    30   if ($dir_attribute eq ".")
       
    31     {
       
    32     chomp $line;
       
    33     my $fullpath = substr($line, 53);
       
    34     my $filename = substr($fullpath, rindex($fullpath,"\\")+1);
       
    35     my $basename = lc substr($filename, 0, index($filename,"."));
       
    36     
       
    37     if ($basename =~ /^(.*){[0-9a-f]+}$/)
       
    38       {
       
    39       # import library
       
    40       $basename = $1;
       
    41       }
       
    42     elsif ($basename =~ /^(.*)_\d+$/)
       
    43       {
       
    44       # language variant in basename rather than extension
       
    45       $basename = $1;
       
    46       }
       
    47     elsif ($basename =~ /^(.*)_(aif|reg)$/)
       
    48       {
       
    49       # Uikon file grouping
       
    50       $basename = $1;
       
    51       }
       
    52 
       
    53     if (!defined $grouped_by_basename{$basename})
       
    54       {
       
    55       $grouped_by_basename{$basename} = ();
       
    56       }
       
    57     push @{$grouped_by_basename{$basename}}, $fullpath;
       
    58     next;
       
    59     }
       
    60   }
       
    61 
       
    62 sub summarise_extensions(@)
       
    63   {
       
    64   my @files = @_;
       
    65   my $resources = 0;
       
    66   my $exes = 0;
       
    67   my $dlls = 0;
       
    68   my $libs = 0;
       
    69   my $maps = 0;
       
    70   my $headers = 0;
       
    71   my $others = 0;
       
    72   my %what_others;
       
    73   
       
    74   foreach my $file (@files)
       
    75     {
       
    76     my $extension = substr($file,rindex($file, "."));
       
    77 
       
    78     if ($extension =~ /^.r\d+$/io)
       
    79       {
       
    80       $what_others{".rNN"} += 1;
       
    81       next;
       
    82       }
       
    83     if ($extension =~ /^.o\d+$/io)
       
    84       {
       
    85       $what_others{".oNNNN"} += 1;
       
    86       next;
       
    87       }
       
    88     $what_others{$extension} += 1;
       
    89     }
       
    90   foreach my $extension (sort keys %what_others)
       
    91     {
       
    92     printf "%d %s, ", $what_others{$extension}, $extension;
       
    93     }
       
    94   print "\n";
       
    95   }
       
    96 
       
    97 my $count = 0;
       
    98 foreach my $basename (sort keys %grouped_by_basename)
       
    99   {
       
   100   my @files = @{$grouped_by_basename{$basename}};
       
   101   next if (! grep /winscw|tools/, @files);  # ignore ARMV5 only for now...
       
   102   printf "%6d\t%s\t", scalar @files, $basename;
       
   103   summarise_extensions(@files);
       
   104   $count++;
       
   105   }
       
   106 printf "%d distinct missing basenames (from %d total)\n", $count, scalar keys %grouped_by_basename;