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.

173 lines
4.1 KiB

  1. #------------------------------------------------------------------
  2. #
  3. # spcopywow.pl : Surajp
  4. # Copy wowfiles from x86 M/c. Called from spcopywow64.cmd
  5. #
  6. # Copyright (c) Microsoft Corporation. All rights reserved.
  7. #
  8. # ------------------------------------------------------------------
  9. use strict;
  10. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  11. use lib $ENV{RAZZLETOOLPATH};
  12. use PbuildEnv;
  13. use ParseArgs;
  14. use Logmsg;
  15. use File::Copy;
  16. use File::Path;
  17. use Data::Dumper;
  18. use File::Basename;
  19. my %files;
  20. my($spmap,$copywowlist,$sourcepath,$destpath,$qfe)= @ARGV;
  21. open MAP, $spmap or die $!;
  22. my @map1=<MAP>;
  23. close MAP;
  24. my %map;
  25. foreach my $file ( @map1 ) {
  26. next if $file !~ /^([^\;\s]*\s+)?([^\;\s]*)/;
  27. my ($tag, $file) = ($1, $2);
  28. next if $tag =~ /[wd]/i;
  29. $map{lc basename($file)}++;
  30. }
  31. my @return;
  32. open LIST,$copywowlist or die $!;
  33. foreach (<LIST>){
  34. chomp;
  35. s/\s+//g;
  36. my $name=basename($_);
  37. if (exists $map{lc$name}){
  38. if ($_ =~ /(.*)\\(.*)/){
  39. ${$files{$1}}{$2}++;
  40. }
  41. else{
  42. ${$files{"."}}{$_}++;
  43. }
  44. }
  45. }
  46. close LIST;
  47. if ($qfe) {
  48. load_symbol_paths("$sourcepath\\symbolcd\\symupd.txt");
  49. }
  50. my $qfeSourcepath = "$sourcepath";
  51. my $qfeWow6432Path = "$sourcepath\\wow6432";
  52. foreach my $key (keys(%files)){
  53. open OUTFILE,"+> $ENV{tmp}\\outfile.txt";
  54. foreach my $filename ( keys (%{$files{$key}}) ) {
  55. print OUTFILE "$filename \n";
  56. copy_symbol($filename) if $qfe;
  57. }
  58. close OUTFILE;
  59. if ( $key eq ".") {
  60. sys("compdir /enrstdm:$ENV{tmp}\\outfile.txt $qfeSourcepath $destpath");
  61. }
  62. else {
  63. sys("compdir /enrstdm:$ENV{tmp}\\outfile.txt $qfeSourcepath\\$key $destpath\\$key");
  64. }
  65. }
  66. if ( -d "$qfeWow6432Path" ) {
  67. dirlist("$qfeWow6432Path");
  68. open OUTFILE,"+>$ENV{tmp}\\outfile1.txt";
  69. foreach (@return){
  70. next if (/^\.|^\.\./);
  71. s/\s*//g;
  72. my $name = basename($_);
  73. if (exists $map{lc$name}){
  74. print OUTFILE "$_ \n" ;
  75. copy_symbol($_) if $qfe;
  76. }
  77. }
  78. close OUTFILE;
  79. sys("compdir /eabnstdm:$ENV{tmp}\\outfile1.txt $qfeWow6432Path $destpath");
  80. }
  81. sys("rename $destpath\\asms wasms") if (-d "$destpath\\asms");
  82. sys("compdir /eabnstd $qfeSourcepath\\asms $destpath\\asms") if (-d "$qfeSourcepath\\asms");
  83. sub dirlist {
  84. my ($root, $dir) = @_;
  85. my $full = $dir ? "$root\\$dir" : $root;
  86. opendir DIR, $full or die "$!: $full";
  87. my @stuff = readdir DIR;
  88. closedir DIR;
  89. for my $file (@stuff) {
  90. next if $file =~ /^\.\.?$/;
  91. if (-d "$full\\$file") {
  92. push @return, dirlist($root, ($dir ? "$dir\\$file" : $file));
  93. }
  94. else {
  95. push @return, basename($dir ? "$dir\\$file" : $file);
  96. }
  97. }
  98. }
  99. sub sys {
  100. my $cmd = shift;
  101. print "$cmd\n";
  102. system($cmd);
  103. if ($?) {
  104. die "ERROR: $cmd ($?)\n";
  105. }
  106. }
  107. {
  108. my %sym;
  109. sub load_symbol_paths {
  110. my $binp_file = shift;
  111. if ( !open BINP, $binp_file ) {
  112. errmsg "open failed $binp_file: $!";
  113. die;
  114. }
  115. while (<BINP>) {
  116. chomp;
  117. my ($bin, $pri, $pub) = split /\,/;
  118. if ($pub or $pri) {
  119. $pub = "" if !$pub;
  120. $pri = "" if !$pri;
  121. $sym{lc $bin} = lc "$pub $pri";
  122. }
  123. }
  124. close BINP;
  125. my $nosym = "$ENV{RAZZLETOOLPATH}\\symdontship.txt";
  126. if ( !open DONTSHIP, $nosym ) {
  127. errmsg "open failed $nosym: $!";
  128. die;
  129. }
  130. while (<DONTSHIP>) {
  131. s/\s*(\;.*)?\s*$//;
  132. my $bin = lc $_;
  133. undef $sym{lc $bin};
  134. }
  135. close DONTSHIP;
  136. }
  137. sub copy_a_symbol {
  138. my ($sym) = @_;
  139. my ($dir,$file) = $sym=~/^(.*\\)?[^\\]*$/;
  140. $dir =~ s/^.*(symbols(?:.pri)?\\)/\1/i;
  141. $dir =~ s/\\$//;
  142. logmsg("symbol copy: copy $sourcepath\\$sym $destpath\\$dir\\$file");
  143. sys("md $destpath\\$dir") if !-d "$destpath\\$dir";
  144. copy("$sourcepath\\$sym", "$destpath\\$dir\\$file");
  145. }
  146. sub copy_symbol {
  147. my ($src) = @_;
  148. $src = lc $src;
  149. return if !defined $sym{$src};
  150. $src = $sym{$src};
  151. my ($pub, $pri) = split(/ /, $src);
  152. copy_a_symbol($pub) if defined $pub and $pub ne "";
  153. copy_a_symbol($pri) if defined $pri and $pri ne "";
  154. }
  155. }