/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/config/version_win.pl

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs · Perl · 423 lines · 312 code · 36 blank · 75 comment · 56 complexity · e1c644e747a1bff78b53a755b55ba223 MD5 · raw file

  1. #!/usr/bin/perl -w
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. #
  5. # The contents of this file are subject to the Mozilla Public License Version
  6. # 1.1 (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. # http://www.mozilla.org/MPL/
  9. #
  10. # Software distributed under the License is distributed on an "AS IS" basis,
  11. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. # for the specific language governing rights and limitations under the
  13. # License.
  14. #
  15. # The Original Code is the Win32 Version System.
  16. #
  17. # The Initial Developer of the Original Code is Brian Bober <netdemonz@yahoo.com>
  18. # Portions created by the Initial Developer are Copyright (C) 2001
  19. # the Initial Developer. All Rights Reserved.
  20. #
  21. # Contributor(s):
  22. #
  23. # Alternatively, the contents of this file may be used under the terms of
  24. # either the GNU General Public License Version 2 or later (the "GPL"), or
  25. # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26. # in which case the provisions of the GPL or the LGPL are applicable instead
  27. # of those above. If you wish to allow use of your version of this file only
  28. # under the terms of either the GPL or the LGPL, and not to allow others to
  29. # use your version of this file under the terms of the MPL, indicate your
  30. # decision by deleting the provisions above and replace them with the notice
  31. # and other provisions required by the GPL or the LGPL. If you do not delete
  32. # the provisions above, a recipient may use your version of this file under
  33. # the terms of any one of the MPL, the GPL or the LGPL.
  34. #
  35. # ***** END LICENSE BLOCK *****
  36. #use diagnostics;
  37. require strict;
  38. my $dir = $0;
  39. $dir =~ s/[^\/]*$//;
  40. push(@INC, "$dir");
  41. require "Moz/Milestone.pm";
  42. use Getopt::Long;
  43. use Getopt::Std;
  44. use POSIX;
  45. # Calculate the number of days since Jan. 1, 2000 from a buildid string
  46. sub daysFromBuildID
  47. {
  48. my ($buildid,) = @_;
  49. my ($y, $m, $d, $h) = ($buildid =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/);
  50. $d || die("Unrecognized buildid string.");
  51. my $secondstodays = 60 * 60 * 24;
  52. return (POSIX::mktime(00, 00, 00, $d, $m, $y - 1900) -
  53. POSIX::mktime(00, 00, 00, 01, 01, 100)) / $secondstodays;
  54. }
  55. #Creates version resource file
  56. #Paramaters are passed on the command line:
  57. #Example: -MODNAME nsToolkitCompsModule -DEBUG=1
  58. # DEBUG - Mozilla's global debug variable - tells if its debug version
  59. # OFFICIAL - tells Mozilla is building a milestone or nightly
  60. # MSTONE - tells which milestone is being built;
  61. # OBJDIR - Holds the object directory;
  62. # MODNAME - tells what the name of the module is like nsBMPModule
  63. # DEPTH - Holds the path to the root obj dir
  64. # TOPSRCDIR - Holds the path to the root mozilla dir
  65. # SRCDIR - Holds module.ver and source
  66. # BINARY - Holds the name of the binary file
  67. # DISPNAME - Holds the display name of the built application
  68. # BITS - 16 or 32 bit
  69. # RCINCLUDE - Holds the name of the RC File to include or ""
  70. # QUIET - Turns off output
  71. #Description and Comment come from module.ver
  72. #Bug 23560
  73. #http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/rc_7x2d.asp
  74. #Get next .ver file entry
  75. sub getNextEntry
  76. {
  77. while (<VERFILE>)
  78. {
  79. my $mline = $_;
  80. ($mline) = split(/#/,$mline);
  81. my ($entry, $value)=split(/=/,$mline,2);
  82. if (defined($entry))
  83. {
  84. if (defined($value))
  85. {
  86. $entry =~ s/^\s*(.*?)\s*$/$1/;
  87. $value =~ s/^\s*(.*?)\s*$/$1/;
  88. return ($entry,$value);
  89. }
  90. }
  91. }
  92. return undef;
  93. }
  94. my ($quiet,$objdir,$debug,$official,$milestone,$buildid,$module,$binary,$depth,$rcinclude,$bits,$srcdir,$fileversion,$productversion);
  95. GetOptions( "QUIET" => \$quiet,
  96. "DEBUG=s" => \$debug,
  97. "OFFICIAL=s" => \$official,
  98. "MSTONE=s" => \$milestone,
  99. "MODNAME=s" => \$module,
  100. "BINARY=s" => \$binary,
  101. "DISPNAME=s" => \$displayname,
  102. "SRCDIR=s" => \$srcdir,
  103. "TOPSRCDIR=s" => \$topsrcdir,
  104. "DEPTH=s" => \$depth,
  105. "RCINCLUDE=s" => \$rcinclude,
  106. "OBJDIR=s" => \$objdir,
  107. "BITS=s" => \$bits);
  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($displayname)) {$displayname="Mozilla";}
  114. if (!defined($depth)) {$depth=".";}
  115. if (!defined($rcinclude)) {$rcinclude="";}
  116. if (!defined($objdir)) {$objdir=".";}
  117. if (!defined($srcdir)) {$srcdir=".";}
  118. if (!defined($topsrcdir)) {$topsrcdir=".";}
  119. if (!defined($bits)) {$bits="";}
  120. my $mfversion = "Personal";
  121. my $mpversion = "Personal";
  122. my @fileflags = ("0");
  123. my $comment="";
  124. my $description="";
  125. if (!defined($module))
  126. {
  127. $module = $binary;
  128. ($module) = split(/\./,$module);
  129. }
  130. my $fileos = "VOS__WINDOWS32";
  131. if ($bits eq "16") { $fileos="VOS__WINDOWS16"; }
  132. my $bufferstr=" ";
  133. my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
  134. my $BUILDID_FILE = "$depth/config/buildid";
  135. #Read module.ver file
  136. #Version file overrides for WIN32:
  137. #WIN32_MODULE_COMMENT
  138. #WIN32_MODULE_DESCRIPTION
  139. #WIN32_MODULE_FILEVERSION
  140. #WIN32_MODULE_COMPANYNAME
  141. #WIN32_MODULE_FILEVERSION_STRING
  142. #WIN32_MODULE_NAME
  143. #WIN32_MODULE_COPYRIGHT
  144. #WIN32_MODULE_TRADEMARKS
  145. #WIN32_MODULE_ORIGINAL_FILENAME
  146. #WIN32_MODULE_PRODUCTNAME
  147. #WIN32_MODULE_PRODUCTVERSION
  148. #WIN32_MODULE_PRODUCTVERSION_STRING
  149. #Override values obtained from the .ver file
  150. my $override_comment;
  151. my $override_description;
  152. my $override_fileversion;
  153. my $override_company;
  154. my $override_mfversion;
  155. my $override_module;
  156. my $override_copyright;
  157. my $override_trademarks;
  158. my $override_filename;
  159. my $override_productname;
  160. my $override_productversion;
  161. my $override_mpversion;
  162. if (open(VERFILE, "<$srcdir/module.ver"))
  163. {
  164. my ($a,$b) = getNextEntry();
  165. while (defined($a))
  166. {
  167. if ($a eq "WIN32_MODULE_COMMENT") { $override_comment = $b; }
  168. if ($a eq "WIN32_MODULE_DESCRIPTION") { $override_description = $b; }
  169. if ($a eq "WIN32_MODULE_FILEVERSION") { $override_fileversion = $b; }
  170. if ($a eq "WIN32_MODULE_COMPANYNAME") { $override_company = $b; }
  171. if ($a eq "WIN32_MODULE_FILEVERSION_STRING") { $override_mfversion = $b; }
  172. if ($a eq "WIN32_MODULE_NAME") { $override_module = $b; }
  173. if ($a eq "WIN32_MODULE_COPYRIGHT") { $override_copyright = $b; }
  174. if ($a eq "WIN32_MODULE_TRADEMARKS") { $override_trademarks = $b; }
  175. if ($a eq "WIN32_MODULE_ORIGINAL_FILENAME") { $override_filename = $b; }
  176. if ($a eq "WIN32_MODULE_PRODUCTNAME") { $override_productname = $b; }
  177. if ($a eq "WIN32_MODULE_PRODUCTVERSION") { $override_productversion = $b; }
  178. if ($a eq "WIN32_MODULE_PRODUCTVERSION_STRING") { $override_mpversion = $b; }
  179. ($a,$b) = getNextEntry();
  180. }
  181. close(VERFILE)
  182. }
  183. else
  184. {
  185. if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; }
  186. }
  187. #Get rid of trailing and leading whitespace
  188. $debug =~ s/^\s*(.*)\s*$/$1/;
  189. $comment =~ s/^\s*(.*)\s*$/$1/;
  190. $official =~ s/^\s*(.*)\s*$/$1/;
  191. $milestone =~ s/^\s*(.*)\s*$/$1/;
  192. $description =~ s/^\s*(.*)\s*$/$1/;
  193. $module =~ s/^\s*(.*)\s*$/$1/;
  194. $depth =~ s/^\s*(.*)\s*$/$1/;
  195. $binary =~ s/^\s*(.*)\s*$/$1/;
  196. $displayname =~ s/^\s*(.*)\s*$/$1/;
  197. open(BUILDID, "<", $BUILDID_FILE) || die("Couldn't open buildid file: $BUILDID_FILE");
  198. $buildid = <BUILDID>;
  199. $buildid =~ s/\s*$//;
  200. close BUILDID;
  201. my $daycount = daysFromBuildID($buildid);
  202. if ($milestone eq "") {
  203. $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
  204. }
  205. $mfversion = $mpversion = $milestone;
  206. if ($debug eq "1")
  207. {
  208. push @fileflags, "VS_FF_DEBUG";
  209. $mpversion .= " Debug";
  210. $mfversion .= " Debug";
  211. }
  212. if ($official ne "1") {
  213. push @fileflags, "VS_FF_PRIVATEBUILD";
  214. }
  215. if ($milestone =~ /[a-z]/) {
  216. push @fileflags, "VS_FF_PRERELEASE";
  217. }
  218. my @mstone = split(/\./,$milestone);
  219. $mstone[1] =~s/\D.*$//;
  220. if (!$mstone[2]) {
  221. $mstone[2] = "0";
  222. }
  223. else {
  224. $mstone[2] =~s/\D.*$//;
  225. }
  226. $fileversion = $productversion="$mstone[0],$mstone[1],$mstone[2],$daycount";
  227. my $copyright = "License: MPL 1.1/GPL 2.0/LGPL 2.1";
  228. my $company = "Mozilla Foundation";
  229. my $trademarks = "Mozilla";
  230. my $productname = $displayname;
  231. if (defined($override_comment)){$override_comment =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $comment=$override_comment;}
  232. if (defined($override_description)){$override_description =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $description=$override_description;}
  233. if (defined($override_fileversion)){$fileversion=$override_fileversion;}
  234. if (defined($override_mfversion)){$mfversion=$override_mfversion;}
  235. if (defined($override_company)){$company=$override_company;}
  236. if (defined($override_module)){$override_module =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $module=$override_module;}
  237. if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_copyright;}
  238. if (defined($override_trademarks)){$override_trademarks =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $trademarks=$override_trademarks;}
  239. if (defined($override_filename)){$binary=$override_filename;}
  240. if (defined($override_productname)){$override_productname =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $productname=$override_productname;}
  241. if (defined($override_productversion)){$productversion=$override_productversion;}
  242. if (defined($override_mpversion)){$mpversion=$override_mpversion;}
  243. #Override section
  244. open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n");
  245. print RCFILE qq{
  246. // ***** BEGIN LICENSE BLOCK *****
  247. // Version: MPL 1.1/GPL 2.0/LGPL 2.1
  248. //
  249. // The contents of this file are subject to the Mozilla Public License Version
  250. // 1.1 (the "License"); you may not use this file except in compliance with
  251. // the License. You may obtain a copy of the License at
  252. // http://www.mozilla.org/MPL/
  253. //
  254. // Software distributed under the License is distributed on an "AS IS" basis,
  255. // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  256. // for the specific language governing rights and limitations under the
  257. // License.
  258. //
  259. // The Original Code is the Win32 Version System.
  260. //
  261. // The Initial Developer of the Original Code is Brian Bober <netdemonz\@yahoo.com>
  262. // Portions created by the Initial Developer are Copyright (C) 2001
  263. // the Initial Developer. All Rights Reserved.
  264. //
  265. // Contributor(s):
  266. //
  267. // Alternatively, the contents of this file may be used under the terms of
  268. // either the GNU General Public License Version 2 or later (the "GPL"), or
  269. // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  270. // in which case the provisions of the GPL or the LGPL are applicable instead
  271. // of those above. If you wish to allow use of your version of this file only
  272. // under the terms of either the GPL or the LGPL, and not to allow others to
  273. // use your version of this file under the terms of the MPL, indicate your
  274. // decision by deleting the provisions above and replace them with the notice
  275. // and other provisions required by the GPL or the LGPL. If you do not delete
  276. // the provisions above, a recipient may use your version of this file under
  277. // the terms of any one of the MPL, the GPL or the LGPL.
  278. //
  279. // ***** END LICENSE BLOCK *****
  280. #include<winver.h>
  281. // Note: if you contain versioning information in an included
  282. // RC script, it will be discarded
  283. // Use module.ver to explicitly set these values
  284. // Do not edit this file. Changes won't affect the build.
  285. };
  286. my $versionlevel=0;
  287. my $insideversion=0;
  288. if (open(RCINCLUDE, "<$rcinclude"))
  289. {
  290. print RCFILE "// From included resource $rcinclude\n";
  291. # my $mstring="";
  292. while (<RCINCLUDE>)
  293. {
  294. $_ =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g;
  295. print RCFILE $_;
  296. # my $instr=$_;
  297. # chomp($instr);
  298. # $mstring .= "$instr\;";
  299. }
  300. close(RCINCLUDE);
  301. # $mstring =~ s/\/\*.*\*\///g;
  302. # my @mlines = split(/\;/,$mstring);
  303. # for(@mlines)
  304. # {
  305. # my ($nocomment)=split(/\/\//,$_);
  306. # if (defined($nocomment) && $nocomment ne "")
  307. # {
  308. # my ($firststring,$secondstring) = split(/\s+/,$nocomment);
  309. # if (!defined($firststring)) {$firststring="";}
  310. # if (!defined($secondstring)) {$secondstring="";}
  311. # if ($secondstring eq "VERSIONINFO")
  312. # {
  313. #if (!$quiet || $quiet ne "1") {
  314. # print "$bufferstr" . "WARNING: Included RC file ($rcinclude, $module, $binary)\n";
  315. # print "$bufferstr" . "WARNING: contains versioning information that will be discarded\n";
  316. # print "$bufferstr" . "WARNING: Remove it and use relevant overrides (in module.ver)\n";
  317. #}
  318. # $versionlevel = 0;
  319. # $insideversion = 1;
  320. # }
  321. # if ($firststring eq "BEGIN") { $versionlevel++; }
  322. # if ($secondstring eq "END")
  323. # {
  324. # $versionlevel--;
  325. # if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;}
  326. # }
  327. # my $includecheck = $firststring . $secondstring;
  328. # $includecheck =~ s/<|>/"/g;
  329. # $includecheck = lc($includecheck);
  330. # if ($includecheck ne "#include\"winver.h\"")
  331. # {
  332. # if ($insideversion == 0 && $versionlevel == 0)
  333. # {
  334. # print RCFILE "$nocomment\n";
  335. # }
  336. # }
  337. # }
  338. # }
  339. }
  340. my $fileflags = join(' | ', @fileflags);
  341. print RCFILE qq{
  342. /////////////////////////////////////////////////////////////////////////////
  343. //
  344. // Version
  345. //
  346. 1 VERSIONINFO
  347. FILEVERSION $fileversion
  348. PRODUCTVERSION $productversion
  349. FILEFLAGSMASK 0x3fL
  350. FILEFLAGS $fileflags
  351. FILEOS $fileos
  352. FILETYPE VFT_DLL
  353. FILESUBTYPE 0x0L
  354. BEGIN
  355. BLOCK "StringFileInfo"
  356. BEGIN
  357. BLOCK "000004b0"
  358. BEGIN
  359. VALUE "Comments", "$comment"
  360. VALUE "LegalCopyright", "$copyright"
  361. VALUE "CompanyName", "$company"
  362. VALUE "FileDescription", "$description"
  363. VALUE "FileVersion", "$mfversion"
  364. VALUE "ProductVersion", "$mpversion"
  365. VALUE "InternalName", "$module"
  366. VALUE "LegalTrademarks", "$trademarks"
  367. VALUE "OriginalFilename", "$binary"
  368. VALUE "ProductName", "$productname"
  369. VALUE "BuildID", "$buildid"
  370. END
  371. END
  372. BLOCK "VarFileInfo"
  373. BEGIN
  374. VALUE "Translation", 0x0, 1200
  375. END
  376. END
  377. };
  378. close(RCFILE);