|
1 #!/usr/bin/perl |
|
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 "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 |
|
20 if (@ARGV <2) |
|
21 { |
|
22 print (STDERR "\ncreaterfifile.pl\n"); |
|
23 print STDERR << 'END_OF_HELP'; |
|
24 |
|
25 Usage: createrfifile.pl rss_cpp_deps_file.d output_file.rfi [exclude path] |
|
26 |
|
27 Takes a file containing CPP dependency output from the preprocessing of a .rss file and |
|
28 generates a "combined resource" .rfi that can be consumed by CDB. |
|
29 Optionally takes an exclusion path under which "found" dependencies are then ignored. |
|
30 |
|
31 END_OF_HELP |
|
32 exit(0); |
|
33 } |
|
34 |
|
35 my ($deps, $rfi, $exclude) = @ARGV; |
|
36 |
|
37 if ($exclude) |
|
38 { |
|
39 $exclude =~ s/\\/\//g; # Ensure consistent slashes |
|
40 $exclude =~ s/\/\//\//g; # Remove double slashes |
|
41 $exclude = quotemeta($exclude); # Convert for regex match |
|
42 } |
|
43 |
|
44 print ("RFI : exclude under - \"$exclude\"\n"); |
|
45 |
|
46 my @resources; |
|
47 open DEPS, "< $deps" or die "\nCannot read \"$deps\"!\n\n"; |
|
48 while (<DEPS>) |
|
49 { |
|
50 # .d file format - whitespace at front is key, path format varies depending on platform |
|
51 # the aim is to get a list of the "real" files. Missing files can appear "unpathed", although |
|
52 # this isn't currently dealt with. |
|
53 # |
|
54 #HelloWorld_reg.o: \ |
|
55 # F:/source/personal/misc/filenamepolicy/ported/examples/helloworld/HelloWorld_reg.rss \ |
|
56 # F:/builds/sbs/9.5/epoc32/include/variant/Symbian_OS.hrh \ |
|
57 # F:/builds/sbs/9.5/epoc32/include/appinfo.rh \ |
|
58 # F:/builds/sbs/9.5/epoc32/include/helloworld.rsg |
|
59 # |
|
60 |
|
61 s/^.*\.o\://; |
|
62 s/^\s+//; |
|
63 s/\s*\\$//; |
|
64 s/\/\//\//g; |
|
65 chomp ($_); |
|
66 next if !/\S/; |
|
67 |
|
68 print ("WARNING: Could not find dependency \"$_\" in \"$deps\"\n") if !(-e $_); |
|
69 |
|
70 print ("RFI : processing - \"$_\"\n"); |
|
71 next if ($exclude && /^$exclude/i); |
|
72 push @resources,$_; |
|
73 } |
|
74 close DEPS; |
|
75 |
|
76 open RFI, "> $rfi" or die "\nCannot write \"$deps\"!\n\n"; |
|
77 foreach my $resource (@resources) |
|
78 { |
|
79 print RFI "\n\n/* GXP ***********************\n"; |
|
80 print RFI " * ".basename($resource)."\n"; |
|
81 print RFI " ****************************/\n\n"; |
|
82 |
|
83 open RESOURCE, "< $resource" or die "\nCannot read \"$resource\"!\n\n"; |
|
84 print RFI $_ while (<RESOURCE>); |
|
85 close RESOURCE; |
|
86 } |
|
87 close RFI; |
|
88 |