Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
2.9 KiB

  1. #
  2. # Get arguments
  3. #
  4. use lib $ENV{RAZZLETOOLPATH};
  5. use Logmsg;
  6. $i=0;
  7. for (@ARGV) {
  8. if (/^[-\/]fl:(.*)$/i) { $flist = $1; next; }
  9. if (/^[-\/]mk:(.*)$/i) { $mkfil = $1; next; }
  10. if (/^[-\/]cmd1:(.*)$/i) { $cmd1 = $1; next; }
  11. if (/^[-\/]path:(.*)$/i) { $path = $1; next; }
  12. if (/^[-\/]relpath:(.*)$/i) { push( @relpaths, $1); next; }
  13. if (/^[-\/]t:(.*)$/i) { $tempdir = $1; next; }
  14. }
  15. #print "$mkfil\n";
  16. # Cleanup any turd temporary files
  17. system "del /f $tempdir\\ansitmp >nul 2>nul";
  18. $mkerr = open MKFIL, ">$mkfil";
  19. $flerr = open FLIST, ">$flist";
  20. if( $mkerr == 0 ){
  21. errmsg ("Error - Could not open $mkfil for writing\n");
  22. exit( 1 );
  23. }
  24. if( $flerr == 0 ){
  25. errmsg ("Error - Could not open $flist for writing\n");
  26. exit( 1 );
  27. }
  28. # Write the rule
  29. print MKFIL "make_drv:drvindex\.gen\n\n\n";
  30. # Write the dependencies
  31. print MKFIL "drvindex\.gen:";
  32. #while (<FLIST>) {
  33. # y/\n/ /;
  34. # print MKFIL " \\\n\t$_";
  35. #}
  36. # For loop to iterate throught the files
  37. push @relpaths, "";
  38. for( $i=0; $i <= $#relpaths; $i++ ) {
  39. #print "$i $relpaths[$i]\n";
  40. push @srcpaths, ($path."\\".$relpaths[$i]);
  41. }
  42. #print @srcpaths;
  43. # Iterate through directories
  44. for( $i=0; $i <= $#srcpaths; $i++ ) {
  45. #print "$i $srcpaths[$i]\n";
  46. $dir = $srcpaths[$i];
  47. if (!opendir CURDIR, $dir){
  48. errmsg ("Error - Could not open $dir\n");
  49. close MKFIL;
  50. close FLIST;
  51. exit( 1 );
  52. }
  53. while (($curfile = readdir CURDIR) ne "" ) {
  54. # Look for INFs
  55. if ($curfile =~ /.*\.inf/i) {
  56. #print "$dir\\$curfile\n";
  57. if( $curfile =~ /layout.inf/i){
  58. # Special case files to let in
  59. ;
  60. }else{
  61. #Take care of UNICODE
  62. system "unitext -u -z $dir\\$curfile $tempdir\\ansitmp >nul";
  63. $inffileerr=open FILE, "$tempdir\\ansitmp";
  64. #if this was ANSI ....
  65. if( $inffileerr == 0 ){
  66. $inffileerr=open FILE, "$dir\\$curfile";
  67. }
  68. if( $inffileerr == 0 ){
  69. errmsg ("Error - Could not open $dir\\$curfile for reading\n");
  70. exit( 1 );
  71. }
  72. $matched_lines = grep { /ClassGUID(\s*)=(\s*){.*}/i and !/ClassGUID(\s*)=(\s*){00000000-0000-0000-0000-000000000000}/i } <FILE>;
  73. # print "$dir\\$curfile ---- $matched_lines\n";
  74. close FILE;
  75. system "del /f $tempdir\\ansitmp >nul 2>nul";
  76. if($matched_lines < 1){
  77. # print "Skipping $dir\\$curfile\n";
  78. next;
  79. }
  80. }
  81. # At this point we know the file is a PNP inf.
  82. print MKFIL " \\\n\t$relpaths[$i]$curfile";
  83. print FLIST "$dir\\$curfile, $relpaths[$i]$curfile\n";
  84. }
  85. }
  86. closedir CURDIR;
  87. }
  88. print MKFIL "\n\t$cmd1";
  89. print MKFIL "\n\n";
  90. close MKFIL;
  91. close FLIST;
  92. exit( 0 );