common/tools/analysis/scan_antlogs.pl
changeset 97 4f54ca96b7e8
child 164 9a13f5f790ee
equal deleted inserted replaced
93:27826401fee5 97:4f54ca96b7e8
       
     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 # Parse "ant" logs from SBS build to determine missing source files
       
    16 
       
    17 my $pdk_src = "../.."; # path to sf tree - correct from "build/output"
       
    18 
       
    19 my %missing_files;
       
    20 my %damaged_components;
       
    21 my %excluded_things;
       
    22 my %abld_import;
       
    23 my %damaged_bldinfs;
       
    24 
       
    25 sub canonical_path($)
       
    26   {
       
    27   my ($path) = @_;
       
    28   my @bits = split /\//, $path;
       
    29   my @newbits = ();
       
    30   
       
    31   foreach my $bit (@bits)
       
    32     {
       
    33     next if ($bit eq ".");
       
    34     if ($bit eq "..")
       
    35       {
       
    36       pop @newbits;
       
    37       next;
       
    38       }
       
    39       push @newbits, $bit;
       
    40     }
       
    41   return join("/", @newbits);
       
    42   }
       
    43 
       
    44 sub excluded_thing($$$)
       
    45   {
       
    46   my ($path, $missing, $reason) = @_;
       
    47   if (!defined $excluded_things{$path})
       
    48     {
       
    49     @{$excluded_things{$path}} = ();
       
    50     }
       
    51   push @{$excluded_things{$path}}, $missing;
       
    52   # print "Missing $missing from excluded $path ($reason)\n";
       
    53   }
       
    54 
       
    55 sub do_missing_file($$$)
       
    56   {
       
    57   my ($missing, $missing_from, $reason) = @_;
       
    58   
       
    59   $missing = canonical_path($missing);
       
    60   $missing_from = canonical_path($missing_from);
       
    61   
       
    62   my $component = "??";
       
    63   if ($missing_from ne "??")
       
    64     {
       
    65     my @dirs = split /\//, $missing_from;
       
    66     shift @dirs if ($dirs[0] eq "sf");
       
    67     
       
    68     $path = $pdk_src . "/sf/$dirs[0]/$dirs[1]";
       
    69     if (!-e $path)
       
    70       {
       
    71       # no sign of the package
       
    72       excluded_thing($path, $missing, $reason);
       
    73       return;
       
    74       }
       
    75     $path .= "/$dirs[2]";
       
    76     if (!-e $path)
       
    77       {
       
    78       # no sign of the collection
       
    79       excluded_thing($path, $missing, $reason);
       
    80       return;
       
    81       }
       
    82     $path .= "/$dirs[3]";
       
    83     if (!-e $path)
       
    84       {
       
    85       # no sign of the component
       
    86       excluded_thing($path, $missing, $reason);
       
    87       return;
       
    88       }
       
    89     $component = join("/", $dirs[0], $dirs[1], $dirs[2], $dirs[3]);
       
    90     }
       
    91   
       
    92   $missing_files{$missing} = $reason if ($missing ne "??");
       
    93   
       
    94   if (!defined $damaged_components{$component})
       
    95     {
       
    96     @{$damaged_components{$component}} = ();
       
    97     }
       
    98   push @{$damaged_components{$component}}, $missing;
       
    99   }
       
   100 
       
   101 sub scan_logfile($)
       
   102 {
       
   103   my ($logfile) = @_;
       
   104   
       
   105   open FILE, "<$logfile" or print "Error: cannot open $logfile: $!\n" and return;
       
   106   
       
   107   my $line;
       
   108   while ($line = <FILE>)
       
   109     {
       
   110     # Could not export s:/sf/mw/classicui/commonuisupport/uikon/docs/Uikon_1.2_Caps_Lock_Extension.doc to s:/epoc32/engdoc/application_framework/uikon/uikon_1.2_caps_lock_extension.doc
       
   111     if ($line =~ /^Could not export .*\/(sf\/.*) to .:\/(epoc32\/.*)$/)
       
   112       {
       
   113       my $source = $1;
       
   114       my $exported = $2;
       
   115       if (-e "m:/$exported")
       
   116         {
       
   117         $abld_import{$source} = $exported;
       
   118         }
       
   119       next;
       
   120       }
       
   121     # Source of export does not exist:  s:/sf/mw/messagingmw/messagingfw/msgtests/group/msgerr.ra
       
   122     # Source zip for export does not exist: s:/sf/os/deviceplatformrelease/S60LocFiles/data/96.zip
       
   123     if ($line =~ /^Source (of|zip for) export does not exist.\s+.*\/(sf\/.*)$/)
       
   124       {
       
   125       do_missing_file($2, "??", "source of export");
       
   126       next;
       
   127       }
       
   128     # No bld.inf found at sf/os/buildtools/toolsandutils/burtestserver/Group in s:/output/build/canonical_system_definition_GT_tb91sf.xml
       
   129     # No bld.inf found at s:/sf/adaptation/stubs/licensee_tsy_stub/group in s:/output/build/canonical_system_definition_S60_5_1_clean.xml
       
   130     if ($line =~ /No bld.inf found at (.*\/)?(sf\/.*) in /i)
       
   131       {
       
   132       my $bldinf = "$2/bld.inf";
       
   133   
       
   134       do_missing_file($bldinf, $bldinf, "no bld.inf");
       
   135       $damaged_bldinfs{"$bldinf\t(missing)"} = 1;
       
   136       next;
       
   137       }
       
   138     # D:/Symbian/Tools/PDT_1.0/raptor/win32/mingw/bin/cpp.exe: s:/sf/os/networkingsrv/networksecurity/ipsec/group/bld.inf:19:42: ../eventmediator/group/bld.inf: No such file or directory
       
   139     if ($line =~ /cpp.exe: .*\/(sf\/[^:]*):.*\s+([^:]+): No such file/)
       
   140       {
       
   141       my $parent = $1;
       
   142       my $relative = $2;
       
   143   
       
   144       if ($parent =~ /\.inf$/i)
       
   145         {
       
   146         my $parent = canonical_path($parent);
       
   147         $damaged_bldinfs{"$parent\t$relative"} = 1;
       
   148         }
       
   149       do_missing_file("$parent/../$relative", $parent, "#include");
       
   150       next;  
       
   151       }
       
   152     }
       
   153     close FILE;
       
   154   }
       
   155   
       
   156   my @logfiles = map(glob,@ARGV);
       
   157   foreach my $logfile (@logfiles)
       
   158     {
       
   159     print "Scanning $logfile...\n";
       
   160     scan_logfile($logfile);
       
   161     }
       
   162   
       
   163   printf "%d Excluded things\n", scalar keys %excluded_things;
       
   164   foreach my $component (sort keys %excluded_things)
       
   165     {
       
   166     my @list = @{$excluded_things{$component}};
       
   167     my %hash;
       
   168     foreach my $missing (@list)
       
   169       {
       
   170       $hash{$missing} = 1;
       
   171       }
       
   172     printf "%s\t%d\n", $component, scalar keys %hash;
       
   173     print "\t", join("\n\t", sort keys %hash), "\n";
       
   174     }
       
   175   print "\nDamaged components\n";
       
   176   foreach my $component (sort keys %damaged_components)
       
   177     {
       
   178     my @list = @{$damaged_components{$component}};
       
   179     my %hash;
       
   180     foreach my $missing (@list)
       
   181       {
       
   182       $hash{$missing} = 1;
       
   183       }
       
   184     printf "%s\t%d\n", $component, scalar keys %hash;
       
   185     print "\t", join("\n\t", sort keys %hash), "\n";
       
   186     }
       
   187   print "\nMissing files\n";
       
   188   foreach my $missing (sort keys %missing_files)
       
   189     {
       
   190     my $exported = $abld_import{$missing};
       
   191     $exported = "(not in PDK)" if (!defined $exported);
       
   192     my $reason = $missing_files{$missing};
       
   193     my @dirs = split /\//, $missing;
       
   194     my $path = shift @dirs;
       
   195     my $dir;
       
   196     
       
   197     while ($dir = shift @dirs)
       
   198       {
       
   199       if (-e "$pdk_src/$path/$dir")
       
   200         {
       
   201         # still exists at this point
       
   202         $path .= "/$dir";
       
   203         next;
       
   204         }
       
   205       print "\t$reason\t$path\t\t", join("/", $dir,@dirs), "\t$exported\n";
       
   206       last;
       
   207       }    
       
   208     }
       
   209   
       
   210   print "\nDamaged bld.infs\n";
       
   211   print join("\n", sort keys %damaged_bldinfs, "");
       
   212   
       
   213   print "\n\n";
       
   214   printf "%d files missing from ", scalar keys %missing_files;
       
   215   printf "%d damaged components\n", scalar keys %damaged_components;
       
   216