/[jscoverage]/trunk/js/config/version_win.pl
ViewVC logotype

Contents of /trunk/js/config/version_win.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 507 - (show annotations)
Sun Jan 10 07:23:34 2010 UTC (9 years, 11 months ago) by siliconforks
File MIME type: text/plain
File size: 14517 byte(s)
Update SpiderMonkey from Firefox 3.6rc1.

1 #!/usr/bin/perl -w
2
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 #
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
10 #
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
15 #
16 # The Original Code is the Win32 Version System.
17 #
18 # The Initial Developer of the Original Code is Brian Bober <netdemonz@yahoo.com>
19 # Portions created by the Initial Developer are Copyright (C) 2001
20 # the Initial Developer. All Rights Reserved.
21 #
22 # Contributor(s):
23 #
24 # Alternatively, the contents of this file may be used under the terms of
25 # either the GNU General Public License Version 2 or later (the "GPL"), or
26 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 # in which case the provisions of the GPL or the LGPL are applicable instead
28 # of those above. If you wish to allow use of your version of this file only
29 # under the terms of either the GPL or the LGPL, and not to allow others to
30 # use your version of this file under the terms of the MPL, indicate your
31 # decision by deleting the provisions above and replace them with the notice
32 # and other provisions required by the GPL or the LGPL. If you do not delete
33 # the provisions above, a recipient may use your version of this file under
34 # the terms of any one of the MPL, the GPL or the LGPL.
35 #
36 # ***** END LICENSE BLOCK *****
37
38 #use diagnostics;
39 require strict;
40 my $dir = $0;
41 $dir =~ s/[^\/]*$//;
42 push(@INC, "$dir");
43 require "Moz/Milestone.pm";
44 use Getopt::Long;
45 use Getopt::Std;
46 use POSIX;
47
48 # Calculate the number of days since Jan. 1, 2000 from a buildid string
49 sub daysFromBuildID
50 {
51 my ($buildid,) = @_;
52
53 my ($y, $m, $d, $h) = ($buildid =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/);
54 $d || die("Unrecognized buildid string.");
55
56 my $secondstodays = 60 * 60 * 24;
57 return (POSIX::mktime(00, 00, 00, $d, $m - 1, $y - 1900) -
58 POSIX::mktime(00, 00, 00, 01, 00, 100)) / $secondstodays;
59 }
60
61 #Creates version resource file
62
63 #Paramaters are passed on the command line:
64
65 #Example: -MODNAME nsToolkitCompsModule -DEBUG=1
66
67 # DEBUG - Mozilla's global debug variable - tells if its debug version
68 # OFFICIAL - tells Mozilla is building a milestone or nightly
69 # MSTONE - tells which milestone is being built;
70 # OBJDIR - Holds the object directory;
71 # MODNAME - tells what the name of the module is like nsBMPModule
72 # DEPTH - Holds the path to the root obj dir
73 # TOPSRCDIR - Holds the path to the root mozilla dir
74 # SRCDIR - Holds module.ver and source
75 # BINARY - Holds the name of the binary file
76 # DISPNAME - Holds the display name of the built application
77 # APPVERSION - Holds the version string of the built application
78 # RCINCLUDE - Holds the name of the RC File to include or ""
79 # QUIET - Turns off output
80
81 #Description and Comment come from module.ver
82 #Bug 23560
83 #http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/rc_7x2d.asp
84
85 #Get next .ver file entry
86 sub getNextEntry
87 {
88 while (<VERFILE>)
89 {
90 my $mline = $_;
91 ($mline) = split(/#/,$mline);
92 my ($entry, $value)=split(/=/,$mline,2);
93 if (defined($entry))
94 {
95 if (defined($value))
96 {
97 $entry =~ s/^\s*(.*?)\s*$/$1/;
98 $value =~ s/^\s*(.*?)\s*$/$1/;
99 return ($entry,$value);
100 }
101 }
102 }
103 return undef;
104 }
105
106 my ($quiet,$objdir,$debug,$official,$milestone,$buildid,$module,$binary,$depth,$rcinclude,$srcdir,$fileversion,$productversion);
107
108 GetOptions( "QUIET" => \$quiet,
109 "DEBUG=s" => \$debug,
110 "OFFICIAL=s" => \$official,
111 "MSTONE=s" => \$milestone,
112 "MODNAME=s" => \$module,
113 "BINARY=s" => \$binary,
114 "DISPNAME=s" => \$displayname,
115 "APPVERSION=s" => \$appversion,
116 "SRCDIR=s" => \$srcdir,
117 "TOPSRCDIR=s" => \$topsrcdir,
118 "DEPTH=s" => \$depth,
119 "RCINCLUDE=s" => \$rcinclude,
120 "OBJDIR=s" => \$objdir);
121 if (!defined($debug)) {$debug="";}
122 if (!defined($official)) {$official="";}
123 if (!defined($milestone)) {$milestone="";}
124 if (!defined($module)) {$module="";}
125 if (!defined($binary)) {$binary="";}
126 if (!defined($displayname)) {$displayname="Mozilla";}
127 if (!defined($appversion)) {$appversion=$milestone;}
128 if (!defined($depth)) {$depth=".";}
129 if (!defined($rcinclude)) {$rcinclude="";}
130 if (!defined($objdir)) {$objdir=".";}
131 if (!defined($srcdir)) {$srcdir=".";}
132 if (!defined($topsrcdir)) {$topsrcdir=".";}
133 my $mfversion = "Personal";
134 my $mpversion = "Personal";
135 my @fileflags = ("0");
136 my $comment="";
137 my $description="";
138 if (!defined($module))
139 {
140 $module = $binary;
141 ($module) = split(/\./,$module);
142 }
143
144 my $bufferstr=" ";
145
146 my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
147 my $BUILDID_FILE = "$depth/config/buildid";
148
149 #Read module.ver file
150 #Version file overrides for WIN32:
151 #WIN32_MODULE_COMMENT
152 #WIN32_MODULE_DESCRIPTION
153 #WIN32_MODULE_FILEVERSION
154 #WIN32_MODULE_COMPANYNAME
155 #WIN32_MODULE_FILEVERSION_STRING
156 #WIN32_MODULE_NAME
157 #WIN32_MODULE_COPYRIGHT
158 #WIN32_MODULE_TRADEMARKS
159 #WIN32_MODULE_ORIGINAL_FILENAME
160 #WIN32_MODULE_PRODUCTNAME
161 #WIN32_MODULE_PRODUCTVERSION
162 #WIN32_MODULE_PRODUCTVERSION_STRING
163
164 #Override values obtained from the .ver file
165 my $override_comment;
166 my $override_description;
167 my $override_fileversion;
168 my $override_company;
169 my $override_mfversion;
170 my $override_module;
171 my $override_copyright;
172 my $override_trademarks;
173 my $override_filename;
174 my $override_productname;
175 my $override_productversion;
176 my $override_mpversion;
177 if (open(VERFILE, "<$srcdir/module.ver"))
178 {
179
180 my ($a,$b) = getNextEntry();
181 while (defined($a))
182 {
183 if ($a eq "WIN32_MODULE_COMMENT") { $override_comment = $b; }
184 if ($a eq "WIN32_MODULE_DESCRIPTION") { $override_description = $b; }
185 if ($a eq "WIN32_MODULE_FILEVERSION") { $override_fileversion = $b; }
186 if ($a eq "WIN32_MODULE_COMPANYNAME") { $override_company = $b; }
187 if ($a eq "WIN32_MODULE_FILEVERSION_STRING") { $override_mfversion = $b; }
188 if ($a eq "WIN32_MODULE_NAME") { $override_module = $b; }
189 if ($a eq "WIN32_MODULE_COPYRIGHT") { $override_copyright = $b; }
190 if ($a eq "WIN32_MODULE_TRADEMARKS") { $override_trademarks = $b; }
191 if ($a eq "WIN32_MODULE_ORIGINAL_FILENAME") { $override_filename = $b; }
192 if ($a eq "WIN32_MODULE_PRODUCTNAME") { $override_productname = $b; }
193 if ($a eq "WIN32_MODULE_PRODUCTVERSION") { $override_productversion = $b; }
194 if ($a eq "WIN32_MODULE_PRODUCTVERSION_STRING") { $override_mpversion = $b; }
195 ($a,$b) = getNextEntry();
196 }
197 close(VERFILE)
198 }
199 else
200 {
201 if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; }
202 }
203 #Get rid of trailing and leading whitespace
204 $debug =~ s/^\s*(.*)\s*$/$1/;
205 $comment =~ s/^\s*(.*)\s*$/$1/;
206 $official =~ s/^\s*(.*)\s*$/$1/;
207 $milestone =~ s/^\s*(.*)\s*$/$1/;
208 $description =~ s/^\s*(.*)\s*$/$1/;
209 $module =~ s/^\s*(.*)\s*$/$1/;
210 $depth =~ s/^\s*(.*)\s*$/$1/;
211 $binary =~ s/^\s*(.*)\s*$/$1/;
212 $displayname =~ s/^\s*(.*)\s*$/$1/;
213
214 open(BUILDID, "<", $BUILDID_FILE) || die("Couldn't open buildid file: $BUILDID_FILE");
215 $buildid = <BUILDID>;
216 $buildid =~ s/\s*$//;
217 close BUILDID;
218
219 my $daycount = daysFromBuildID($buildid);
220
221 if ($milestone eq "") {
222 $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
223 }
224
225 $mfversion = $mpversion = $milestone;
226 if ($appversion eq "") {
227 $appversion = $milestone;
228 }
229
230 if ($debug eq "1")
231 {
232 push @fileflags, "VS_FF_DEBUG";
233 $mpversion .= " Debug";
234 $mfversion .= " Debug";
235 }
236
237 if ($official ne "1") {
238 push @fileflags, "VS_FF_PRIVATEBUILD";
239 }
240
241 if ($milestone =~ /[a-z]/) {
242 push @fileflags, "VS_FF_PRERELEASE";
243 }
244
245 my @mstone = split(/\./,$milestone);
246 $mstone[1] =~s/\D.*$//;
247 if (!$mstone[2]) {
248 $mstone[2] = "0";
249 }
250 else {
251 $mstone[2] =~s/\D.*$//;
252 }
253 $fileversion = $productversion="$mstone[0],$mstone[1],$mstone[2],$daycount";
254
255 my @appver = split(/\./,$appversion);
256 for ($j = 1; $j < 4; $j++)
257 {
258 if (!$appver[$j]) {
259 $appver[$j] = "0";
260 }
261 else {
262 $appver[$j] =~s/\D.*$//;
263 }
264 }
265 my $winappversion = "$appver[0],$appver[1],$appver[2],$appver[3]";
266
267 my $copyright = "License: MPL 1.1/GPL 2.0/LGPL 2.1";
268 my $company = "Mozilla Foundation";
269 my $trademarks = "Mozilla";
270 my $productname = $displayname;
271
272
273 if (defined($override_comment)){$override_comment =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $comment=$override_comment;}
274 if (defined($override_description)){$override_description =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $description=$override_description;}
275 if (defined($override_fileversion)){$override_fileversion =~ s/\@MOZ_APP_WINVERSION\@/$winappversion/g; $fileversion=$override_fileversion;}
276 if (defined($override_mfversion)){$override_mfversion =~ s/\@MOZ_APP_VERSION\@/$appversion/g; $mfversion=$override_mfversion;}
277 if (defined($override_company)){$company=$override_company;}
278 if (defined($override_module)){$override_module =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $module=$override_module;}
279 if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_copyright;}
280 if (defined($override_trademarks)){$override_trademarks =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $trademarks=$override_trademarks;}
281 if (defined($override_filename)){$binary=$override_filename;}
282 if (defined($override_productname)){$override_productname =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $productname=$override_productname;}
283 if (defined($override_productversion)){$override_productversion =~ s/\@MOZ_APP_WINVERSION\@/$winappversion/g; $productversion=$override_productversion;}
284 if (defined($override_mpversion)){$override_mpversion =~ s/\@MOZ_APP_VERSION\@/$appversion/g; $mpversion=$override_mpversion;}
285
286
287 #Override section
288
289 open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n");
290 print RCFILE qq{
291 // ***** BEGIN LICENSE BLOCK *****
292 // Version: MPL 1.1/GPL 2.0/LGPL 2.1
293 //
294 // The contents of this file are subject to the Mozilla Public License Version
295 // 1.1 (the "License"); you may not use this file except in compliance with
296 // the License. You may obtain a copy of the License at
297 // http://www.mozilla.org/MPL/
298 //
299 // Software distributed under the License is distributed on an "AS IS" basis,
300 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
301 // for the specific language governing rights and limitations under the
302 // License.
303 //
304 // The Original Code is the Win32 Version System.
305 //
306 // The Initial Developer of the Original Code is Brian Bober <netdemonz\@yahoo.com>
307 // Portions created by the Initial Developer are Copyright (C) 2001
308 // the Initial Developer. All Rights Reserved.
309 //
310 // Contributor(s):
311 //
312 // Alternatively, the contents of this file may be used under the terms of
313 // either the GNU General Public License Version 2 or later (the "GPL"), or
314 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
315 // in which case the provisions of the GPL or the LGPL are applicable instead
316 // of those above. If you wish to allow use of your version of this file only
317 // under the terms of either the GPL or the LGPL, and not to allow others to
318 // use your version of this file under the terms of the MPL, indicate your
319 // decision by deleting the provisions above and replace them with the notice
320 // and other provisions required by the GPL or the LGPL. If you do not delete
321 // the provisions above, a recipient may use your version of this file under
322 // the terms of any one of the MPL, the GPL or the LGPL.
323 //
324 // ***** END LICENSE BLOCK *****
325
326 #include<winver.h>
327
328 // Note: if you contain versioning information in an included
329 // RC script, it will be discarded
330 // Use module.ver to explicitly set these values
331
332 // Do not edit this file. Changes won't affect the build.
333
334 };
335
336 my $versionlevel=0;
337 my $insideversion=0;
338 if (open(RCINCLUDE, "<$rcinclude"))
339 {
340 print RCFILE "// From included resource $rcinclude\n";
341 # my $mstring="";
342 while (<RCINCLUDE>)
343 {
344 $_ =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g;
345 print RCFILE $_;
346 # my $instr=$_;
347 # chomp($instr);
348 # $mstring .= "$instr\;";
349 }
350 close(RCINCLUDE);
351 # $mstring =~ s/\/\*.*\*\///g;
352 # my @mlines = split(/\;/,$mstring);
353 # for(@mlines)
354 # {
355 # my ($nocomment)=split(/\/\//,$_);
356 # if (defined($nocomment) && $nocomment ne "")
357 # {
358 # my ($firststring,$secondstring) = split(/\s+/,$nocomment);
359 # if (!defined($firststring)) {$firststring="";}
360 # if (!defined($secondstring)) {$secondstring="";}
361 # if ($secondstring eq "VERSIONINFO")
362 # {
363 #if (!$quiet || $quiet ne "1") {
364 # print "$bufferstr" . "WARNING: Included RC file ($rcinclude, $module, $binary)\n";
365 # print "$bufferstr" . "WARNING: contains versioning information that will be discarded\n";
366 # print "$bufferstr" . "WARNING: Remove it and use relevant overrides (in module.ver)\n";
367 #}
368 # $versionlevel = 0;
369 # $insideversion = 1;
370 # }
371 # if ($firststring eq "BEGIN") { $versionlevel++; }
372 # if ($secondstring eq "END")
373 # {
374 # $versionlevel--;
375 # if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;}
376 # }
377 # my $includecheck = $firststring . $secondstring;
378 # $includecheck =~ s/<|>/"/g;
379 # $includecheck = lc($includecheck);
380 # if ($includecheck ne "#include\"winver.h\"")
381 # {
382 # if ($insideversion == 0 && $versionlevel == 0)
383 # {
384 # print RCFILE "$nocomment\n";
385 # }
386 # }
387 # }
388 # }
389
390 }
391
392 my $fileflags = join(' | ', @fileflags);
393
394 print RCFILE qq{
395
396
397 /////////////////////////////////////////////////////////////////////////////
398 //
399 // Version
400 //
401
402 1 VERSIONINFO
403 FILEVERSION $fileversion
404 PRODUCTVERSION $productversion
405 FILEFLAGSMASK 0x3fL
406 FILEFLAGS $fileflags
407 FILEOS VOS__WINDOWS32
408 FILETYPE VFT_DLL
409 FILESUBTYPE 0x0L
410 BEGIN
411 BLOCK "StringFileInfo"
412 BEGIN
413 BLOCK "000004b0"
414 BEGIN
415 VALUE "Comments", "$comment"
416 VALUE "LegalCopyright", "$copyright"
417 VALUE "CompanyName", "$company"
418 VALUE "FileDescription", "$description"
419 VALUE "FileVersion", "$mfversion"
420 VALUE "ProductVersion", "$mpversion"
421 VALUE "InternalName", "$module"
422 VALUE "LegalTrademarks", "$trademarks"
423 VALUE "OriginalFilename", "$binary"
424 VALUE "ProductName", "$productname"
425 VALUE "BuildID", "$buildid"
426 END
427 END
428 BLOCK "VarFileInfo"
429 BEGIN
430 VALUE "Translation", 0x0, 1200
431 END
432 END
433
434 };
435 close(RCFILE);

  ViewVC Help
Powered by ViewVC 1.1.24