sbsv2/raptor/bin/createrfifile.pl
changeset 2 39c28ec933dd
child 13 c327db0664bb
equal deleted inserted replaced
1:820b22e13ff1 2:39c28ec933dd
       
     1 #
       
     2 # Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     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 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 
       
    17 use strict;
       
    18 use File::Basename;
       
    19 use Getopt::Long;
       
    20 
       
    21 my $verbose = 0;
       
    22 my ($rfifile, $excludepath) = "";
       
    23 GetOptions ('v' => \$verbose, 'o=s' => \$rfifile, 'x=s' => \$excludepath);
       
    24 
       
    25 if (!$rfifile || @ARGV < 1)
       
    26 	{
       
    27 	print (STDERR "\ncreaterfifile.pl\n");
       
    28 	print STDERR << 'END_OF_HELP';
       
    29 
       
    30 Usage: createrfifile.pl [-v] -o outputfile.rfi [-x excludepath] rss_cpp_deps_file_1.d rss_cpp_deps_file_n.d
       
    31 
       
    32 Takes one or more files containing CPP dependency output from the preprocessing of a .rss file and
       
    33 generates a "combined resource" .rfi that can  be consumed by CDB.
       
    34 Optionally takes an exclusion path under which "found" dependencies can be ignored.
       
    35 
       
    36 END_OF_HELP
       
    37 	exit(0);
       
    38 	}
       
    39 
       
    40 my @depfiles = @ARGV;
       
    41 
       
    42 my $exclude = $excludepath;
       
    43 if ($exclude)
       
    44 	{
       
    45 	$exclude =~ s/\\/\//g;			# Ensure consistent slashes
       
    46 	$exclude =~ s/\/\//\//g;		# Remove double slashes
       
    47 	$exclude = quotemeta($exclude);	# Convert for regex match
       
    48 	}
       
    49 
       
    50 print ("RFI : exclude under - \"$exclude\"\n") if ($verbose);
       
    51 
       
    52 my @resources;
       
    53 my %loggedresources;
       
    54 foreach my $depfile (@depfiles)
       
    55 	{
       
    56 	open DEPFILE, "< $depfile" or die "\nRFI : Cannot read \"$depfile\"!\n\n";
       
    57 	while (<DEPFILE>)
       
    58 		{
       
    59 		# .d file format - whitespace at front is key, path format varies depending on platform
       
    60 		# the aim is to get a list of the "real" files. Missing files can appear "unpathed"
       
    61 		#
       
    62 		#Audio.rsc: M:/src/common/techview/apps/audio/Src/Audio.rss \
       
    63 		#  M:/epoc32/include/variant/Symbian_OS.hrh \
       
    64 		#  M://epoc32/include/techview/eikon.rh \
       
    65 		#  M://epoc32/include/techview/eikon.hrh M://epoc32/include/uikon.hrh \
       
    66 		#  M://epoc32/include/techview/controls.hrh \
       
    67 		#  M://epoc32/include/eikcolor.hrh \
       
    68 		#  M://epoc32/include/techview/techview.hrh M://epoc32/include/uikon.rh \
       
    69 		#  M://epoc32/include/badef.rh M://epoc32/include/baerrrsvr.rh \
       
    70 		#  M://epoc32/include/techview/controls.rh M://epoc32/include/gulftflg.hrh \
       
    71 		#  M://epoc32/include/eikcore.rsg M://epoc32/include/eikcoctl.rsg \
       
    72 		#  M://epoc32/include/eikctl.rsg M://epoc32/include/eikfile.rsg \
       
    73 		#  M://epoc32/include/eikprint.rsg M://epoc32/include/audio.mbg \
       
    74 		#  M:/src/common/techview/apps/audio/Src/Audio.hrh \
       
    75 		#  M:/src/common/techview/apps/audio/Src/NewAudio.rls
       
    76 		
       
    77 		s/^.*\.\w+\://;
       
    78 		s/\\$//;
       
    79 		s/^\s+//;
       
    80 		s/\s+$//;
       
    81 		s/\/\//\//g;
       
    82 		chomp $_;
       
    83 		next if !/\S/;	
       
    84 	
       
    85 		my @dependencies = split;	
       
    86 		foreach my $dependency (@dependencies)
       
    87 			{
       
    88 			next if ($exclude && $dependency =~ /^$exclude/i);
       
    89 			print ("WARNING: Could not find dependency \"$dependency\" in \"$depfile\"\n") if (!-e $dependency and $verbose);		
       
    90 			print ("RFI : processing - \"$dependency\"\n") if ($verbose);
       
    91 			
       
    92 			if (!defined $loggedresources{$dependency})
       
    93 				{
       
    94 				push @resources, $dependency;
       
    95 				$loggedresources{$dependency} = 1;
       
    96 				}
       
    97 			}
       
    98 		}
       
    99 	close DEPFILE;
       
   100 	}
       
   101 
       
   102 open RFIFILE, "> $rfifile" or die "\nRFI : Cannot write \"$rfifile\"!\n\n";
       
   103 foreach my $resource (@resources)
       
   104 	{
       
   105 	print RFIFILE "\n\n/* GXP ***********************\n";
       
   106 	print RFIFILE " * ".basename($resource)."\n";
       
   107 	print RFIFILE " ****************************/\n\n";
       
   108 	
       
   109 	open RESOURCE, "< $resource" or die "\nCannot read \"$resource\"!\n\n";
       
   110 	print RFIFILE $_ while (<RESOURCE>);
       
   111 	close RESOURCE;
       
   112 	}
       
   113 close RFIFILE;
       
   114