PageRenderTime 36ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/config/Moz/Milestone.pm

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Perl | 232 lines | 186 code | 7 blank | 39 comment | 3 complexity | 0d7a1ca75d3ce58ea7762bcd18d52032 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. #!/usr/bin/perl -w
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. #
  5. # The contents of this file are subject to the Mozilla Public License Version
  6. # 1.1 (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. # http://www.mozilla.org/MPL/
  9. #
  10. # Software distributed under the License is distributed on an "AS IS" basis,
  11. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. # for the specific language governing rights and limitations under the
  13. # License.
  14. #
  15. # The Original Code is the Win32 Version System.
  16. #
  17. # The Initial Developer of the Original Code is Netscape Communications Corporation
  18. # Portions created by the Initial Developer are Copyright (C) 2002
  19. # the Initial Developer. All Rights Reserved.
  20. #
  21. # Contributor(s):
  22. #
  23. # Alternatively, the contents of this file may be used under the terms of
  24. # either the GNU General Public License Version 2 or later (the "GPL"), or
  25. # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26. # in which case the provisions of the GPL or the LGPL are applicable instead
  27. # of those above. If you wish to allow use of your version of this file only
  28. # under the terms of either the GPL or the LGPL, and not to allow others to
  29. # use your version of this file under the terms of the MPL, indicate your
  30. # decision by deleting the provisions above and replace them with the notice
  31. # and other provisions required by the GPL or the LGPL. If you do not delete
  32. # the provisions above, a recipient may use your version of this file under
  33. # the terms of any one of the MPL, the GPL or the LGPL.
  34. #
  35. # ***** END LICENSE BLOCK *****
  36. package Moz::Milestone;
  37. use strict;
  38. use vars qw($officialMilestone
  39. $milestone);
  40. local $Moz::Milestone::milestone;
  41. local $Moz::Milestone::officialMilestone;
  42. #
  43. # Usage: getOfficialMilestone($milestoneFile)
  44. # Returns full milestone (x.x.x.x[ab12pre+])
  45. #
  46. sub getOfficialMilestone($) {
  47. my $mfile = $_[0];
  48. open(FILE,"$mfile") ||
  49. die ("Can't open $mfile for reading!");
  50. my $num = <FILE>;
  51. while($num =~ /^\s*#/ || $num !~ /^\d/) {
  52. $num = <FILE>;
  53. }
  54. close(FILE);
  55. if ($num !~ /^\d/) { return; }
  56. chomp($num);
  57. # Remove extra ^M caused by using dos-mode line-endings
  58. chop $num if (substr($num, -1, 1) eq "\r");
  59. $Moz::Milestone::officialMilestone = $num;
  60. $Moz::Milestone::milestone = &getMilestoneNum;
  61. return $num;
  62. }
  63. #
  64. # Usage: getMilestoneNum($num)
  65. # Returns: milestone without a + if it exists.
  66. #
  67. sub getMilestoneNum {
  68. if (defined($Moz::Milestone::milestone)) {
  69. return $Moz::Milestone::milestone;
  70. }
  71. if (defined($Moz::Milestone::officialMilestone)) {
  72. $Moz::Milestone::milestone = $Moz::Milestone::officialMilestone;
  73. } else {
  74. $Moz::Milestone::milestone = $_[0];
  75. }
  76. if ($Moz::Milestone::milestone =~ /\+$/) { # for x.x.x+, strip off the +
  77. $Moz::Milestone::milestone =~ s/\+$//;
  78. }
  79. return $Moz::Milestone::milestone;
  80. }
  81. #
  82. # Usage: getMilestoneQualifier($num)
  83. # Returns: + if it exists.
  84. #
  85. sub getMilestoneQualifier {
  86. my $milestoneQualifier;
  87. if (defined($Moz::Milestone::officialMilestone)) {
  88. $milestoneQualifier = $Moz::Milestone::officialMilestone;
  89. } else {
  90. $milestoneQualifier = $_[0];
  91. }
  92. if ($milestoneQualifier =~ /\+$/) {
  93. return "+";
  94. }
  95. }
  96. sub getMilestoneMajor {
  97. my $milestoneMajor;
  98. if (defined($Moz::Milestone::milestone)) {
  99. $milestoneMajor = $Moz::Milestone::milestone;
  100. } else {
  101. $milestoneMajor = $_[0];
  102. }
  103. my @parts = split(/\./,$milestoneMajor);
  104. return $parts[0];
  105. }
  106. sub getMilestoneMinor {
  107. my $milestoneMinor;
  108. if (defined($Moz::Milestone::milestone)) {
  109. $milestoneMinor = $Moz::Milestone::milestone;
  110. } else {
  111. $milestoneMinor = $_[0];
  112. }
  113. my @parts = split(/\./,$milestoneMinor);
  114. if ($#parts < 1 ) { return 0; }
  115. return $parts[1];
  116. }
  117. sub getMilestoneMini {
  118. my $milestoneMini;
  119. if (defined($Moz::Milestone::milestone)) {
  120. $milestoneMini = $Moz::Milestone::milestone;
  121. } else {
  122. $milestoneMini = $_[0];
  123. }
  124. my @parts = split(/\./,$milestoneMini);
  125. if ($#parts < 2 ) { return 0; }
  126. return $parts[2];
  127. }
  128. sub getMilestoneMicro {
  129. my $milestoneMicro;
  130. if (defined($Moz::Milestone::milestone)) {
  131. $milestoneMicro = $Moz::Milestone::milestone;
  132. } else {
  133. $milestoneMicro = $_[0];
  134. }
  135. my @parts = split(/\./,$milestoneMicro);
  136. if ($#parts < 3 ) { return 0; }
  137. return $parts[3];
  138. }
  139. sub getMilestoneAB {
  140. my $milestoneAB;
  141. if (defined($Moz::Milestone::milestone)) {
  142. $milestoneAB = $Moz::Milestone::milestone;
  143. } else {
  144. $milestoneAB = $_[0];
  145. }
  146. if ($milestoneAB =~ /a/) { return "alpha"; }
  147. if ($milestoneAB =~ /b/) { return "beta"; }
  148. return "final";
  149. }
  150. #
  151. # build_file($template_file,$output_file)
  152. #
  153. sub build_file($$) {
  154. my @FILE;
  155. my @MILESTONE_PARTS;
  156. my $MINI_VERSION = 0;
  157. my $MICRO_VERSION = 0;
  158. my $OFFICIAL = 0;
  159. my $QUALIFIER = "";
  160. if (!defined($Moz::Milestone::milestone)) { die("$0: no milestone file set!\n"); }
  161. @MILESTONE_PARTS = split(/\./, &getMilestoneNum);
  162. if ($#MILESTONE_PARTS >= 2) {
  163. $MINI_VERSION = 1;
  164. } else {
  165. $MILESTONE_PARTS[2] = 0;
  166. }
  167. if ($#MILESTONE_PARTS >= 3) {
  168. $MICRO_VERSION = 1;
  169. } else {
  170. $MILESTONE_PARTS[3] = 0;
  171. }
  172. if (! &getMilestoneQualifier) {
  173. $OFFICIAL = 1;
  174. } else {
  175. $QUALIFIER = "+";
  176. }
  177. if (-e $_[0]) {
  178. open(FILE, "$_[0]") || die("$0: Can't open $_[0] for reading!\n");
  179. @FILE = <FILE>;
  180. close(FILE);
  181. open(FILE, ">$_[1]") || die("$0: Can't open $_[1] for writing!\n");
  182. #
  183. # There will be more of these based on what we need for files.
  184. #
  185. foreach(@FILE) {
  186. s/__MOZ_MAJOR_VERSION__/$MILESTONE_PARTS[0]/g;
  187. s/__MOZ_MINOR_VERSION__/$MILESTONE_PARTS[1]/g;
  188. s/__MOZ_MINI_VERSION__/$MILESTONE_PARTS[2]/g;
  189. s/__MOZ_MICRO_VERSION__/$MILESTONE_PARTS[3]/g;
  190. if ($MINI_VERSION) {
  191. s/__MOZ_OPTIONAL_MINI_VERSION__/.$MILESTONE_PARTS[2]/g;
  192. }
  193. if ($MICRO_VERSION) {
  194. s/__MOZ_OPTIONAL_MICRO_VERSION__/.$MILESTONE_PARTS[3]/g;
  195. }
  196. print FILE $_;
  197. }
  198. close(FILE);
  199. } else {
  200. die("$0: $_[0] doesn't exist for autoversioning!\n");
  201. }
  202. }
  203. 1;