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.

120 lines
3.5 KiB

  1. # FileName: CombineDistributeBinplaceLogs.pl
  2. #
  3. #
  4. # Usage: CombineDistributeBinplaceLogs.pl [-nttree=nttreedir]
  5. #
  6. # Function: The distributed build process produces a unique binplace_%COMPUTERNAME%.log file
  7. # for each machine involved in the build.
  8. # This script combines them into a unified binplace.log file
  9. # translating the path information to coorespond to the local
  10. # enlistment.
  11. #
  12. # If there are no files named binplace_*,log then this script exits silently.
  13. #
  14. # Author: jporkka 03/24/2000
  15. #
  16. # Usage variables
  17. #
  18. $PGM='CombineDistributeBinplaceLogs: ';
  19. $Usage = $PGM . "Usage: CombineDistributeBinplaceLogs.pl [-nttree=nttreedir]\n";
  20. #
  21. # Process and validate arguments
  22. #
  23. for (@ARGV) {
  24. if (/^[\/\-]test$/i) { $Test++; next; }
  25. if (/^[\/\-]verbose$/i) { $Verbose++; next; }
  26. if (/^[\/\-]nttree=(.+)$/i) { $XNTTree++; $NTTree = $1; next; }
  27. if (/^[\/\-]?$/i) { die $Usage; }
  28. if (/^[\/\-]help$/i) { die $Usage; }
  29. die $Usage;
  30. }
  31. # Functions
  32. #
  33. # print on the various files
  34. #
  35. sub printall {
  36. print LOGFILE @_;
  37. print $PGM unless @_ == 1 and @_[0] eq "\n";
  38. print @_;
  39. }
  40. #
  41. # Get the current directory
  42. #
  43. open CWD, 'cd 2>&1|';
  44. $CurrDir = <CWD>;
  45. close CWD;
  46. chomp $CurrDir;
  47. $CurrDrive = substr($CurrDir, 0, 2);
  48. #
  49. $sdxroot = $ENV{'SDXROOT'} or die $PGM, "Error: SDXROOT not set in environment\n";
  50. $LogFile = "build.combinebinplace";
  51. #
  52. # If we didn't get the NTTree directory from the command line,
  53. # get it from the _NTTREE environment variable.
  54. #
  55. if ($XNTTree == 0) {
  56. $NTTree = $ENV{'_NTTREE'};
  57. $XNTTree = 1;
  58. }
  59. #
  60. # Can only CombineDistributeBinplaceLogs with the current directory the same as sdxroot.
  61. #
  62. die $PGM, "Error: Can only CombineDistributeBinplaceLogs if CD <$CurrDir> is SDXROOT <$sdxroot>\n" unless $sdxroot =~ /^\Q$CurrDir\E$/io;
  63. die $Usage unless $XNTTree == 1 and $NTTree;
  64. die $PGM, "Error: Not a directory: ", $NTTree, "\n" unless -d $NTTree;
  65. die $PGM, "Error: Not writable: ", $NTTree, "\n" unless -w $NTTree;
  66. #
  67. # Open the logfile
  68. #
  69. $foo = "$NTTree\\build_logs\\$LogFile";
  70. open LOGFILE, ">>$foo" or die $PGM, "Error: Could not create logfile: ", $foo, ": $!\n";
  71. @binplacelogFiles = glob("$NTTree\\build_logs\\binplace_*.log") or exit 0;
  72. open BINPLACE, ">$NTTree\\build_logs\\binplace.log" or die $PGM, "Error: Could not create: ", "$NTTree\\build_logs\\binplace.log", "\n";
  73. # process the list of binplace files.
  74. # the first line of the file must be of the form:
  75. # C:\mt\nt\__blddate__ Fri Mar 24 12:59:25 2000
  76. # Where everything upto __blddata__ is the enlistment path
  77. # where the build was done.
  78. for (@binplacelogFiles) {
  79. $binplacelog = $_;
  80. #
  81. # Read in the VBL and NTTree binplace logs and process them
  82. #
  83. printall "Opening $binplacelog \n";
  84. open BINPLACE_COMPUTERNAME, $binplacelog or die $PGM, "Error: Could not open: ", "$binplacelog", "\n";
  85. $whichline = 0;
  86. $binplaceroot = $sdxroot;
  87. $firstline = <BINPLACE_COMPUTERNAME>;
  88. if ( $firstline =~ /^(.*)\\__blddate__/io) {
  89. $binplaceroot=$1;
  90. } else {
  91. die $PGM, "Error: first line of $binplacelog was not __blddate__ format\n";
  92. }
  93. print LOGFILE $firstline;
  94. print BINPLACE $firstline;
  95. for (<BINPLACE_COMPUTERNAME>) {
  96. $whichline++;
  97. if (/^\Q$binplaceroot\E\\(.*)$/i) {
  98. print BINPLACE "$sdxroot\\$1\n";
  99. } else {
  100. print BINPLACE $_;
  101. }
  102. }
  103. }
  104. exit 0;