1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/config/version_win.pl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,374 @@ 1.4 +#!/usr/bin/perl -w 1.5 + 1.6 +# This Source Code Form is subject to the terms of the Mozilla Public 1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.9 + 1.10 +#use diagnostics; 1.11 +require strict; 1.12 +my $dir = $0; 1.13 +$dir =~ s/[^\/]*$//; 1.14 +push(@INC, "$dir"); 1.15 +require "Moz/Milestone.pm"; 1.16 +use Getopt::Long; 1.17 +use Getopt::Std; 1.18 +use POSIX; 1.19 + 1.20 +# Calculate the number of days since Jan. 1, 2000 from a buildid string 1.21 +sub daysFromBuildID 1.22 +{ 1.23 + my ($buildid,) = @_; 1.24 + 1.25 + my ($y, $m, $d, $h) = ($buildid =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/); 1.26 + $d || die("Unrecognized buildid string."); 1.27 + 1.28 + my $secondstodays = 60 * 60 * 24; 1.29 + return sprintf("%d", 1.30 + (POSIX::mktime(00, 00, 00, $d, $m - 1, $y - 1900) - 1.31 + POSIX::mktime(00, 00, 00, 01, 00, 100)) / $secondstodays); 1.32 +} 1.33 + 1.34 +#Creates version resource file 1.35 + 1.36 +#Paramaters are passed on the command line: 1.37 + 1.38 +#Example: -MODNAME nsToolkitCompsModule -DEBUG=1 1.39 + 1.40 +# DEBUG - Mozilla's global debug variable - tells if its debug version 1.41 +# OFFICIAL - tells Mozilla is building a milestone or nightly 1.42 +# MSTONE - tells which milestone is being built; 1.43 +# OBJDIR - Holds the object directory; 1.44 +# MODNAME - tells what the name of the module is like nsBMPModule 1.45 +# DEPTH - Holds the path to the root obj dir 1.46 +# TOPSRCDIR - Holds the path to the root mozilla dir 1.47 +# SRCDIR - Holds module.ver and source 1.48 +# BINARY - Holds the name of the binary file 1.49 +# DISPNAME - Holds the display name of the built application 1.50 +# APPVERSION - Holds the version string of the built application 1.51 +# RCINCLUDE - Holds the name of the RC File to include or "" 1.52 +# QUIET - Turns off output 1.53 + 1.54 +#Description and Comment come from module.ver 1.55 +#Bug 23560 1.56 +#http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/rc_7x2d.asp 1.57 + 1.58 +#Get next .ver file entry 1.59 +sub getNextEntry 1.60 +{ 1.61 + while (<VERFILE>) 1.62 + { 1.63 + my $mline = $_; 1.64 + ($mline) = split(/#/,$mline); 1.65 + my ($entry, $value)=split(/=/,$mline,2); 1.66 + if (defined($entry)) 1.67 + { 1.68 + if (defined($value)) 1.69 + { 1.70 + $entry =~ s/^\s*(.*?)\s*$/$1/; 1.71 + $value =~ s/^\s*(.*?)\s*$/$1/; 1.72 + return ($entry,$value); 1.73 + } 1.74 + } 1.75 + } 1.76 + return undef; 1.77 +} 1.78 + 1.79 +my ($quiet,$objdir,$debug,$official,$milestone,$buildid,$module,$binary,$depth,$rcinclude,$srcdir,$fileversion,$productversion); 1.80 + 1.81 +GetOptions( "QUIET" => \$quiet, 1.82 + "DEBUG=s" => \$debug, 1.83 + "OFFICIAL=s" => \$official, 1.84 + "MSTONE=s" => \$milestone, 1.85 + "MODNAME=s" => \$module, 1.86 + "BINARY=s" => \$binary, 1.87 + "DISPNAME=s" => \$displayname, 1.88 + "APPVERSION=s" => \$appversion, 1.89 + "SRCDIR=s" => \$srcdir, 1.90 + "TOPSRCDIR=s" => \$topsrcdir, 1.91 + "DEPTH=s" => \$depth, 1.92 + "RCINCLUDE=s" => \$rcinclude, 1.93 + "OBJDIR=s" => \$objdir); 1.94 +if (!defined($debug)) {$debug="";} 1.95 +if (!defined($official)) {$official="";} 1.96 +if (!defined($milestone)) {$milestone="";} 1.97 +if (!defined($module)) {$module="";} 1.98 +if (!defined($binary)) {$binary="";} 1.99 +if (!defined($displayname)) {$displayname="Mozilla";} 1.100 +if (!defined($appversion)) {$appversion=$milestone;} 1.101 +if (!defined($depth)) {$depth=".";} 1.102 +if (!defined($rcinclude)) {$rcinclude="";} 1.103 +if (!defined($objdir)) {$objdir=".";} 1.104 +if (!defined($srcdir)) {$srcdir=".";} 1.105 +if (!defined($topsrcdir)) {$topsrcdir=".";} 1.106 +my $mfversion = "Personal"; 1.107 +my $mpversion = "Personal"; 1.108 +my @fileflags = ("0"); 1.109 +my $comment=""; 1.110 +my $description=""; 1.111 +if (!defined($module)) 1.112 +{ 1.113 + $module = $binary; 1.114 + ($module) = split(/\./,$module); 1.115 +} 1.116 + 1.117 +my $bufferstr=" "; 1.118 + 1.119 +my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt"; 1.120 +my $BUILDID_FILE = "$depth/config/buildid"; 1.121 + 1.122 +#Read module.ver file 1.123 +#Version file overrides for WIN32: 1.124 +#WIN32_MODULE_COMMENT 1.125 +#WIN32_MODULE_DESCRIPTION 1.126 +#WIN32_MODULE_FILEVERSION 1.127 +#WIN32_MODULE_COMPANYNAME 1.128 +#WIN32_MODULE_FILEVERSION_STRING 1.129 +#WIN32_MODULE_NAME 1.130 +#WIN32_MODULE_COPYRIGHT 1.131 +#WIN32_MODULE_TRADEMARKS 1.132 +#WIN32_MODULE_ORIGINAL_FILENAME 1.133 +#WIN32_MODULE_PRODUCTNAME 1.134 +#WIN32_MODULE_PRODUCTVERSION 1.135 +#WIN32_MODULE_PRODUCTVERSION_STRING 1.136 + 1.137 +#Override values obtained from the .ver file 1.138 +my $override_comment; 1.139 +my $override_description; 1.140 +my $override_fileversion; 1.141 +my $override_company; 1.142 +my $override_mfversion; 1.143 +my $override_module; 1.144 +my $override_copyright; 1.145 +my $override_trademarks; 1.146 +my $override_filename; 1.147 +my $override_productname; 1.148 +my $override_productversion; 1.149 +my $override_mpversion; 1.150 +if (open(VERFILE, "<$srcdir/module.ver")) 1.151 +{ 1.152 + 1.153 + my ($a,$b) = getNextEntry(); 1.154 + while (defined($a)) 1.155 + { 1.156 + if ($a eq "WIN32_MODULE_COMMENT") { $override_comment = $b; } 1.157 + if ($a eq "WIN32_MODULE_DESCRIPTION") { $override_description = $b; } 1.158 + if ($a eq "WIN32_MODULE_FILEVERSION") { $override_fileversion = $b; } 1.159 + if ($a eq "WIN32_MODULE_COMPANYNAME") { $override_company = $b; } 1.160 + if ($a eq "WIN32_MODULE_FILEVERSION_STRING") { $override_mfversion = $b; } 1.161 + if ($a eq "WIN32_MODULE_NAME") { $override_module = $b; } 1.162 + if ($a eq "WIN32_MODULE_COPYRIGHT") { $override_copyright = $b; } 1.163 + if ($a eq "WIN32_MODULE_TRADEMARKS") { $override_trademarks = $b; } 1.164 + if ($a eq "WIN32_MODULE_ORIGINAL_FILENAME") { $override_filename = $b; } 1.165 + if ($a eq "WIN32_MODULE_PRODUCTNAME") { $override_productname = $b; } 1.166 + if ($a eq "WIN32_MODULE_PRODUCTVERSION") { $override_productversion = $b; } 1.167 + if ($a eq "WIN32_MODULE_PRODUCTVERSION_STRING") { $override_mpversion = $b; } 1.168 + ($a,$b) = getNextEntry(); 1.169 + } 1.170 + close(VERFILE) 1.171 +} 1.172 +else 1.173 +{ 1.174 + if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; } 1.175 +} 1.176 +#Get rid of trailing and leading whitespace 1.177 +$debug =~ s/^\s*(.*)\s*$/$1/; 1.178 +$comment =~ s/^\s*(.*)\s*$/$1/; 1.179 +$official =~ s/^\s*(.*)\s*$/$1/; 1.180 +$milestone =~ s/^\s*(.*)\s*$/$1/; 1.181 +$description =~ s/^\s*(.*)\s*$/$1/; 1.182 +$module =~ s/^\s*(.*)\s*$/$1/; 1.183 +$depth =~ s/^\s*(.*)\s*$/$1/; 1.184 +$binary =~ s/^\s*(.*)\s*$/$1/; 1.185 +$displayname =~ s/^\s*(.*)\s*$/$1/; 1.186 + 1.187 +open(BUILDID, "<", $BUILDID_FILE) || die("Couldn't open buildid file: $BUILDID_FILE"); 1.188 +$buildid = <BUILDID>; 1.189 +$buildid =~ s/\s*$//; 1.190 +close BUILDID; 1.191 + 1.192 +my $daycount = daysFromBuildID($buildid); 1.193 + 1.194 +if ($milestone eq "") { 1.195 + $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE); 1.196 +} 1.197 + 1.198 +$mfversion = $mpversion = $milestone; 1.199 +if ($appversion eq "") { 1.200 + $appversion = $milestone; 1.201 +} 1.202 + 1.203 +if ($debug eq "1") 1.204 +{ 1.205 + push @fileflags, "VS_FF_DEBUG"; 1.206 + $mpversion .= " Debug"; 1.207 + $mfversion .= " Debug"; 1.208 +} 1.209 + 1.210 +if ($official ne "1") { 1.211 + push @fileflags, "VS_FF_PRIVATEBUILD"; 1.212 +} 1.213 + 1.214 +if ($milestone =~ /[a-z]/) { 1.215 + push @fileflags, "VS_FF_PRERELEASE"; 1.216 +} 1.217 + 1.218 +my @mstone = split(/\./,$milestone); 1.219 +$mstone[1] =~s/\D.*$//; 1.220 +if (!$mstone[2]) { 1.221 + $mstone[2] = "0"; 1.222 +} 1.223 +else { 1.224 + $mstone[2] =~s/\D.*$//; 1.225 +} 1.226 +$fileversion = $productversion="$mstone[0],$mstone[1],$mstone[2],$daycount"; 1.227 + 1.228 +my @appver = split(/\./,$appversion); 1.229 +for ($j = 1; $j < 4; $j++) 1.230 +{ 1.231 + if (!$appver[$j]) { 1.232 + $appver[$j] = "0"; 1.233 + } 1.234 + else { 1.235 + $appver[$j] =~s/\D.*$//; 1.236 + } 1.237 +} 1.238 +my $winappversion = "$appver[0],$appver[1],$appver[2],$appver[3]"; 1.239 + 1.240 +my $copyright = "License: MPL 2"; 1.241 +my $company = "Mozilla Foundation"; 1.242 +my $trademarks = "Mozilla"; 1.243 +my $productname = $displayname; 1.244 + 1.245 + 1.246 +if (defined($override_comment)){$override_comment =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $comment=$override_comment;} 1.247 +if (defined($override_description)){$override_description =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $description=$override_description;} 1.248 +if (defined($override_fileversion)){$override_fileversion =~ s/\@MOZ_APP_WINVERSION\@/$winappversion/g; $fileversion=$override_fileversion;} 1.249 +if (defined($override_mfversion)){$override_mfversion =~ s/\@MOZ_APP_VERSION\@/$appversion/g; $mfversion=$override_mfversion;} 1.250 +if (defined($override_company)){$company=$override_company;} 1.251 +if (defined($override_module)){$override_module =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $module=$override_module;} 1.252 +if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_copyright;} 1.253 +if (defined($override_trademarks)){$override_trademarks =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $trademarks=$override_trademarks;} 1.254 +if (defined($override_filename)){$binary=$override_filename;} 1.255 +if (defined($override_productname)){$override_productname =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $productname=$override_productname;} 1.256 +if (defined($override_productversion)){$override_productversion =~ s/\@MOZ_APP_WINVERSION\@/$winappversion/g; $productversion=$override_productversion;} 1.257 +if (defined($override_mpversion)){$override_mpversion =~ s/\@MOZ_APP_VERSION\@/$appversion/g; $mpversion=$override_mpversion;} 1.258 + 1.259 + 1.260 +#Override section 1.261 + 1.262 +open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n"); 1.263 +print RCFILE qq{ 1.264 +// This Source Code Form is subject to the terms of the Mozilla Public 1.265 +// License, v. 2.0. If a copy of the MPL was not distributed with this 1.266 +// file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.267 + 1.268 +#include<winver.h> 1.269 + 1.270 +// Note: if you contain versioning information in an included 1.271 +// RC script, it will be discarded 1.272 +// Use module.ver to explicitly set these values 1.273 + 1.274 +// Do not edit this file. Changes won't affect the build. 1.275 + 1.276 +}; 1.277 + 1.278 +my $versionlevel=0; 1.279 +my $insideversion=0; 1.280 +if (open(RCINCLUDE, "<$rcinclude")) 1.281 +{ 1.282 + print RCFILE "// From included resource $rcinclude\n"; 1.283 +# my $mstring=""; 1.284 + while (<RCINCLUDE>) 1.285 + { 1.286 + $_ =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; 1.287 + print RCFILE $_; 1.288 +# my $instr=$_; 1.289 +# chomp($instr); 1.290 +# $mstring .= "$instr\;"; 1.291 + } 1.292 + close(RCINCLUDE); 1.293 +# $mstring =~ s/\/\*.*\*\///g; 1.294 +# my @mlines = split(/\;/,$mstring); 1.295 +# for(@mlines) 1.296 +# { 1.297 +# my ($nocomment)=split(/\/\//,$_); 1.298 +# if (defined($nocomment) && $nocomment ne "") 1.299 +# { 1.300 +# my ($firststring,$secondstring) = split(/\s+/,$nocomment); 1.301 +# if (!defined($firststring)) {$firststring="";} 1.302 +# if (!defined($secondstring)) {$secondstring="";} 1.303 +# if ($secondstring eq "VERSIONINFO") 1.304 +# { 1.305 +#if (!$quiet || $quiet ne "1") { 1.306 +# print "$bufferstr" . "WARNING: Included RC file ($rcinclude, $module, $binary)\n"; 1.307 +# print "$bufferstr" . "WARNING: contains versioning information that will be discarded\n"; 1.308 +# print "$bufferstr" . "WARNING: Remove it and use relevant overrides (in module.ver)\n"; 1.309 +#} 1.310 +# $versionlevel = 0; 1.311 +# $insideversion = 1; 1.312 +# } 1.313 +# if ($firststring eq "BEGIN") { $versionlevel++; } 1.314 +# if ($secondstring eq "END") 1.315 +# { 1.316 +# $versionlevel--; 1.317 +# if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;} 1.318 +# } 1.319 +# my $includecheck = $firststring . $secondstring; 1.320 +# $includecheck =~ s/<|>/"/g; 1.321 +# $includecheck = lc($includecheck); 1.322 +# if ($includecheck ne "#include\"winver.h\"") 1.323 +# { 1.324 +# if ($insideversion == 0 && $versionlevel == 0) 1.325 +# { 1.326 +# print RCFILE "$nocomment\n"; 1.327 +# } 1.328 +# } 1.329 +# } 1.330 +# } 1.331 + 1.332 +} 1.333 + 1.334 +my $fileflags = join(' | ', @fileflags); 1.335 + 1.336 +print RCFILE qq{ 1.337 + 1.338 + 1.339 +///////////////////////////////////////////////////////////////////////////// 1.340 +// 1.341 +// Version 1.342 +// 1.343 + 1.344 +1 VERSIONINFO 1.345 + FILEVERSION $fileversion 1.346 + PRODUCTVERSION $productversion 1.347 + FILEFLAGSMASK 0x3fL 1.348 + FILEFLAGS $fileflags 1.349 + FILEOS VOS__WINDOWS32 1.350 + FILETYPE VFT_DLL 1.351 + FILESUBTYPE 0x0L 1.352 +BEGIN 1.353 + BLOCK "StringFileInfo" 1.354 + BEGIN 1.355 + BLOCK "000004b0" 1.356 + BEGIN 1.357 + VALUE "Comments", "$comment" 1.358 + VALUE "LegalCopyright", "$copyright" 1.359 + VALUE "CompanyName", "$company" 1.360 + VALUE "FileDescription", "$description" 1.361 + VALUE "FileVersion", "$mfversion" 1.362 + VALUE "ProductVersion", "$mpversion" 1.363 + VALUE "InternalName", "$module" 1.364 + VALUE "LegalTrademarks", "$trademarks" 1.365 + VALUE "OriginalFilename", "$binary" 1.366 + VALUE "ProductName", "$productname" 1.367 + VALUE "BuildID", "$buildid" 1.368 + END 1.369 + END 1.370 + BLOCK "VarFileInfo" 1.371 + BEGIN 1.372 + VALUE "Translation", 0x0, 1200 1.373 + END 1.374 +END 1.375 + 1.376 +}; 1.377 +close(RCFILE);