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.

200 lines
7.6 KiB

  1. package Build;
  2. sub SetBuildNumber {
  3. local( $build, $versionfile ) = @_;
  4. local( $debugfound ) = 0;
  5. if ( -f "$versionfile.bak" ) {
  6. system ("del /f \"$versionfile.bak\"");
  7. }
  8. if ( ! rename ("$versionfile", "$versionfile.bak") ) {
  9. print "Error renaming $versionfile to $versionfile.bak: $!.\n";
  10. }
  11. else {
  12. if ( ! open (INFILE, "<$versionfile.bak") ) {
  13. print "Error opening file $versionfile.bak: $!.\n";
  14. }
  15. else {
  16. if ( ! open (OUTFILE, ">$versionfile") ) {
  17. print "Error opening file $versionfile: $!.\n";
  18. }
  19. else {
  20. while (<INFILE>) {
  21. # for EaVer.hpp
  22. s/(.*\sEA_VER_MOD\s\D*)\d+(\D*)/$1$build$2/;
  23. # for .RC files
  24. s/(.*FILEVERSION\s\d+,\d+,\d+,)\d+(.*)/$1$build$2/;
  25. s/(.*FileVersion.*\d+, \d+, \d+, )\d+(.*\\0.*)/$1$build$2/;
  26. # for ASP pages
  27. s/(.*Application\(\"VersionInfo\"\).*Version.*\d+\.\d+\.\d+)\s+\(Build \d+\)(.*)/$1 (Build $build)$2/;
  28. s/^(version:.*)/$1 (Build $build)/;
  29. # for Highlander EaCommon.h
  30. s/(.*EA_BUILD_STR.*\"Build).*(\".*)/$1 $build$2/;
  31. s/(.*EA_BUILD_STR.*\")Dev Build(\".*)/$1Build $build$2/;
  32. # for Highlander prototype
  33. s/(.*Title=\".*Build).*(\".*)/$1 $build$2/;
  34. s/(.*VersionComments=\".*Build).*(\".*)/$1 $build$2/;
  35. # for string resources of MMC snap-ins
  36. s/(\s*IDS_.+_VERSION.*\d+\.\d+).*(\".*)/$1 (Build $build)$2/;
  37. if ( /ifdef _DEBUG/ )
  38. {
  39. $debugfound = 1;
  40. }
  41. elsif ( /endif/ )
  42. {
  43. $debugfound = 0;
  44. }
  45. if ( ( s/(.*FileVersion.*\d+\.\d+\.\d+)\s+\(Build \d+\)(.*\\0.*)/$1 (Build $build)$2/ ||
  46. s/(.*FileVersion.*\d+\.\d+\.\d+)(.*\\0.*)/$1 (Build $build)$2/ ) &&
  47. ! $debugfound )
  48. {
  49. (/(.*) Debug Version(\\0.*)/) || (/(.*)(\\0.*)/);
  50. print OUTFILE "#ifdef _DEBUG\n";
  51. print OUTFILE "$1 Debug Version$2\n";
  52. print OUTFILE "#else\n";
  53. print OUTFILE;
  54. print OUTFILE "#endif\n";
  55. }
  56. else
  57. {
  58. print OUTFILE;
  59. }
  60. }
  61. close INFILE, OUTFILE;
  62. chmod 0444, "$versionfile";
  63. system ("del /f \"$versionfile.bak\"");
  64. }
  65. }
  66. }
  67. }
  68. sub SetVersionNumber {
  69. local( $version, $versionfile ) = @_;
  70. local( $verMaj, $verMin, $verRel, $verMinPad, $verRelPad );
  71. if ( -f "$versionfile.bak" ) {
  72. system ("del /f \"$versionfile.bak\"");
  73. }
  74. if ( ! rename ("$versionfile", "$versionfile.bak") ) {
  75. print "Error renaming $versionfile to $versionfile.bak: $!.\n";
  76. }
  77. else {
  78. if ( ! open (INFILE, "<$versionfile.bak") ) {
  79. print "Error opening file $versionfile.bak: $!.\n";
  80. }
  81. else {
  82. if ( ! open (OUTFILE, ">$versionfile") ) {
  83. print "Error opening file $versionfile: $!.\n";
  84. }
  85. else {
  86. ($verMaj, $verMin, $verRel) = split( ",", $version );
  87. $verMinPad = "$verMin";
  88. $verRelPad = "$verRel";
  89. if ($verMin < 10) { $verMinPad = "0$verMin"; }
  90. if ($verRel < 10) { $verRelPad = "0$verRel"; }
  91. while (<INFILE>) {
  92. s/(.*\sEA_VER_MAJ\s\D*)\d+(\D*)/$1$verMaj$2/;
  93. s/(.*\sEA_VER_MIN\s\D*)\d+(\D*)/$1$verMin$2/;
  94. s/(.*\sEA_VER_REL\s\D*)\d+(\D*)/$1$verRel$2/;
  95. s/(.*FILEVERSION\s)\d+,\d+,\d+,\d+(.*)/$1$verMaj,$verMin,$verRel,0$2/;
  96. s/(.*PRODUCTVERSION\s)\d+,\d+,\d+,\d+(.*)/$1$verMaj,$verMin,$verRel,0$2/;
  97. s/(.*FileVersion.*)\d+\.\d+\.\d+(.*\\0.*)/$1$verMaj.$verMinPad.$verRelPad$2/;
  98. s/(.*ProductVersion.*)\d+\.\d+\.\d+(.*\\0.*)/$1$verMaj.$verMinPad.$verRelPad$2/;
  99. s/(.*Application\(\"VersionInfo\"\).*Version.*)\d+\.\d+\.\d+\s+\(Build \d+\)(.*)/$1$verMaj.$verMinPad.$verRelPad (Build 0)$2/;
  100. print OUTFILE;
  101. }
  102. close INFILE, OUTFILE;
  103. system ("del /f \"$versionfile.bak\"");
  104. }
  105. }
  106. }
  107. }
  108. sub SetVersionResource {
  109. local( $version, $productname, $company, $copyright, $versionfile ) = @_;
  110. local( $verMaj, $verMin, $verRel, $build, $verMinPad, $verRelPad, $buildPad );
  111. if ( -f "$versionfile.bak" ) {
  112. system ("del /f \"$versionfile.bak\"");
  113. }
  114. if ( ! rename ("$versionfile", "$versionfile.bak") ) {
  115. print "Error renaming $versionfile to $versionfile.bak: $!.\n";
  116. }
  117. else {
  118. if ( ! open (INFILE, "<$versionfile.bak") ) {
  119. print "Error opening file $versionfile.bak: $!.\n";
  120. }
  121. else {
  122. if ( ! open (OUTFILE, ">$versionfile") ) {
  123. print "Error opening file $versionfile: $!.\n";
  124. }
  125. else {
  126. ($verMaj, $verMin, $verRel, $build) = split( ",", $version );
  127. ($verMaj) || ($verMaj = "0");
  128. ($verMin) || ($verMin = "0");
  129. ($verRel) || ($verRel = "0");
  130. ($build) || ($build = "0");
  131. $verMinPad = "$verMin";
  132. $verRelPad = "$verRel";
  133. $buildPad = "$build";
  134. if ($verMin < 10) { $verMinPad = "0$verMin"; }
  135. if ($verRel < 10) { $verRelPad = "0$verRel"; }
  136. if ($build < 10) { $buildPad = "0$build"; }
  137. while (<INFILE>) {
  138. # for EaVer.hpp
  139. s/(.*\sEA_VER_MAJ\s\D*)\d+(\D*)/$1$verMaj$2/;
  140. s/(.*\sEA_VER_MIN\s\D*)\d+(\D*)/$1$verMin$2/;
  141. s/(.*\sEA_VER_REL\s\D*)\d+(\D*)/$1$verRel$2/;
  142. s/(.*\sEA_VER_MOD\s\D*)\d+(\D*)/$1$build$2/;
  143. # for .RC files
  144. s/(.*FILEVERSION\s)\d+,\d+,\d+,\d+(.*)/$1$verMaj,$verMin,$verRel,$build$2/;
  145. s/(.*PRODUCTVERSION\s)\d+,\d+,\d+,\d+(.*)/$1$verMaj,$verMin,$verRel,0$2/;
  146. s/(.*FileVersion\", \").*(\\0.*)/$1$verMaj.$verMin.$verRel.$build$2/;
  147. s/(.*ProductVersion\", \").*(\\0.*)/$1$verMaj.$verMinPad.$verRelPad$2/;
  148. ( $company ) && ( s/(.*CompanyName\", \").*(\\0.*)/$1$company$2/ );
  149. ( $copyright ) && ( s/(.*LegalCopyright\", \").*(\\0.*)/$1$copyright$2/ );
  150. ( $productname ) && ( s/(.*ProductName\", \").*(\\0.*)/$1$productname$2/ );
  151. # for ASP pages
  152. s/(.*Application\(\"VersionInfo\"\).*Version.*)\d+\.\d+\.\d+\s+\(Build \d+\)(.*)/$1$verMaj.$verMinPad.$verRelPad (Build $build)$2/;
  153. s/^(version:).*/$1$verMaj.$verMinPad.$verRelPad (Build $build)/;
  154. # for Highlander EaCommon.h
  155. s/(.*\sEA_VER_MAJOR\s\D*)\d+(\D*)/$1$verMaj$2/;
  156. s/(.*\sEA_VER_MINOR\s\D*)\d+(\D*)/$1$verMin$2/;
  157. s/(.*\sEA_VER_RELEASE\s\D*)\d+(\D*)/$1$verRel$2/;
  158. s/(.*EA_VERSION_STR.*\"v).*(\".*)/$1$verMaj.$verMinPad.$verRelPad$2/;
  159. s/(.*EA_BUILD_STR.*\"Build).*(\".*)/$1 $build$2/;
  160. s/(.*EA_BUILD_STR.*\")Dev Build(\".*)/$1Build $build$2/;
  161. # for Highlander prototype
  162. s/(.*Title=\".*Build).*(\".*)/$1 $build$2/;
  163. s/(.*VersionComments=\".*Build).*(\".*)/$1 $build$2/;
  164. # for string resources of MMC snap-ins
  165. s/(\s*IDS_.+_VERSION.*\").*(\".*)/$1$verMaj.$verMinPad.$verRelPad (Build $build)$2/;
  166. print OUTFILE;
  167. }
  168. close INFILE, OUTFILE;
  169. chmod 0444, "$versionfile";
  170. system ("del /f \"$versionfile.bak\"");
  171. }
  172. }
  173. }
  174. }
  175. 1;