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.

125 lines
3.0 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. $DbgVerFile=".\\dbg-common\\dbgver.h";
  57. $EmVerFile=".\\dbg-common\\emver.h";
  58. @FileList= ($DbgVerFile, $EmVerFile );
  59. foreach $ThisFile (@FileList) {
  60. logmsg( "Incrementing build number for $ThisFile",
  61. $LogFilename );
  62. # Sync the dbgver.h file
  63. system( "sd revert $ThisFile" );
  64. system( "sd sync -f $ThisFile" );
  65. # Edit the dbgver.h file
  66. system( "sd edit $ThisFile" );
  67. # Make a copy of it
  68. my ( $ThisFile_old );
  69. $ThisFile_old = $ThisFile . "_old";
  70. system( "copy $ThisFile $ThisFile_old" );
  71. # Update the build number in it
  72. my ( $Line );
  73. my ( $fh_in );
  74. unless ( $fh_in = new IO::File $ThisFile_old, "r" ) {
  75. errmsg( "Failed to open $ThisFile_old for read" );
  76. return;
  77. }
  78. my( $fh_out );
  79. unless ( $fh_out = new IO::File $ThisFile, "w" ) {
  80. errmsg( "Failed to open $ThisFile for write" );
  81. return;
  82. }
  83. my($IdentifyLine);
  84. $IdentifyLine="#define\\s+VER_PRODUCTBUILD\\s+(\\d+)";
  85. while ( $Line = <$fh_in> ) {
  86. chomp( $Line );
  87. if ( $Line =~ /$IdentifyLine/) {
  88. my ($match)=$1;
  89. logmsg("New build number is $1 + 1", $LogFilename );
  90. $Line=~s/$match/$match+1/e;
  91. }
  92. print( $fh_out "$Line\n" );
  93. }
  94. undef( $fh_in );
  95. undef( $fh_out );
  96. system( "del /f /q $ThisFile_old" );
  97. }
  98. system( "sd submit" );
  99. }