/[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 399 - (show annotations)
Tue Dec 9 03:37:47 2008 UTC (13 years, 6 months ago) by siliconforks
File MIME type: text/plain
File size: 13960 byte(s)
Use SpiderMonkey from Firefox 3.1b2.

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, $y - 1900) -
58 POSIX::mktime(00, 00, 00, 01, 01, 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 # BITS - 16 or 32 bit
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,$bits,$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 "SRCDIR=s" => \$srcdir,
116 "TOPSRCDIR=s" => \$topsrcdir,
117 "DEPTH=s" => \$depth,
118 "RCINCLUDE=s" => \$rcinclude,
119 "OBJDIR=s" => \$objdir,
120 "BITS=s" => \$bits);
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($depth)) {$depth=".";}
128 if (!defined($rcinclude)) {$rcinclude="";}
129 if (!defined($objdir)) {$objdir=".";}
130 if (!defined($srcdir)) {$srcdir=".";}
131 if (!defined($topsrcdir)) {$topsrcdir=".";}
132 if (!defined($bits)) {$bits="";}
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 $fileos = "VOS__WINDOWS32";
145 if ($bits eq "16") { $fileos="VOS__WINDOWS16"; }
146
147 my $bufferstr=" ";
148
149 my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
150 my $BUILDID_FILE = "$depth/config/buildid";
151
152 #Read module.ver file
153 #Version file overrides for WIN32:
154 #WIN32_MODULE_COMMENT
155 #WIN32_MODULE_DESCRIPTION
156 #WIN32_MODULE_FILEVERSION
157 #WIN32_MODULE_COMPANYNAME
158 #WIN32_MODULE_FILEVERSION_STRING
159 #WIN32_MODULE_NAME
160 #WIN32_MODULE_COPYRIGHT
161 #WIN32_MODULE_TRADEMARKS
162 #WIN32_MODULE_ORIGINAL_FILENAME
163 #WIN32_MODULE_PRODUCTNAME
164 #WIN32_MODULE_PRODUCTVERSION
165 #WIN32_MODULE_PRODUCTVERSION_STRING
166
167 #Override values obtained from the .ver file
168 my $override_comment;
169 my $override_description;
170 my $override_fileversion;
171 my $override_company;
172 my $override_mfversion;
173 my $override_module;
174 my $override_copyright;
175 my $override_trademarks;
176 my $override_filename;
177 my $override_productname;
178 my $override_productversion;
179 my $override_mpversion;
180 if (open(VERFILE, "<$srcdir/module.ver"))
181 {
182
183 my ($a,$b) = getNextEntry();
184 while (defined($a))
185 {
186 if ($a eq "WIN32_MODULE_COMMENT") { $override_comment = $b; }
187 if ($a eq "WIN32_MODULE_DESCRIPTION") { $override_description = $b; }
188 if ($a eq "WIN32_MODULE_FILEVERSION") { $override_fileversion = $b; }
189 if ($a eq "WIN32_MODULE_COMPANYNAME") { $override_company = $b; }
190 if ($a eq "WIN32_MODULE_FILEVERSION_STRING") { $override_mfversion = $b; }
191 if ($a eq "WIN32_MODULE_NAME") { $override_module = $b; }
192 if ($a eq "WIN32_MODULE_COPYRIGHT") { $override_copyright = $b; }
193 if ($a eq "WIN32_MODULE_TRADEMARKS") { $override_trademarks = $b; }
194 if ($a eq "WIN32_MODULE_ORIGINAL_FILENAME") { $override_filename = $b; }
195 if ($a eq "WIN32_MODULE_PRODUCTNAME") { $override_productname = $b; }
196 if ($a eq "WIN32_MODULE_PRODUCTVERSION") { $override_productversion = $b; }
197 if ($a eq "WIN32_MODULE_PRODUCTVERSION_STRING") { $override_mpversion = $b; }
198 ($a,$b) = getNextEntry();
199 }
200 close(VERFILE)
201 }
202 else
203 {
204 if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; }
205 }
206 #Get rid of trailing and leading whitespace
207 $debug =~ s/^\s*(.*)\s*$/$1/;
208 $comment =~ s/^\s*(.*)\s*$/$1/;
209 $official =~ s/^\s*(.*)\s*$/$1/;
210 $milestone =~ s/^\s*(.*)\s*$/$1/;
211 $description =~ s/^\s*(.*)\s*$/$1/;
212 $module =~ s/^\s*(.*)\s*$/$1/;
213 $depth =~ s/^\s*(.*)\s*$/$1/;
214 $binary =~ s/^\s*(.*)\s*$/$1/;
215 $displayname =~ s/^\s*(.*)\s*$/$1/;
216
217 open(BUILDID, "<", $BUILDID_FILE) || die("Couldn't open buildid file: $BUILDID_FILE");
218 $buildid = <BUILDID>;
219 $buildid =~ s/\s*$//;
220 close BUILDID;
221
222 my $daycount = daysFromBuildID($buildid);
223
224 if ($milestone eq "") {
225 $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
226 }
227
228 $mfversion = $mpversion = $milestone;
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 $copyright = "License: MPL 1.1/GPL 2.0/LGPL 2.1";
256 my $company = "Mozilla Foundation";
257 my $trademarks = "Mozilla";
258 my $productname = $displayname;
259
260
261 if (defined($override_comment)){$override_comment =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $comment=$override_comment;}
262 if (defined($override_description)){$override_description =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $description=$override_description;}
263 if (defined($override_fileversion)){$fileversion=$override_fileversion;}
264 if (defined($override_mfversion)){$mfversion=$override_mfversion;}
265 if (defined($override_company)){$company=$override_company;}
266 if (defined($override_module)){$override_module =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $module=$override_module;}
267 if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_copyright;}
268 if (defined($override_trademarks)){$override_trademarks =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $trademarks=$override_trademarks;}
269 if (defined($override_filename)){$binary=$override_filename;}
270 if (defined($override_productname)){$override_productname =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $productname=$override_productname;}
271 if (defined($override_productversion)){$productversion=$override_productversion;}
272 if (defined($override_mpversion)){$mpversion=$override_mpversion;}
273
274
275 #Override section
276
277 open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n");
278 print RCFILE qq{
279 // ***** BEGIN LICENSE BLOCK *****
280 // Version: MPL 1.1/GPL 2.0/LGPL 2.1
281 //
282 // The contents of this file are subject to the Mozilla Public License Version
283 // 1.1 (the "License"); you may not use this file except in compliance with
284 // the License. You may obtain a copy of the License at
285 // http://www.mozilla.org/MPL/
286 //
287 // Software distributed under the License is distributed on an "AS IS" basis,
288 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
289 // for the specific language governing rights and limitations under the
290 // License.
291 //
292 // The Original Code is the Win32 Version System.
293 //
294 // The Initial Developer of the Original Code is Brian Bober <netdemonz\@yahoo.com>
295 // Portions created by the Initial Developer are Copyright (C) 2001
296 // the Initial Developer. All Rights Reserved.
297 //
298 // Contributor(s):
299 //
300 // Alternatively, the contents of this file may be used under the terms of
301 // either the GNU General Public License Version 2 or later (the "GPL"), or
302 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
303 // in which case the provisions of the GPL or the LGPL are applicable instead
304 // of those above. If you wish to allow use of your version of this file only
305 // under the terms of either the GPL or the LGPL, and not to allow others to
306 // use your version of this file under the terms of the MPL, indicate your
307 // decision by deleting the provisions above and replace them with the notice
308 // and other provisions required by the GPL or the LGPL. If you do not delete
309 // the provisions above, a recipient may use your version of this file under
310 // the terms of any one of the MPL, the GPL or the LGPL.
311 //
312 // ***** END LICENSE BLOCK *****
313
314 #include<winver.h>
315
316 // Note: if you contain versioning information in an included
317 // RC script, it will be discarded
318 // Use module.ver to explicitly set these values
319
320 // Do not edit this file. Changes won't affect the build.
321
322 };
323
324 my $versionlevel=0;
325 my $insideversion=0;
326 if (open(RCINCLUDE, "<$rcinclude"))
327 {
328 print RCFILE "// From included resource $rcinclude\n";
329 # my $mstring="";
330 while (<RCINCLUDE>)
331 {
332 $_ =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g;
333 print RCFILE $_;
334 # my $instr=$_;
335 # chomp($instr);
336 # $mstring .= "$instr\;";
337 }
338 close(RCINCLUDE);
339 # $mstring =~ s/\/\*.*\*\///g;
340 # my @mlines = split(/\;/,$mstring);
341 # for(@mlines)
342 # {
343 # my ($nocomment)=split(/\/\//,$_);
344 # if (defined($nocomment) && $nocomment ne "")
345 # {
346 # my ($firststring,$secondstring) = split(/\s+/,$nocomment);
347 # if (!defined($firststring)) {$firststring="";}
348 # if (!defined($secondstring)) {$secondstring="";}
349 # if ($secondstring eq "VERSIONINFO")
350 # {
351 #if (!$quiet || $quiet ne "1") {
352 # print "$bufferstr" . "WARNING: Included RC file ($rcinclude, $module, $binary)\n";
353 # print "$bufferstr" . "WARNING: contains versioning information that will be discarded\n";
354 # print "$bufferstr" . "WARNING: Remove it and use relevant overrides (in module.ver)\n";
355 #}
356 # $versionlevel = 0;
357 # $insideversion = 1;
358 # }
359 # if ($firststring eq "BEGIN") { $versionlevel++; }
360 # if ($secondstring eq "END")
361 # {
362 # $versionlevel--;
363 # if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;}
364 # }
365 # my $includecheck = $firststring . $secondstring;
366 # $includecheck =~ s/<|>/"/g;
367 # $includecheck = lc($includecheck);
368 # if ($includecheck ne "#include\"winver.h\"")
369 # {
370 # if ($insideversion == 0 && $versionlevel == 0)
371 # {
372 # print RCFILE "$nocomment\n";
373 # }
374 # }
375 # }
376 # }
377
378 }
379
380 my $fileflags = join(' | ', @fileflags);
381
382 print RCFILE qq{
383
384
385 /////////////////////////////////////////////////////////////////////////////
386 //
387 // Version
388 //
389
390 1 VERSIONINFO
391 FILEVERSION $fileversion
392 PRODUCTVERSION $productversion
393 FILEFLAGSMASK 0x3fL
394 FILEFLAGS $fileflags
395 FILEOS $fileos
396 FILETYPE VFT_DLL
397 FILESUBTYPE 0x0L
398 BEGIN
399 BLOCK "StringFileInfo"
400 BEGIN
401 BLOCK "000004b0"
402 BEGIN
403 VALUE "Comments", "$comment"
404 VALUE "LegalCopyright", "$copyright"
405 VALUE "CompanyName", "$company"
406 VALUE "FileDescription", "$description"
407 VALUE "FileVersion", "$mfversion"
408 VALUE "ProductVersion", "$mpversion"
409 VALUE "InternalName", "$module"
410 VALUE "LegalTrademarks", "$trademarks"
411 VALUE "OriginalFilename", "$binary"
412 VALUE "ProductName", "$productname"
413 VALUE "BuildID", "$buildid"
414 END
415 END
416 BLOCK "VarFileInfo"
417 BEGIN
418 VALUE "Translation", 0x0, 1200
419 END
420 END
421
422 };
423 close(RCFILE);

  ViewVC Help
Powered by ViewVC 1.1.24