common/tools/ats/ats_generate_index.pl
changeset 844 385ad61f2ab3
child 850 0e8b8d588322
equal deleted inserted replaced
843:c32873117195 844:385ad61f2ab3
       
     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 #   Maciej Seroka, maciej@symbian.org
       
    12 #
       
    13 # Description:
       
    14 #   This is a tool for generating the top-level index for BC test reports.
       
    15 
       
    16 use strict;
       
    17 use File::Copy;
       
    18 use Tie::File;
       
    19 use File::Find;
       
    20 
       
    21 my @files;
       
    22 my @lines;
       
    23 sub Wanted;
       
    24 
       
    25 my $path;
       
    26 if ($ARGV[0]) {
       
    27   $path = $ARGV[0];
       
    28  }
       
    29 else { die "Missing parameter \"path\". For example: //v800020/Publish/SF_builds/symbian2/builds/default/symbian2_default.sf-test-bc-check.PDK_2.0.1.51/ats_reports"; }
       
    30 
       
    31 find(\&Wanted, $path);
       
    32 my $n = 0;
       
    33 foreach (@files) { #Replace "//v800020/Publish" with "http://cdn.symbian,org"
       
    34 	@files[$n] =~ s/\/\/v800020\/Publish/http:\/\/cdn.symbian.org/;
       
    35 	$n++;
       
    36 }
       
    37 #Copy template and insert links
       
    38 copy("report_template.html","index.html") or die ("Cannot copy file \"report_template.html\". $!\n");
       
    39 tie @lines, 'Tie::File', "index.html" or die ("Cannot tie file \"index.html\". $!\n");
       
    40 my $current_line = 0;
       
    41 for (@lines) {
       
    42 	if (/<!-- Insert reports here -->/) {
       
    43 		my $i = 0;
       
    44 		foreach (@files) {
       
    45 			splice @lines, $current_line+$i+1, 0, "<tr class=\"tableData\"><td align=\"center\">" . ($i+1) . "</td>" . "<td align=\"left\"><a href=\"" . @files[$i] . "\">" . @files[$i] . "</a></td></tr>"; 
       
    46 			$i++;
       
    47 		}
       
    48 		last;
       
    49 	}
       
    50 	$current_line++;
       
    51 }
       
    52 untie @lines;
       
    53 print @{files} . " link(s) added.\n";
       
    54 #copy index
       
    55 copy("index.html","$path/index.html") or die ("Cannot copy file \"index.html\" to $path. $!\n");
       
    56 
       
    57 sub Wanted {
       
    58     # only operate on ATS3Report.html files
       
    59     /ATS3Report.html/ or return;	
       
    60 	push (@files, $File::Find::name);
       
    61 }