bldsystemtools/commonbldutils/abldcache.pl
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 #!perl
       
     2 
       
     3 # Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 # All rights reserved.
       
     5 # This component and the accompanying materials are made available
       
     6 # under the terms of "Eclipse Public License v1.0"
       
     7 # which accompanies this distribution, and is available
       
     8 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9 #
       
    10 # Initial Contributors:
       
    11 # Nokia Corporation - initial contribution.
       
    12 #
       
    13 # Contributors:
       
    14 #
       
    15 # Description:
       
    16 #
       
    17 
       
    18 use File::Path;
       
    19 use Data::Dumper;
       
    20 
       
    21 $Data::Dumper::Deepcopy = 1;
       
    22 
       
    23 #-----------------GLOBAL VARIABLES------------------------#
       
    24 
       
    25 my $command;
       
    26 my $source;
       
    27 my $target;
       
    28 my $component;
       
    29 my $flag = 0;
       
    30 my $plats = 0;
       
    31 
       
    32 my @temp;
       
    33 my %output;
       
    34 my %project_platforms;
       
    35 my @components;
       
    36 
       
    37 my $platform;
       
    38 
       
    39 #--------------------------------------------------------#
       
    40 
       
    41 #Check that correct number of arguments were specified by the user
       
    42 #If not then print out Usage instructions to the command window	
       
    43 Usage() if (@ARGV!=1);
       
    44 
       
    45 $platform = $ARGV[0];
       
    46 
       
    47 my %logfiles = (
       
    48 		"GT2.log" => "M:\\logs\\$platform\\GT2.log",
       
    49 		"TV2.log" => "M:\\logs\\$platform\\TV2.log",
       
    50 		"JAVA2.log" => "M:\\logs\\$platform\\java2.log",
       
    51 	       );
       
    52 
       
    53 foreach my $file (keys %logfiles)
       
    54 {
       
    55 	$plats = 0;
       
    56 	
       
    57 	open(LOGFILE, $logfiles{$file}) || warn "Warning: can't open $logfiles{$file} : $!";
       
    58 
       
    59 	while(my $line = <LOGFILE>)
       
    60 	{
       
    61 		my $exists = 0;
       
    62 		if($line =~ m%^=== Stage=.*\s==\s(.*)\n%i)
       
    63 		{
       
    64 			$component = "$1 ";
       
    65 		}
       
    66 	   
       
    67 		if($line =~ m%-- abld -what\s(.*)%i)
       
    68 		{
       
    69 			foreach my $entry (@components)
       
    70 			{
       
    71 				$exists = 1 if($entry eq $component);
       
    72 			}
       
    73 		
       
    74 			push @components, $component if ($exists == 0);
       
    75 		
       
    76 			$command = "$1 -what";
       
    77 			$flag = 1;
       
    78 			@temp =();
       
    79 		}
       
    80 	
       
    81 		if(($line =~ m%Chdir (M:)?(.*)%i)&&($flag == 1))
       
    82 		{
       
    83 			$source = "$2 ";
       
    84 			$target = $component.$source.$command;
       
    85 		}
       
    86 	
       
    87 		if(($line =~ m%^(\\EPOC32\\.*)\n%i)&&($flag == 1))
       
    88 		{
       
    89 			push @temp, $1;
       
    90 		}
       
    91 		# Match ..\..\..\..\..\..\..\..\..\..\epoc32
       
    92 		if(($line =~ m%^((\.\.\\){1,}EPOC32\\.*)\n%i)&&($flag == 1))
       
    93 		{
       
    94 			push @temp, $1;
       
    95 		}
       
    96 	
       
    97 		if(($line =~ m%^\+\+\+ HiRes End%i)&&($flag == 1))
       
    98 		{
       
    99 			$flag = 0;
       
   100 			my @files = @temp;
       
   101 			$output{$target} = \@files;
       
   102 		}
       
   103 	
       
   104 		if($line =~ m%^project platforms%i)
       
   105 		{
       
   106 			$plats = 1;
       
   107 			next
       
   108 		}
       
   109 	
       
   110 		if($plats == 1)
       
   111 		{
       
   112 			$plats = 0;
       
   113 			$line =~ s/^\s+//;
       
   114 			$line =~ s/\n$//;
       
   115 			my @platforms = split(/ /, $line);
       
   116 			$project_platforms{$component} = \@platforms;
       
   117 		}
       
   118 	}
       
   119 }
       
   120 
       
   121 foreach my $comp (@components)
       
   122 {
       
   123 	$comp =~ s/\s$//;
       
   124 	my %abldcache;
       
   125 	my %self;
       
   126 	my $path;
       
   127 	
       
   128 	foreach my $hashelement (keys %output)
       
   129 	{
       
   130 		$hashelement =~ /(.*)\s(\\src.*?)\s/;
       
   131 		my $temp_element = $1;
       
   132 		if ($temp_element eq $comp)
       
   133 		{
       
   134 			$path = $2;
       
   135 			$path =~ s/\\src/src/;
       
   136 			my $newkey = $hashelement;
       
   137 			$newkey =~ s/.*\s\\src/\\src/;
       
   138 			$newkey = "'".$newkey."'";
       
   139 			$abldcache{$newkey} = $output{$hashelement};
       
   140 			$abldcache{"'plats'"} = $project_platforms{$comp." "};
       
   141 		}
       
   142 	}
       
   143 	
       
   144 	$self{abldcache} = \%abldcache;
       
   145 	
       
   146 	mkpath ("M:\\abldcache\\$path", 0, 0744);
       
   147 		
       
   148 	open OUTFILE, "> M:\\abldcache\\$path\\cache"
       
   149 		or die "ERROR: Can't open M:\\abldcache\\$path\\cache for output\n$!";
       
   150 			
       
   151 	print OUTFILE Data::Dumper->Dump(per_key('$self->{abldcache}->', $self{abldcache})), "\n";
       
   152 		
       
   153 	close OUTFILE;
       
   154 }
       
   155 
       
   156 sub per_key
       
   157 {
       
   158 	my($name, $href) = @_;
       
   159 	my @hkeys = keys %$href;
       
   160 	([@$href{@hkeys}], [map {"$name\{$_}"} @hkeys])
       
   161 }
       
   162 	
       
   163 
       
   164 sub Usage
       
   165 	{
       
   166 	 print <<USAGE_EOF;
       
   167 	 
       
   168 USAGE
       
   169 ----------
       
   170 perl abldcache <platform>
       
   171 
       
   172 USAGE_EOF
       
   173 
       
   174 	exit 1;
       
   175 	}