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
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.
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 *****
43
require "Moz/Milestone.pm";
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
64
# RCINCLUDE - Holds the name of the RC File to include or ""
65
# QUIET - Turns off output
67
#Description and Comment come from module.ver
69
#http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/rc_7x2d.asp
71
#Get next .ver file entry
77
($mline) = split(/#/,$mline);
78
my ($entry, $value)=split(/=/,$mline,2);
83
$entry =~ s/^\s*(.*?)\s*$/$1/;
84
$value =~ s/^\s*(.*?)\s*$/$1/;
85
return ($entry,$value);
92
my ($quiet,$privateinfo,$objdir,$debug,$official,$milestone,$module,$binary,$depth,$rcinclude,$bits,$srcdir);
94
GetOptions( "QUIET" => \$quiet,
95
"PBI=s" => \$privateinfo,
97
"OFFICIAL=s" => \$official,
98
"MSTONE=s" => \$milestone,
99
"MODNAME=s" => \$module,
100
"BINARY=s" => \$binary,
101
"SRCDIR=s" => \$srcdir,
102
"TOPSRCDIR=s" => \$topsrcdir,
103
"DEPTH=s" => \$depth,
104
"RCINCLUDE=s" => \$rcinclude,
105
"OBJDIR=s" => \$objdir,
107
if (!defined($privateinfo)) {$privateinfo="";}
108
if (!defined($debug)) {$debug="";}
109
if (!defined($official)) {$official="";}
110
if (!defined($milestone)) {$milestone="";}
111
if (!defined($module)) {$module="";}
112
if (!defined($binary)) {$binary="";}
113
if (!defined($depth)) {$depth=".";}
114
if (!defined($rcinclude)) {$rcinclude="";}
115
if (!defined($objdir)) {$objdir=".";}
116
if (!defined($srcdir)) {$srcdir=".";}
117
if (!defined($topsrcdir)) {$topsrcdir=".";}
118
if (!defined($bits)) {$bits="";}
119
my $mfversion = "Personal";
120
my $mpversion = "Personal";
121
my $fileflags = "VS_FF_PRIVATEBUILD";
124
if (!defined($module))
127
($module) = split(/\./,$module);
130
my $productversion = "0,0,0,0";
131
my $fileversion = $productversion;
132
my $fileos = "VOS__WINDOWS32";
133
if ($bits eq "16") { $fileos="VOS__WINDOWS16"; }
137
my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
138
my $BUILDID_FILE = "$depth/config/build_number";
140
#Read module.ver file
141
#Version file overrides for WIN32:
142
#WIN32_MODULE_COMMENT
143
#WIN32_MODULE_DESCRIPTION
144
#WIN32_MODULE_FILEVERSION
145
#WIN32_MODULE_COMPANYNAME
146
#WIN32_MODULE_FILEVERSION_STRING
148
#WIN32_MODULE_COPYRIGHT
149
#WIN32_MODULE_TRADEMARKS
150
#WIN32_MODULE_ORIGINAL_FILENAME
151
#WIN32_MODULE_PRODUCTNAME
153
#Override values obtained from the .ver file
154
my $override_comment;
155
my $override_description;
156
my $override_fileversion;
157
my $override_company;
158
my $override_mfversion;
160
my $override_copyright;
161
my $override_trademarks;
162
my $override_filename;
163
my $override_productname;
164
if (open(VERFILE, "<$srcdir/module.ver"))
167
my ($a,$b) = getNextEntry();
170
if ($a eq "WIN32_MODULE_COMMENT") { $override_comment = $b; }
171
if ($a eq "WIN32_MODULE_DESCRIPTION") { $override_description = $b; }
172
if ($a eq "WIN32_MODULE_FILEVERSION") { $override_fileversion = $b; }
173
if ($a eq "WIN32_MODULE_COMPANYNAME") { $override_company = $b; }
174
if ($a eq "WIN32_MODULE_FILEVERSION_STRING") { $override_mfversion = $b; }
175
if ($a eq "WIN32_MODULE_NAME") { $override_module = $b; }
176
if ($a eq "WIN32_MODULE_COPYRIGHT") { $override_copyright = $b; }
177
if ($a eq "WIN32_MODULE_TRADEMARKS") { $override_trademarks = $b; }
178
if ($a eq "WIN32_MODULE_ORIGINAL_FILENAME") { $override_filename = $b; }
179
if ($a eq "WIN32_MODULE_PRODUCTNAME") { $override_productname = $b; }
180
($a,$b) = getNextEntry();
186
if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; }
188
#Get rid of trailing and leading whitespace
189
$debug =~ s/^\s*(.*)\s*$/$1/;
190
$comment =~ s/^\s*(.*)\s*$/$1/;
191
$official =~ s/^\s*(.*)\s*$/$1/;
192
$milestone =~ s/^\s*(.*)\s*$/$1/;
193
$description =~ s/^\s*(.*)\s*$/$1/;
194
$module =~ s/^\s*(.*)\s*$/$1/;
195
$depth =~ s/^\s*(.*)\s*$/$1/;
196
$privateinfo =~ s/^\s*(.*)\s*$/$1/;
197
$binary =~ s/^\s*(.*)\s*$/$1/;
201
$fileflags .= " | VS_FF_DEBUG";
202
$mpversion .= " Debug";
203
$mfversion .= " Debug";
206
if ($official eq "1") {
207
#its an official build
209
$fileflags = "VS_FF_PRERELEASE";
211
$fileflags = "VS_FF_PRERELEASE | VS_FF_DEBUG";
214
# Try to grab milestone.
215
# I'd love to put this in the makefiles rather than here,
216
# since I could run it once per build rather than once per
217
# dll/program, but I can't seem to get backticks working
218
# properly in the makefiles =P
219
if ($milestone eq "") {
220
$milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
223
if ($milestone ne "" && $milestone !~ /\+$/) {
224
#its a milestone build
226
$mpversion = $milestone;
230
my @mstone = split(/\./,$milestone);
231
$mstone[1] =~s/\D*$//g;
232
$productversion="$mstone[0],$mstone[1],0,0";
236
my ($buildid, $buildid_hi, $buildid_lo);
237
open(NUMBER, "<$BUILDID_FILE") || die "No build number file\n";
238
while ( <NUMBER> ) { $buildid = $_ }
240
$buildid =~ s/^\s*(.*)\s*$/$1/;
241
$buildid_hi = substr($buildid, 0, 5);
242
$buildid_lo = substr($buildid, 5);
244
$mfversion = $mpversion = "$milestone: $buildid";
245
my @pvarray = split(',', $productversion);
246
$fileversion = "$pvarray[0],$pvarray[1],$buildid_hi,$buildid_lo";
249
my $copyright = "License: MPL 1.1/GPL 2.0/LGPL 2.1";
250
my $company = "Mozilla Foundation";
251
my $trademarks = "Mozilla";
252
my $productname = "Mozilla";
255
if (defined($override_comment)){$comment=$override_comment;}
256
if (defined($override_description)){$description=$override_description;}
257
if (defined($override_fileversion)){$fileversion=$override_fileversion;}
258
if (defined($override_mfversion)){$mfversion=$override_mfversion;}
259
if (defined($override_company)){$company=$override_company;}
260
if (defined($override_module)){$module=$override_module;}
261
if (defined($override_copyright)){$copyright=$override_company;}
262
if (defined($override_trademarks)){$trademarks=$override_trademarks;}
263
if (defined($override_filename)){$binary=$override_filename;}
264
if (defined($override_productname)){$productname=$override_productname;}
269
open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n");
271
// ***** BEGIN LICENSE BLOCK *****
272
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
274
// The contents of this file are subject to the Mozilla Public License Version
275
// 1.1 (the "License"); you may not use this file except in compliance with
276
// the License. You may obtain a copy of the License at
277
// http://www.mozilla.org/MPL/
279
// Software distributed under the License is distributed on an "AS IS" basis,
280
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
281
// for the specific language governing rights and limitations under the
284
// The Original Code is the Win32 Version System.
286
// The Initial Developer of the Original Code is Brian Bober <netdemonz\@yahoo.com>
287
// Portions created by the Initial Developer are Copyright (C) 2001
288
// the Initial Developer. All Rights Reserved.
292
// Alternatively, the contents of this file may be used under the terms of
293
// either the GNU General Public License Version 2 or later (the "GPL"), or
294
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
295
// in which case the provisions of the GPL or the LGPL are applicable instead
296
// of those above. If you wish to allow use of your version of this file only
297
// under the terms of either the GPL or the LGPL, and not to allow others to
298
// use your version of this file under the terms of the MPL, indicate your
299
// decision by deleting the provisions above and replace them with the notice
300
// and other provisions required by the GPL or the LGPL. If you do not delete
301
// the provisions above, a recipient may use your version of this file under
302
// the terms of any one of the MPL, the GPL or the LGPL.
304
// ***** END LICENSE BLOCK *****
308
// Note: if you contain versioning information in an included
309
// RC script, it will be discarded
310
// Use module.ver to explicitly set these values
312
// Do not edit this file. Changes won't affect the build.
318
if (open(RCINCLUDE, "<$rcinclude"))
320
print RCFILE "// From included resource $rcinclude\n";
327
# $mstring .= "$instr\;";
330
# $mstring =~ s/\/\*.*\*\///g;
331
# my @mlines = split(/\;/,$mstring);
334
# my ($nocomment)=split(/\/\//,$_);
335
# if (defined($nocomment) && $nocomment ne "")
337
# my ($firststring,$secondstring) = split(/\s+/,$nocomment);
338
# if (!defined($firststring)) {$firststring="";}
339
# if (!defined($secondstring)) {$secondstring="";}
340
# if ($secondstring eq "VERSIONINFO")
342
#if (!$quiet || $quiet ne "1") {
343
# print "$bufferstr" . "WARNING: Included RC file ($rcinclude, $module, $binary)\n";
344
# print "$bufferstr" . "WARNING: contains versioning information that will be discarded\n";
345
# print "$bufferstr" . "WARNING: Remove it and use relevant overrides (in module.ver)\n";
348
# $insideversion = 1;
350
# if ($firststring eq "BEGIN") { $versionlevel++; }
351
# if ($secondstring eq "END")
354
# if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;}
356
# my $includecheck = $firststring . $secondstring;
357
# $includecheck =~ s/<|>/"/g;
358
# $includecheck = lc($includecheck);
359
# if ($includecheck ne "#include\"winver.h\"")
361
# if ($insideversion == 0 && $versionlevel == 0)
363
# print RCFILE "$nocomment\n";
374
/////////////////////////////////////////////////////////////////////////////
380
FILEVERSION $fileversion
381
PRODUCTVERSION $productversion
388
BLOCK "StringFileInfo"
392
VALUE "Comments", "$comment"
393
VALUE "LegalCopyright", "$copyright"
394
VALUE "CompanyName", "$company"
395
VALUE "FileDescription", "$description"
396
VALUE "FileVersion", "$mfversion"
397
VALUE "ProductVersion", "$mpversion"
398
VALUE "InternalName", "$module"
399
VALUE "LegalTrademarks", "$trademarks"
400
VALUE "OriginalFilename", "$binary"
402
if ($official ne "1") {
404
VALUE "PrivateBuild", "$privateinfo"
408
VALUE "ProductName", "$productname"
413
VALUE "Translation", 0x0, 1200