/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/config/version_win.pl
Perl | 423 lines | 326 code | 23 blank | 74 comment | 37 complexity | e1c644e747a1bff78b53a755b55ba223 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
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; 39require strict; 40my $dir = $0; 41$dir =~ s/[^\/]*$//; 42push(@INC, "$dir"); 43require "Moz/Milestone.pm"; 44use Getopt::Long; 45use Getopt::Std; 46use POSIX; 47 48# Calculate the number of days since Jan. 1, 2000 from a buildid string 49sub 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 86sub 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 106my ($quiet,$objdir,$debug,$official,$milestone,$buildid,$module,$binary,$depth,$rcinclude,$bits,$srcdir,$fileversion,$productversion); 107 108GetOptions( "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); 121if (!defined($debug)) {$debug="";} 122if (!defined($official)) {$official="";} 123if (!defined($milestone)) {$milestone="";} 124if (!defined($module)) {$module="";} 125if (!defined($binary)) {$binary="";} 126if (!defined($displayname)) {$displayname="Mozilla";} 127if (!defined($depth)) {$depth=".";} 128if (!defined($rcinclude)) {$rcinclude="";} 129if (!defined($objdir)) {$objdir=".";} 130if (!defined($srcdir)) {$srcdir=".";} 131if (!defined($topsrcdir)) {$topsrcdir=".";} 132if (!defined($bits)) {$bits="";} 133my $mfversion = "Personal"; 134my $mpversion = "Personal"; 135my @fileflags = ("0"); 136my $comment=""; 137my $description=""; 138if (!defined($module)) 139{ 140 $module = $binary; 141 ($module) = split(/\./,$module); 142} 143 144my $fileos = "VOS__WINDOWS32"; 145if ($bits eq "16") { $fileos="VOS__WINDOWS16"; } 146 147my $bufferstr=" "; 148 149my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt"; 150my $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 168my $override_comment; 169my $override_description; 170my $override_fileversion; 171my $override_company; 172my $override_mfversion; 173my $override_module; 174my $override_copyright; 175my $override_trademarks; 176my $override_filename; 177my $override_productname; 178my $override_productversion; 179my $override_mpversion; 180if (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} 202else 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 217open(BUILDID, "<", $BUILDID_FILE) || die("Couldn't open buildid file: $BUILDID_FILE"); 218$buildid = <BUILDID>; 219$buildid =~ s/\s*$//; 220close BUILDID; 221 222my $daycount = daysFromBuildID($buildid); 223 224if ($milestone eq "") { 225 $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE); 226} 227 228$mfversion = $mpversion = $milestone; 229 230if ($debug eq "1") 231{ 232 push @fileflags, "VS_FF_DEBUG"; 233 $mpversion .= " Debug"; 234 $mfversion .= " Debug"; 235} 236 237if ($official ne "1") { 238 push @fileflags, "VS_FF_PRIVATEBUILD"; 239} 240 241if ($milestone =~ /[a-z]/) { 242 push @fileflags, "VS_FF_PRERELEASE"; 243} 244 245my @mstone = split(/\./,$milestone); 246$mstone[1] =~s/\D.*$//; 247if (!$mstone[2]) { 248 $mstone[2] = "0"; 249} 250else { 251 $mstone[2] =~s/\D.*$//; 252} 253$fileversion = $productversion="$mstone[0],$mstone[1],$mstone[2],$daycount"; 254 255my $copyright = "License: MPL 1.1/GPL 2.0/LGPL 2.1"; 256my $company = "Mozilla Foundation"; 257my $trademarks = "Mozilla"; 258my $productname = $displayname; 259 260 261if (defined($override_comment)){$override_comment =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $comment=$override_comment;} 262if (defined($override_description)){$override_description =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $description=$override_description;} 263if (defined($override_fileversion)){$fileversion=$override_fileversion;} 264if (defined($override_mfversion)){$mfversion=$override_mfversion;} 265if (defined($override_company)){$company=$override_company;} 266if (defined($override_module)){$override_module =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $module=$override_module;} 267if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_copyright;} 268if (defined($override_trademarks)){$override_trademarks =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $trademarks=$override_trademarks;} 269if (defined($override_filename)){$binary=$override_filename;} 270if (defined($override_productname)){$override_productname =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $productname=$override_productname;} 271if (defined($override_productversion)){$productversion=$override_productversion;} 272if (defined($override_mpversion)){$mpversion=$override_mpversion;} 273 274 275#Override section 276 277open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n"); 278print 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 324my $versionlevel=0; 325my $insideversion=0; 326if (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 380my $fileflags = join(' | ', @fileflags); 381 382print RCFILE qq{ 383 384 385///////////////////////////////////////////////////////////////////////////// 386// 387// Version 388// 389 3901 VERSIONINFO 391 FILEVERSION $fileversion 392 PRODUCTVERSION $productversion 393 FILEFLAGSMASK 0x3fL 394 FILEFLAGS $fileflags 395 FILEOS $fileos 396 FILETYPE VFT_DLL 397 FILESUBTYPE 0x0L 398BEGIN 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 420END 421 422}; 423close(RCFILE);