fixing bug causing font-weight: 900 to not be bold. bug 359542. r=vlad
[mozilla-central.git] / config / version_win.pl
blob3c0f00c70a32a03609c70532425ec531b37d1813
1 #!/usr/bin/perl -w
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
16 # The Original Code is the Win32 Version System.
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.
22 # Contributor(s):
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.
36 # ***** END LICENSE BLOCK *****
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;
47 #Creates version resource file
49 #Paramaters are passed on the command line:
51 #Example: -PBI=blah -DEBUG=1
53 # PBI - your private build information (if not a milestone or nightly)
54 # DEBUG - Mozilla's global debug variable - tells if its debug version
55 # OFFICIAL - tells Mozilla is building a milestone or nightly
56 # MSTONE - tells which milestone is being built;
57 # OBJDIR - Holds the object directory;
58 # MODNAME - tells what the name of the module is like nsBMPModule
59 # DEPTH - Holds the path to the root obj dir
60 # TOPSRCDIR - Holds the path to the root mozilla dir
61 # SRCDIR - Holds module.ver and source
62 # BINARY - Holds the name of the binary file
63 # DISPNAME - Holds the display name of the built application
64 # BITS - 16 or 32 bit
65 # RCINCLUDE - Holds the name of the RC File to include or ""
66 # QUIET - Turns off output
68 #Description and Comment come from module.ver
69 #Bug 23560
70 #http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/rc_7x2d.asp
72 #Get next .ver file entry
73 sub getNextEntry
75 while (<VERFILE>)
77 my $mline = $_;
78 ($mline) = split(/#/,$mline);
79 my ($entry, $value)=split(/=/,$mline,2);
80 if (defined($entry))
82 if (defined($value))
84 $entry =~ s/^\s*(.*?)\s*$/$1/;
85 $value =~ s/^\s*(.*?)\s*$/$1/;
86 return ($entry,$value);
90 return undef;
93 my ($quiet,$privateinfo,$objdir,$debug,$official,$milestone,$module,$binary,$depth,$rcinclude,$bits,$srcdir);
95 GetOptions( "QUIET" => \$quiet,
96 "PBI=s" => \$privateinfo,
97 "DEBUG=s" => \$debug,
98 "OFFICIAL=s" => \$official,
99 "MSTONE=s" => \$milestone,
100 "MODNAME=s" => \$module,
101 "BINARY=s" => \$binary,
102 "DISPNAME=s" => \$displayname,
103 "SRCDIR=s" => \$srcdir,
104 "TOPSRCDIR=s" => \$topsrcdir,
105 "DEPTH=s" => \$depth,
106 "RCINCLUDE=s" => \$rcinclude,
107 "OBJDIR=s" => \$objdir,
108 "BITS=s" => \$bits);
109 if (!defined($privateinfo)) {$privateinfo="";}
110 if (!defined($debug)) {$debug="";}
111 if (!defined($official)) {$official="";}
112 if (!defined($milestone)) {$milestone="";}
113 if (!defined($module)) {$module="";}
114 if (!defined($binary)) {$binary="";}
115 if (!defined($displayname)) {$displayname="Mozilla";}
116 if (!defined($depth)) {$depth=".";}
117 if (!defined($rcinclude)) {$rcinclude="";}
118 if (!defined($objdir)) {$objdir=".";}
119 if (!defined($srcdir)) {$srcdir=".";}
120 if (!defined($topsrcdir)) {$topsrcdir=".";}
121 if (!defined($bits)) {$bits="";}
122 my $mfversion = "Personal";
123 my $mpversion = "Personal";
124 my $fileflags = "VS_FF_PRIVATEBUILD";
125 my $comment="";
126 my $description="";
127 if (!defined($module))
129 $module = $binary;
130 ($module) = split(/\./,$module);
133 my $productversion = "0,0,0,0";
134 my $fileversion = $productversion;
135 my $fileos = "VOS__WINDOWS32";
136 if ($bits eq "16") { $fileos="VOS__WINDOWS16"; }
138 my $bufferstr=" ";
140 my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
141 my $BUILDID_FILE = "$depth/config/build_number";
143 #Read module.ver file
144 #Version file overrides for WIN32:
145 #WIN32_MODULE_COMMENT
146 #WIN32_MODULE_DESCRIPTION
147 #WIN32_MODULE_FILEVERSION
148 #WIN32_MODULE_COMPANYNAME
149 #WIN32_MODULE_FILEVERSION_STRING
150 #WIN32_MODULE_NAME
151 #WIN32_MODULE_COPYRIGHT
152 #WIN32_MODULE_TRADEMARKS
153 #WIN32_MODULE_ORIGINAL_FILENAME
154 #WIN32_MODULE_PRODUCTNAME
155 #WIN32_MODULE_PRODUCTVERSION
156 #WIN32_MODULE_PRODUCTVERSION_STRING
158 #Override values obtained from the .ver file
159 my $override_comment;
160 my $override_description;
161 my $override_fileversion;
162 my $override_company;
163 my $override_mfversion;
164 my $override_module;
165 my $override_copyright;
166 my $override_trademarks;
167 my $override_filename;
168 my $override_productname;
169 my $override_productversion;
170 my $override_mpversion;
171 if (open(VERFILE, "<$srcdir/module.ver"))
174 my ($a,$b) = getNextEntry();
175 while (defined($a))
177 if ($a eq "WIN32_MODULE_COMMENT") { $override_comment = $b; }
178 if ($a eq "WIN32_MODULE_DESCRIPTION") { $override_description = $b; }
179 if ($a eq "WIN32_MODULE_FILEVERSION") { $override_fileversion = $b; }
180 if ($a eq "WIN32_MODULE_COMPANYNAME") { $override_company = $b; }
181 if ($a eq "WIN32_MODULE_FILEVERSION_STRING") { $override_mfversion = $b; }
182 if ($a eq "WIN32_MODULE_NAME") { $override_module = $b; }
183 if ($a eq "WIN32_MODULE_COPYRIGHT") { $override_copyright = $b; }
184 if ($a eq "WIN32_MODULE_TRADEMARKS") { $override_trademarks = $b; }
185 if ($a eq "WIN32_MODULE_ORIGINAL_FILENAME") { $override_filename = $b; }
186 if ($a eq "WIN32_MODULE_PRODUCTNAME") { $override_productname = $b; }
187 if ($a eq "WIN32_MODULE_PRODUCTVERSION") { $override_productversion = $b; }
188 if ($a eq "WIN32_MODULE_PRODUCTVERSION_STRING") { $override_mpversion = $b; }
189 ($a,$b) = getNextEntry();
191 close(VERFILE)
193 else
195 if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; }
197 #Get rid of trailing and leading whitespace
198 $debug =~ s/^\s*(.*)\s*$/$1/;
199 $comment =~ s/^\s*(.*)\s*$/$1/;
200 $official =~ s/^\s*(.*)\s*$/$1/;
201 $milestone =~ s/^\s*(.*)\s*$/$1/;
202 $description =~ s/^\s*(.*)\s*$/$1/;
203 $module =~ s/^\s*(.*)\s*$/$1/;
204 $depth =~ s/^\s*(.*)\s*$/$1/;
205 $privateinfo =~ s/^\s*(.*)\s*$/$1/;
206 $binary =~ s/^\s*(.*)\s*$/$1/;
207 $displayname =~ s/^\s*(.*)\s*$/$1/;
209 if ($debug eq "1")
211 $fileflags .= " | VS_FF_DEBUG";
212 $mpversion .= " Debug";
213 $mfversion .= " Debug";
216 if ($official eq "1") {
217 #its an official build
218 $privateinfo = "";
219 $fileflags = "VS_FF_PRERELEASE";
220 if ($debug eq "1") {
221 $fileflags = "VS_FF_PRERELEASE | VS_FF_DEBUG";
224 # Try to grab milestone.
225 # I'd love to put this in the makefiles rather than here,
226 # since I could run it once per build rather than once per
227 # dll/program, but I can't seem to get backticks working
228 # properly in the makefiles =P
229 if ($milestone eq "") {
230 $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
233 if ($milestone ne "" && $milestone !~ /\+$/) {
234 #its a milestone build
236 $mpversion = $milestone;
238 $fileflags = "0";
240 my @mstone = split(/\./,$milestone);
241 $mstone[1] =~s/\D*$//g;
242 $productversion="$mstone[0],$mstone[1],0,0";
246 my ($buildid, $buildid_hi, $buildid_lo);
247 open(NUMBER, "<$BUILDID_FILE") || die "No build number file\n";
248 while ( <NUMBER> ) { $buildid = $_ }
249 close (NUMBER);
250 $buildid =~ s/^\s*(.*)\s*$/$1/;
251 $buildid_hi = substr($buildid, 0, 5);
252 $buildid_lo = substr($buildid, 5);
254 $mfversion = $mpversion = "$milestone: $buildid";
255 my @pvarray = split(',', $productversion);
256 $fileversion = "$pvarray[0],$pvarray[1],$buildid_hi,$buildid_lo";
259 my $copyright = "License: MPL 1.1/GPL 2.0/LGPL 2.1";
260 my $company = "Mozilla Foundation";
261 my $trademarks = "Mozilla";
262 my $productname = $displayname;
265 if (defined($override_comment)){$override_comment =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $comment=$override_comment;}
266 if (defined($override_description)){$override_description =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $description=$override_description;}
267 if (defined($override_fileversion)){$fileversion=$override_fileversion;}
268 if (defined($override_mfversion)){$mfversion=$override_mfversion;}
269 if (defined($override_company)){$company=$override_company;}
270 if (defined($override_module)){$override_module =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $module=$override_module;}
271 if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_company;}
272 if (defined($override_trademarks)){$override_trademarks =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $trademarks=$override_trademarks;}
273 if (defined($override_filename)){$binary=$override_filename;}
274 if (defined($override_productname)){$override_productname =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $productname=$override_productname;}
275 if (defined($override_productversion)){$productversion=$override_productversion;}
276 if (defined($override_mpversion)){$mpversion=$override_mpversion;}
279 #Override section
281 open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n");
282 print RCFILE qq{
283 // ***** BEGIN LICENSE BLOCK *****
284 // Version: MPL 1.1/GPL 2.0/LGPL 2.1
286 // The contents of this file are subject to the Mozilla Public License Version
287 // 1.1 (the "License"); you may not use this file except in compliance with
288 // the License. You may obtain a copy of the License at
289 // http://www.mozilla.org/MPL/
291 // Software distributed under the License is distributed on an "AS IS" basis,
292 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
293 // for the specific language governing rights and limitations under the
294 // License.
296 // The Original Code is the Win32 Version System.
298 // The Initial Developer of the Original Code is Brian Bober <netdemonz\@yahoo.com>
299 // Portions created by the Initial Developer are Copyright (C) 2001
300 // the Initial Developer. All Rights Reserved.
302 // Contributor(s):
304 // Alternatively, the contents of this file may be used under the terms of
305 // either the GNU General Public License Version 2 or later (the "GPL"), or
306 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
307 // in which case the provisions of the GPL or the LGPL are applicable instead
308 // of those above. If you wish to allow use of your version of this file only
309 // under the terms of either the GPL or the LGPL, and not to allow others to
310 // use your version of this file under the terms of the MPL, indicate your
311 // decision by deleting the provisions above and replace them with the notice
312 // and other provisions required by the GPL or the LGPL. If you do not delete
313 // the provisions above, a recipient may use your version of this file under
314 // the terms of any one of the MPL, the GPL or the LGPL.
316 // ***** END LICENSE BLOCK *****
318 #include<winver.h>
320 // Note: if you contain versioning information in an included
321 // RC script, it will be discarded
322 // Use module.ver to explicitly set these values
324 // Do not edit this file. Changes won't affect the build.
328 my $versionlevel=0;
329 my $insideversion=0;
330 if (open(RCINCLUDE, "<$rcinclude"))
332 print RCFILE "// From included resource $rcinclude\n";
333 # my $mstring="";
334 while (<RCINCLUDE>)
336 $_ =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g;
337 print RCFILE $_;
338 # my $instr=$_;
339 # chomp($instr);
340 # $mstring .= "$instr\;";
342 close(RCINCLUDE);
343 # $mstring =~ s/\/\*.*\*\///g;
344 # my @mlines = split(/\;/,$mstring);
345 # for(@mlines)
347 # my ($nocomment)=split(/\/\//,$_);
348 # if (defined($nocomment) && $nocomment ne "")
350 # my ($firststring,$secondstring) = split(/\s+/,$nocomment);
351 # if (!defined($firststring)) {$firststring="";}
352 # if (!defined($secondstring)) {$secondstring="";}
353 # if ($secondstring eq "VERSIONINFO")
355 #if (!$quiet || $quiet ne "1") {
356 # print "$bufferstr" . "WARNING: Included RC file ($rcinclude, $module, $binary)\n";
357 # print "$bufferstr" . "WARNING: contains versioning information that will be discarded\n";
358 # print "$bufferstr" . "WARNING: Remove it and use relevant overrides (in module.ver)\n";
360 # $versionlevel = 0;
361 # $insideversion = 1;
363 # if ($firststring eq "BEGIN") { $versionlevel++; }
364 # if ($secondstring eq "END")
365 # {
366 # $versionlevel--;
367 # if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;}
369 # my $includecheck = $firststring . $secondstring;
370 # $includecheck =~ s/<|>/"/g;
371 # $includecheck = lc($includecheck);
372 # if ($includecheck ne "#include\"winver.h\"")
374 # if ($insideversion == 0 && $versionlevel == 0)
376 # print RCFILE "$nocomment\n";
384 print RCFILE qq{
387 /////////////////////////////////////////////////////////////////////////////
389 // Version
392 1 VERSIONINFO
393 FILEVERSION $fileversion
394 PRODUCTVERSION $productversion
395 FILEFLAGSMASK 0x3fL
396 FILEFLAGS $fileflags
397 FILEOS $fileos
398 FILETYPE VFT_DLL
399 FILESUBTYPE 0x0L
400 BEGIN
401 BLOCK "StringFileInfo"
402 BEGIN
403 BLOCK "000004b0"
404 BEGIN
405 VALUE "Comments", "$comment"
406 VALUE "LegalCopyright", "$copyright"
407 VALUE "CompanyName", "$company"
408 VALUE "FileDescription", "$description"
409 VALUE "FileVersion", "$mfversion"
410 VALUE "ProductVersion", "$mpversion"
411 VALUE "InternalName", "$module"
412 VALUE "LegalTrademarks", "$trademarks"
413 VALUE "OriginalFilename", "$binary"
415 if ($official ne "1") {
416 print RCFILE qq{
417 VALUE "PrivateBuild", "$privateinfo"
420 print RCFILE qq{
421 VALUE "ProductName", "$productname"
424 BLOCK "VarFileInfo"
425 BEGIN
426 VALUE "Translation", 0x0, 1200
431 close(RCFILE);