Merge m-c to b2g-inbound.
[gecko.git] / config / milestone.pl
blobfa9837ffdd0633212f79617d4016d32a3f61e448
1 #!/usr/bin/perl -w
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 use Getopt::Long;
8 use strict;
9 use vars qw(
10 $OBJDIR
11 $SRCDIR
12 $TOPSRCDIR
13 $SCRIPTDIR
14 @TEMPLATE_FILE
15 $MILESTONE_FILE
16 $MILESTONE
17 $MILESTONE_NUM
18 @MILESTONE_PARTS
19 $MINI_VERSION
20 $MICRO_VERSION
21 $opt_debug
22 $opt_template
23 $opt_uaversion
24 $opt_help
27 $SCRIPTDIR = $0;
28 $SCRIPTDIR =~ s/[^\/]*$//;
29 push(@INC,$SCRIPTDIR);
31 require "Moz/Milestone.pm";
33 &GetOptions('topsrcdir=s' => \$TOPSRCDIR, 'srcdir=s' => \$SRCDIR, 'objdir=s' => \$OBJDIR, 'debug', 'help', 'template', 'uaversion');
35 if (defined($opt_help)) {
36 &usage();
37 exit;
40 if (defined($opt_template)) {
41 @TEMPLATE_FILE = @ARGV;
42 if ($opt_debug) {
43 print("TEMPLATE_FILE = --@TEMPLATE_FILE--\n");
47 if (!defined($SRCDIR)) { $SRCDIR = '.'; }
48 if (!defined($OBJDIR)) { $OBJDIR = '.'; }
50 $MILESTONE_FILE = "$TOPSRCDIR/config/milestone.txt";
51 @MILESTONE_PARTS = (0, 0, 0, 0);
54 # Grab milestone (top line of $MILESTONE_FILE that starts with a digit)
56 my $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
58 if (defined(@TEMPLATE_FILE)) {
59 my $TFILE;
61 foreach $TFILE (@TEMPLATE_FILE) {
62 my $BUILT_FILE = "$OBJDIR/$TFILE";
63 $TFILE = "$SRCDIR/$TFILE.tmpl";
65 if (-e $TFILE) {
67 Moz::Milestone::build_file($TFILE,$BUILT_FILE);
69 } else {
70 warn("$0: No such file $TFILE!\n");
73 } elsif(defined($opt_uaversion)) {
74 # Only expose the major milestone in the UA string, hide the patch level
75 # (bugs 572659 and 870868).
76 my $uaversion = Moz::Milestone::getMilestoneMajor($milestone) . ".0";
77 print "$uaversion\n";
78 } else {
79 print "$milestone\n";
82 sub usage() {
83 print <<END
84 `milestone.pl [--topsrcdir TOPSRCDIR] [--objdir OBJDIR] [--srcdir SRCDIR] --template [file list] --uaversion` # will build file list from .tmpl files
85 END