createrfifile.pl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. use strict;
  17. use File::Basename;
  18. use Getopt::Long;
  19. my $verbose = 0;
  20. my ($rfifile, $excludepath) = "";
  21. GetOptions ('v' => \$verbose, 'o=s' => \$rfifile, 'x=s' => \$excludepath);
  22. if (!$rfifile || @ARGV < 1)
  23. {
  24. print (STDERR "\ncreaterfifile.pl\n");
  25. print STDERR << 'END_OF_HELP';
  26. Usage: createrfifile.pl [-v] -o outputfile.rfi [-x excludepath] rss_cpp_deps_file_1.d rss_cpp_deps_file_n.d
  27. Takes one or more files 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 can be ignored.
  30. END_OF_HELP
  31. exit(0);
  32. }
  33. my @depfiles = @ARGV;
  34. my $exclude = $excludepath;
  35. if ($exclude)
  36. {
  37. $exclude =~ s/\\/\//g; # Ensure consistent slashes
  38. $exclude =~ s/\/\//\//g; # Remove double slashes
  39. $exclude = quotemeta($exclude); # Convert for regex match
  40. }
  41. print ("RFI : exclude under - \"$exclude\"\n") if ($verbose);
  42. my @resources;
  43. my %loggedresources;
  44. foreach my $depfile (@depfiles)
  45. {
  46. open DEPFILE, "< $depfile" or die "\nRFI : Cannot read \"$depfile\"!\n\n";
  47. while (<DEPFILE>)
  48. {
  49. # .d file format - whitespace at front is key, path format varies depending on platform
  50. # the aim is to get a list of the "real" files. Missing files can appear "unpathed"
  51. #
  52. #Audio.rsc: M:/src/common/techview/apps/audio/Src/Audio.rss \
  53. # M:/epoc32/include/variant/Symbian_OS.hrh \
  54. # M://epoc32/include/techview/eikon.rh \
  55. # M://epoc32/include/techview/eikon.hrh M://epoc32/include/uikon.hrh \
  56. # M://epoc32/include/techview/controls.hrh \
  57. # M://epoc32/include/eikcolor.hrh \
  58. # M://epoc32/include/techview/techview.hrh M://epoc32/include/uikon.rh \
  59. # M://epoc32/include/badef.rh M://epoc32/include/baerrrsvr.rh \
  60. # M://epoc32/include/techview/controls.rh M://epoc32/include/gulftflg.hrh \
  61. # M://epoc32/include/eikcore.rsg M://epoc32/include/eikcoctl.rsg \
  62. # M://epoc32/include/eikctl.rsg M://epoc32/include/eikfile.rsg \
  63. # M://epoc32/include/eikprint.rsg M://epoc32/include/audio.mbg \
  64. # M:/src/common/techview/apps/audio/Src/Audio.hrh \
  65. # M:/src/common/techview/apps/audio/Src/NewAudio.rls
  66. s/^.*\.\w+\://;
  67. s/\\$//;
  68. s/^\s+//;
  69. s/\s+$//;
  70. s/\/\//\//g;
  71. chomp $_;
  72. next if !/\S/;
  73. my @dependencies = split;
  74. foreach my $dependency (@dependencies)
  75. {
  76. next if ($exclude && $dependency =~ /^$exclude/i);
  77. print ("WARNING: Could not find dependency \"$dependency\" in \"$depfile\"\n") if (!-e $dependency and $verbose);
  78. print ("RFI : processing - \"$dependency\"\n") if ($verbose);
  79. if (!defined $loggedresources{$dependency})
  80. {
  81. push @resources, $dependency;
  82. $loggedresources{$dependency} = 1;
  83. }
  84. }
  85. }
  86. close DEPFILE;
  87. }
  88. open RFIFILE, "> $rfifile" or die "\nRFI : Cannot write \"$rfifile\"!\n\n";
  89. foreach my $resource (@resources)
  90. {
  91. print RFIFILE "\n\n/* GXP ***********************\n";
  92. print RFIFILE " * ".basename($resource)."\n";
  93. print RFIFILE " ****************************/\n\n";
  94. open RESOURCE, "< $resource" or die "\nCannot read \"$resource\"!\n\n";
  95. print RFIFILE $_ while (<RESOURCE>);
  96. close RESOURCE;
  97. }
  98. close RFIFILE;