common/tools/analysis/parsewhatlog.pl
changeset 97 4f54ca96b7e8
child 146 f31749863421
equal deleted inserted replaced
93:27826401fee5 97:4f54ca96b7e8
       
     1 #!/usr/bin/perl
       
     2 #parsewhatlog - parses a whatlog, gives csv output.
       
     3 use strict;
       
     4 
       
     5 #<whatlog bldinf='t:/sf/mw/ipappprotocols/sipconnproviderplugins/sipstatemachine/group/bld.inf' mmp='' config='winscw_udeb.whatlog'>
       
     6 #<export destination='t:/epoc32/rom/include/sipstatemachine.iby' source='t:/sf/mw/ipappprotocols/sipconnproviderplugins/sipstatemachine/group/SipStateMachine.iby'/>
       
     7 #</whatlog>
       
     8 #<whatlog bldinf='t:/sf/os/mm/mmplugins/3gplib/group/bld.inf' mmp='t:/sf/os/mm/mmplugins/3gplib/impl/group/3gpmp4lib.mmp' config='winscw_udeb.whatlog'>
       
     9 #<build>t:/epoc32/release/winscw/udeb/3gpmp4lib.lib</build>
       
    10 #<build>t:/epoc32/release/winscw/udeb/3gpmp4lib.lib</build>
       
    11 #<build>t:/epoc32/release/winscw/udeb/3gpmp4lib.dll</build>
       
    12 #</whatlog>
       
    13 #<whatlog bldinf='t:/sf/mw/messagingmw/messagingfw/msgconf/group/bld.inf' mmp='t:/sf/mw/messagingmw/messagingfw/msgconf/group/messaging_config.mmp' config='winscw_udeb.whatlog'>
       
    14 #<bitmap>t:/epoc32/data/z/resource/messaging/bif/vclp.mbm</bitmap>
       
    15 #<bitmap>t:/epoc32/release/winscw/udeb/z/resource/messaging/bif/vclp.mbm</bitmap>
       
    16 #<bitmap>t:/epoc32/release/winscw/urel/z/resource/messaging/bif/vclp.mbm</bitmap>
       
    17 #<bitmap>t:/epoc32/localisation/vclp/mbm/vclp0.bmp</bitmap>
       
    18 #<bitmap>t:/epoc32/localisation/group/vclp.info</bitmap>
       
    19 #</whatlog>
       
    20 #<whatlog bldinf='t:/sf/mw/mmmw/mmmiddlewarefws/mmfw/sounddev/group_pluginsupport/bld.inf' mmp='t:/sf/mw/mmmw/mmmiddlewarefws/mmfw/sounddev/PlatSec/MMPFiles/Sounddevice/aacdecoderconfigci.mmp' config='winscw_udeb.whatlog'>
       
    21 #<resource>t:/epoc32/data/z/resource/plugins/aacdecoderconfigci.rsc</resource>
       
    22 #<resource>t:/epoc32/release/winscw/udeb/z/resource/plugins/aacdecoderconfigci.rsc</resource>
       
    23 #<resource>t:/epoc32/release/winscw/urel/z/resource/plugins/aacdecoderconfigci.rsc</resource>
       
    24 #<resource>t:/epoc32/localisation/aacdecoderconfigci/rsc/aacdecoderconfigci.rpp</resource>
       
    25 #<resource>t:/epoc32/localisation/group/aacdecoderconfigci.info</resource>
       
    26 #</whatlog>
       
    27 
       
    28 
       
    29 my $keepgoing = 1;
       
    30 main();
       
    31 
       
    32 sub cleanpath($)
       
    33 {
       
    34   my $str = lc(shift); #drop the case.
       
    35   $str =~ s/^\S://; #remove drive letter
       
    36   $str =~ s/^\///; # some custom makefiles report aboslute path
       
    37   $str =~ s/\\/\//g; #switch the path
       
    38   $str =~ s/\/\//\//g;#we have some double slashes in some resources... 
       
    39   return $str;
       
    40 }
       
    41 sub ext($)
       
    42 {
       
    43   my $str = shift;
       
    44   $str =~ s/\S+\.//; #may fail...
       
    45   return $str;
       
    46 }
       
    47 
       
    48 sub main()
       
    49 {
       
    50   my $path = shift @ARGV;
       
    51   my @files = glob($path."/*whatlog*WHAT_*compile.log"); 
       
    52   foreach my $filename (@files)
       
    53   {
       
    54 #    print $filename."\n";
       
    55     parsefile($filename);
       
    56   }  
       
    57 }
       
    58 sub parsefile($filename)
       
    59 {  
       
    60   my $filename = shift;
       
    61   open(FILE,"<$filename") or die "Couldn't open filename\n";
       
    62   
       
    63   #I'm using previous formatting stypes from the flm parsing...ie location, bld.inf, makefile, type, target,extension
       
    64   print "location,bldinf,makefile,type,target,extension\n";
       
    65   my $bldinf = "";
       
    66   my $makefile = "";
       
    67   my $inrecipe = 0;
       
    68   
       
    69   my $linecount = 0;
       
    70   while(my $line = <FILE>)
       
    71   {
       
    72     ++$linecount;
       
    73     if($line =~ m/^<whatlog bldinf='(\S+)' mmp='(\S*)' config='\S+'>/) #brittle
       
    74     {
       
    75       $bldinf = $1;
       
    76       $makefile = $2;
       
    77     }
       
    78     elsif($line =~ m/^<\/whatlog>/)
       
    79     {
       
    80       $bldinf = "";
       
    81       $makefile = "";
       
    82     }
       
    83     elsif($line =~ m/^<bitmap>(\S+)<\/bitmap>/)
       
    84     {
       
    85       if($bldinf eq "" || $makefile eq "" && !$keepgoing)
       
    86       {
       
    87         die "$filename($linecount) bldinf=$bldinf makefile=$makefile: $line\n";
       
    88       }
       
    89       print "$filename($linecount),".cleanpath($bldinf).",".cleanpath($makefile).",bitmap,".cleanpath($1).",".ext($1)."\n";        
       
    90     }
       
    91     elsif($line =~ m/^<build>(\S+)<\/build>/)
       
    92     {
       
    93       if($bldinf eq "" || $makefile eq "" && !$keepgoing)
       
    94       {
       
    95         die "$filename($linecount) bldinf=$bldinf makefile=$makefile : $line\n";
       
    96       }
       
    97       print "$filename($linecount),".cleanpath($bldinf).",".cleanpath($makefile).",binary,".cleanpath($1).",".ext($1)."\n";        
       
    98     }
       
    99     elsif($line =~ m/^<resource>(\S+)<\/resource>/)
       
   100     {
       
   101       if($bldinf eq "" || $makefile eq "" && !$keepgoing)
       
   102       {
       
   103         die "$filename($linecount) bldinf=$bldinf makefile=$makefile : $line\n";
       
   104       }
       
   105       print "$filename($linecount),".cleanpath($bldinf).",".cleanpath($makefile).",resource,".cleanpath($1).",".ext($1)."\n";        
       
   106     }
       
   107     
       
   108     #<export destination='t:/epoc32/rom/include/sipstatemachine.iby' source='t:/sf/mw/ipappprotocols/sipconnproviderplugins/sipstatemachine/group/SipStateMachine.iby'/>
       
   109     elsif($line =~ m/^<export destination='(\S+)' source='(\S+)'\/>/)
       
   110     {
       
   111       if($bldinf eq "" )
       
   112       {
       
   113         die "$filename($linecount) bldinf=$bldinf: $line\n";
       
   114       }
       
   115       print "$filename($linecount),".cleanpath($bldinf).",".cleanpath($2).",export,".cleanpath($1).",".ext($1)."\n";    
       
   116     }
       
   117   #<recipe name='tem' target='91e4e9b4af8b5c84bbac43a2419a4ce3_RELEASABLES' host='LON-ENGBUILD87' layer='os' component='localesupport' bldinf='t:/sf/os/kernelhwsrv/localisation/localesupport/bld.inf' mmp='' config='winscw_urel.whatlog' platform='WINSCW' phase='BITMAP' source='copy_default.mk_RELEASABLES'>
       
   118     
       
   119     elsif($line =~ m/<recipe.+bldinf='(\S+)'.+source='(\S+)'>/)
       
   120     {
       
   121       $bldinf = $1;
       
   122       $makefile = $2;
       
   123       $inrecipe = 1;    
       
   124     }
       
   125     elsif($inrecipe && $line =~ m/^(\S:\S+)/)
       
   126     {
       
   127       if($bldinf eq "" || $makefile eq "" && !$keepgoing)
       
   128       {
       
   129         die "$filename($linecount) bldinf=$bldinf makefile=$makefile : $line\n";
       
   130       }
       
   131       my $str = cleanpath($1);
       
   132       
       
   133       print "$filename($linecount),".cleanpath($bldinf).",".cleanpath($makefile).",custom,".cleanpath($str).",".ext($str)."\n";
       
   134     }
       
   135     
       
   136     elsif($line =~ m/<\/recipe>/)
       
   137     {
       
   138       $bldinf = "";
       
   139       $makefile = "";
       
   140       $inrecipe = 0;
       
   141     }
       
   142     
       
   143       
       
   144   }
       
   145   close FILE;
       
   146 }