Leaked source code of windows server 2003
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.

126 lines
3.2 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM <<template_script.cmd>>
  5. REM <<purpose of this script>>
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. perl -x "%~f0" %*
  11. goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  15. use lib $ENV{RAZZLETOOLPATH};
  16. use File::Basename;
  17. use PbuildEnv;
  18. use ParseArgs;
  19. use Logmsg;
  20. use A2U;
  21. BEGIN {
  22. # A2u is setting itself as the script_name
  23. $ENV{SCRIPT_NAME} = 'dbgver.cmd';
  24. }
  25. sub Usage { print<<USAGE; exit(1) }
  26. dbgver
  27. Increments the build number by 1 for dbgver.h
  28. USAGE
  29. # global switches/values set on the command line
  30. parseargs('?' => \&Usage
  31. );
  32. # Global Variables
  33. my( $LogFilename );
  34. my( $TempDir );
  35. my( $RazPath );
  36. # call into the Main sub, too much indentation to make this
  37. # toplevel right now
  38. &Main();
  39. sub Main {
  40. # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  41. # Begin Main code section
  42. # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  43. # Return when you want to exit on error
  44. # <Implement your code here>
  45. $Logmsg::DEBUG = 0; # set to 1 to activate logging of dbgmsg's
  46. $LogFilename = $ENV{ "LOGFILE" };
  47. if ( ! defined( $LogFilename ) ) {
  48. $TempDir = $ENV{ "TMP" };
  49. $LogFilename = "$TempDir\\$0.log";
  50. }
  51. $RazPath= $ENV{ "RazzleToolPath" };
  52. timemsg( "Beginning ...", $LogFilename );
  53. # Enter default names for $DbgVerFile
  54. # and EMVerFile
  55. #my( $DbgVerFile, $EmVerFile, @FileList, $ThisFile );
  56. my( $DbgVerFile, @FileList, $ThisFile );
  57. $DbgVerFile=".\\dbg-common\\dbgver.h";
  58. #$EmVerFile=".\\dbg-common\\emver.h";
  59. @FileList= ($DbgVerFile); # , $EmVerFile );
  60. foreach $ThisFile (@FileList) {
  61. logmsg( "Incrementing build number for $ThisFile",
  62. $LogFilename );
  63. # Sync the dbgver.h file
  64. system( "sd revert $ThisFile" );
  65. system( "sd sync -f $ThisFile" );
  66. # Edit the dbgver.h file
  67. system( "sd edit $ThisFile" );
  68. # Make a copy of it
  69. my ( $ThisFile_old );
  70. $ThisFile_old = $ThisFile . "_old";
  71. system( "copy $ThisFile $ThisFile_old" );
  72. # Update the build number in it
  73. my ( $Line );
  74. my ( $fh_in );
  75. unless ( $fh_in = new IO::File $ThisFile_old, "r" ) {
  76. errmsg( "Failed to open $ThisFile_old for read" );
  77. return;
  78. }
  79. my( $fh_out );
  80. unless ( $fh_out = new IO::File $ThisFile, "w" ) {
  81. errmsg( "Failed to open $ThisFile for write" );
  82. return;
  83. }
  84. my($IdentifyLine);
  85. $IdentifyLine="#define\\s+VER_PRODUCTBUILD\\s+(\\d+)";
  86. while ( $Line = <$fh_in> ) {
  87. chomp( $Line );
  88. if ( $Line =~ /$IdentifyLine/) {
  89. my ($match)=$1;
  90. logmsg("New build number is $1 + 1", $LogFilename );
  91. $Line=~s/$match/$match+1/e;
  92. }
  93. print( $fh_out "$Line\n" );
  94. }
  95. undef( $fh_in );
  96. undef( $fh_out );
  97. system( "del /f /q $ThisFile_old" );
  98. }
  99. system( "sd submit $DbgVerFile" );
  100. }