3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 require "Moz/Milestone.pm";
17 # Calculate the number of days since Jan. 1, 2000 from a buildid string
22 my ($y, $m, $d, $h) = ($buildid =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/);
23 $d || die("Unrecognized buildid string.");
25 my $secondstodays = 60 * 60 * 24;
27 (POSIX
::mktime
(00, 00, 00, $d, $m - 1, $y - 1900) -
28 POSIX
::mktime
(00, 00, 00, 01, 00, 100)) / $secondstodays);
31 #Creates version resource file
33 #Paramaters are passed on the command line:
35 #Example: -MODNAME nsToolkitCompsModule -DEBUG=1
37 # DEBUG - Mozilla's global debug variable - tells if its debug version
38 # OFFICIAL - tells Mozilla is building a milestone or nightly
39 # MSTONE - tells which milestone is being built;
40 # OBJDIR - Holds the object directory;
41 # MODNAME - tells what the name of the module is like nsBMPModule
42 # DEPTH - Holds the path to the root obj dir
43 # TOPSRCDIR - Holds the path to the root mozilla dir
44 # SRCDIR - Holds module.ver and source
45 # BINARY - Holds the name of the binary file
46 # DISPNAME - Holds the display name of the built application
47 # APPVERSION - Holds the version string of the built application
48 # RCINCLUDE - Holds the name of the RC File to include or ""
49 # QUIET - Turns off output
51 #Description and Comment come from module.ver
53 #http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/rc_7x2d.asp
55 #Get next .ver file entry
61 ($mline) = split(/#/,$mline);
62 my ($entry, $value)=split(/=/,$mline,2);
67 $entry =~ s/^\s*(.*?)\s*$/$1/;
68 $value =~ s/^\s*(.*?)\s*$/$1/;
69 return ($entry,$value);
76 my ($quiet,$objdir,$debug,$official,$milestone,$buildid,$module,$binary,$depth,$rcinclude,$srcdir,$fileversion,$productversion);
78 GetOptions
( "QUIET" => \
$quiet,
80 "OFFICIAL=s" => \
$official,
81 "MSTONE=s" => \
$milestone,
82 "MODNAME=s" => \
$module,
83 "BINARY=s" => \
$binary,
84 "DISPNAME=s" => \
$displayname,
85 "APPVERSION=s" => \
$appversion,
86 "SRCDIR=s" => \
$srcdir,
87 "TOPSRCDIR=s" => \
$topsrcdir,
89 "RCINCLUDE=s" => \
$rcinclude,
90 "OBJDIR=s" => \
$objdir);
91 if (!defined($debug)) {$debug="";}
92 if (!defined($official)) {$official="";}
93 if (!defined($milestone)) {$milestone="";}
94 if (!defined($module)) {$module="";}
95 if (!defined($binary)) {$binary="";}
96 if (!defined($displayname)) {$displayname="Mozilla";}
97 if (!defined($appversion)) {$appversion=$milestone;}
98 if (!defined($depth)) {$depth=".";}
99 if (!defined($rcinclude)) {$rcinclude="";}
100 if (!defined($objdir)) {$objdir=".";}
101 if (!defined($srcdir)) {$srcdir=".";}
102 if (!defined($topsrcdir)) {$topsrcdir=".";}
103 my $mfversion = "Personal";
104 my $mpversion = "Personal";
105 my @fileflags = ("0");
108 if (!defined($module))
111 ($module) = split(/\./,$module);
116 my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
117 my $BUILDID_FILE = "$depth/buildid.h";
119 #Read module.ver file
120 #Version file overrides for WIN32:
121 #WIN32_MODULE_COMMENT
122 #WIN32_MODULE_DESCRIPTION
123 #WIN32_MODULE_FILEVERSION
124 #WIN32_MODULE_COMPANYNAME
125 #WIN32_MODULE_FILEVERSION_STRING
127 #WIN32_MODULE_COPYRIGHT
128 #WIN32_MODULE_TRADEMARKS
129 #WIN32_MODULE_ORIGINAL_FILENAME
130 #WIN32_MODULE_PRODUCTNAME
131 #WIN32_MODULE_PRODUCTVERSION
132 #WIN32_MODULE_PRODUCTVERSION_STRING
134 #Override values obtained from the .ver file
135 my $override_comment;
136 my $override_description;
137 my $override_fileversion;
138 my $override_company;
139 my $override_mfversion;
141 my $override_copyright;
142 my $override_trademarks;
143 my $override_filename;
144 my $override_productname;
145 my $override_productversion;
146 my $override_mpversion;
147 if (open(VERFILE
, "<$srcdir/module.ver"))
150 my ($a,$b) = getNextEntry
();
153 if ($a eq "WIN32_MODULE_COMMENT") { $override_comment = $b; }
154 if ($a eq "WIN32_MODULE_DESCRIPTION") { $override_description = $b; }
155 if ($a eq "WIN32_MODULE_FILEVERSION") { $override_fileversion = $b; }
156 if ($a eq "WIN32_MODULE_COMPANYNAME") { $override_company = $b; }
157 if ($a eq "WIN32_MODULE_FILEVERSION_STRING") { $override_mfversion = $b; }
158 if ($a eq "WIN32_MODULE_NAME") { $override_module = $b; }
159 if ($a eq "WIN32_MODULE_COPYRIGHT") { $override_copyright = $b; }
160 if ($a eq "WIN32_MODULE_TRADEMARKS") { $override_trademarks = $b; }
161 if ($a eq "WIN32_MODULE_ORIGINAL_FILENAME") { $override_filename = $b; }
162 if ($a eq "WIN32_MODULE_PRODUCTNAME") { $override_productname = $b; }
163 if ($a eq "WIN32_MODULE_PRODUCTVERSION") { $override_productversion = $b; }
164 if ($a eq "WIN32_MODULE_PRODUCTVERSION_STRING") { $override_mpversion = $b; }
165 ($a,$b) = getNextEntry
();
171 if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; }
173 #Get rid of trailing and leading whitespace
174 $debug =~ s/^\s*(.*)\s*$/$1/;
175 $comment =~ s/^\s*(.*)\s*$/$1/;
176 $official =~ s/^\s*(.*)\s*$/$1/;
177 $milestone =~ s/^\s*(.*)\s*$/$1/;
178 $description =~ s/^\s*(.*)\s*$/$1/;
179 $module =~ s/^\s*(.*)\s*$/$1/;
180 $depth =~ s/^\s*(.*)\s*$/$1/;
181 $binary =~ s/^\s*(.*)\s*$/$1/;
182 $displayname =~ s/^\s*(.*)\s*$/$1/;
184 open(BUILDID
, "<", $BUILDID_FILE) || die("Couldn't open buildid file: $BUILDID_FILE");
185 $buildid = <BUILDID
>;
186 $buildid =~ s/^#define MOZ_BUILDID\s+(\S+)\s*$/$1/;
189 my $daycount = daysFromBuildID
($buildid);
191 if ($milestone eq "") {
192 $milestone = Moz
::Milestone
::getOfficialMilestone
($MILESTONE_FILE);
195 $mfversion = $mpversion = $milestone;
196 if ($appversion eq "") {
197 $appversion = $milestone;
202 push @fileflags, "VS_FF_DEBUG";
203 $mpversion .= " Debug";
204 $mfversion .= " Debug";
207 if ($official ne "1") {
208 push @fileflags, "VS_FF_PRIVATEBUILD";
211 if ($milestone =~ /[a-z]/) {
212 push @fileflags, "VS_FF_PRERELEASE";
215 my @mstone = split(/\./,$milestone);
216 $mstone[1] =~s/\D.*$//;
221 $mstone[2] =~s/\D.*$//;
223 $fileversion = $productversion="$mstone[0],$mstone[1],$mstone[2],$daycount";
225 my @appver = split(/\./,$appversion);
226 for ($j = 1; $j < 4; $j++)
232 $appver[$j] =~s/\D.*$//;
235 my $winappversion = "$appver[0],$appver[1],$appver[2],$appver[3]";
237 my $copyright = "License: MPL 2";
238 my $company = "Mozilla Foundation";
239 my $trademarks = "Mozilla";
240 my $productname = $displayname;
243 if (defined($override_comment)){$override_comment =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $comment=$override_comment;}
244 if (defined($override_description)){$override_description =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $description=$override_description;}
245 if (defined($override_fileversion)){$override_fileversion =~ s/\@MOZ_APP_WINVERSION\@/$winappversion/g; $fileversion=$override_fileversion;}
246 if (defined($override_mfversion)){$override_mfversion =~ s/\@MOZ_APP_VERSION\@/$appversion/g; $mfversion=$override_mfversion;}
247 if (defined($override_company)){$company=$override_company;}
248 if (defined($override_module)){$override_module =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $module=$override_module;}
249 if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_copyright;}
250 if (defined($override_trademarks)){$override_trademarks =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $trademarks=$override_trademarks;}
251 if (defined($override_filename)){$binary=$override_filename;}
252 if (defined($override_productname)){$override_productname =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $productname=$override_productname;}
253 if (defined($override_productversion)){$override_productversion =~ s/\@MOZ_APP_WINVERSION\@/$winappversion/g; $productversion=$override_productversion;}
254 if (defined($override_mpversion)){$override_mpversion =~ s/\@MOZ_APP_VERSION\@/$appversion/g; $mpversion=$override_mpversion;}
259 open(RCFILE
, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n");
261 // This Source Code Form is subject to the terms of the Mozilla Public
262 // License
, v
. 2.0. If a copy of the MPL was
not distributed with this
263 // file
, You can obtain one at http
://mozilla
.org
/MPL/2.0/.
267 // Note
: if you contain versioning information
in an included
268 // RC script
, it will be discarded
269 // Use module
.ver to explicitly set these
values
271 // Do
not edit this file
. Changes won
't affect the build.
278 if (open(RCINCLUDE, "<$rcinclude"))
280 print RCFILE "// From included resource $rcinclude\n";
284 $has_manifest = 1 if /^1 (24|RT_MANIFEST) "$binary.manifest"/;
285 $_ =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g;
289 # $mstring .= "$instr\;";
292 # $mstring =~ s/\/\*.*\*\///g;
293 # my @mlines = split(/\;/,$mstring);
296 # my ($nocomment)=split(/\/\//,$_);
297 # if (defined($nocomment) && $nocomment ne "")
299 # my ($firststring,$secondstring) = split(/\s+/,$nocomment);
300 # if (!defined($firststring)) {$firststring="";}
301 # if (!defined($secondstring)) {$secondstring="";}
302 # if ($secondstring eq "VERSIONINFO")
304 #if (!$quiet || $quiet ne "1") {
305 # print "$bufferstr" . "WARNING: Included RC file ($rcinclude, $module, $binary)\n";
306 # print "$bufferstr" . "WARNING: contains versioning information that will be discarded\n";
307 # print "$bufferstr" . "WARNING: Remove it and use relevant overrides (in module.ver)\n";
310 # $insideversion = 1;
312 # if ($firststring eq "BEGIN") { $versionlevel++; }
313 # if ($secondstring eq "END")
316 # if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;}
318 # my $includecheck = $firststring . $secondstring;
319 # $includecheck =~ s/<|>/"/g;
320 # $includecheck = lc($includecheck);
321 # if ($includecheck ne "#include\"winver.h\"")
323 # if ($insideversion == 0 && $versionlevel == 0)
325 # print RCFILE "$nocomment\n";
333 my $fileflags = join(' | ', @fileflags);
336 1 RT_MANIFEST "$binary.manifest"
337 } if !$has_manifest && $binary =~ /\.exe$/ && -e "$objdir/$binary.manifest";
342 /////////////////////////////////////////////////////////////////////////////
348 FILEVERSION $fileversion
349 PRODUCTVERSION $productversion
352 FILEOS VOS__WINDOWS32
356 BLOCK "StringFileInfo"
360 VALUE "Comments", "$comment"
361 VALUE "LegalCopyright", "$copyright"
362 VALUE "CompanyName", "$company"
363 VALUE "FileDescription", "$description"
364 VALUE "FileVersion", "$mfversion"
365 VALUE "ProductVersion", "$mpversion"
366 VALUE "InternalName", "$module"
367 VALUE "LegalTrademarks", "$trademarks"
368 VALUE "OriginalFilename", "$binary"
369 VALUE "ProductName", "$productname"
370 VALUE "BuildID", "$buildid"
375 VALUE "Translation", 0x0, 1200