~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/config/version_win.pl

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;
 
39
require strict;
 
40
my $dir = $0;
 
41
$dir =~ s/[^\/]*$//;
 
42
push(@INC, "$dir");
 
43
require "Moz/Milestone.pm";
 
44
use Getopt::Long;
 
45
use Getopt::Std;
 
46
 
 
47
#Creates version resource file
 
48
 
 
49
#Paramaters are passed on the command line:
 
50
 
 
51
#Example: -PBI=blah -DEBUG=1
 
52
 
 
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
 
63
# BITS - 16 or 32 bit
 
64
# RCINCLUDE - Holds the name of the RC File to include or ""
 
65
# QUIET - Turns off output
 
66
 
 
67
#Description and Comment come from module.ver
 
68
#Bug 23560
 
69
#http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/rc_7x2d.asp
 
70
 
 
71
#Get next .ver file entry
 
72
sub getNextEntry
 
73
{
 
74
        while (<VERFILE>) 
 
75
        { 
 
76
                my $mline = $_;
 
77
                ($mline) = split(/#/,$mline);
 
78
                my ($entry, $value)=split(/=/,$mline,2);
 
79
                if (defined($entry))
 
80
                {
 
81
                        if (defined($value))
 
82
                        {
 
83
                                $entry =~ s/^\s*(.*?)\s*$/$1/;
 
84
                                $value =~ s/^\s*(.*?)\s*$/$1/;
 
85
                                return ($entry,$value);
 
86
                        }
 
87
                }
 
88
        }
 
89
        return undef;
 
90
}
 
91
 
 
92
my ($quiet,$privateinfo,$objdir,$debug,$official,$milestone,$module,$binary,$depth,$rcinclude,$bits,$srcdir);
 
93
 
 
94
GetOptions( "QUIET" => \$quiet,
 
95
                "PBI=s" => \$privateinfo,
 
96
                "DEBUG=s" => \$debug,
 
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,
 
106
                "BITS=s" => \$bits);
 
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";
 
122
my $comment="";
 
123
my $description="";
 
124
if (!defined($module))
 
125
{
 
126
        $module = $binary;
 
127
        ($module) = split(/\./,$module);
 
128
}
 
129
 
 
130
my $productversion = "0,0,0,0";
 
131
my $fileversion = $productversion;
 
132
my $fileos = "VOS__WINDOWS32";
 
133
if ($bits eq "16") { $fileos="VOS__WINDOWS16"; }
 
134
 
 
135
my $bufferstr="    ";
 
136
 
 
137
my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
 
138
my $BUILDID_FILE = "$depth/config/build_number";
 
139
 
 
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
 
147
#WIN32_MODULE_NAME
 
148
#WIN32_MODULE_COPYRIGHT
 
149
#WIN32_MODULE_TRADEMARKS
 
150
#WIN32_MODULE_ORIGINAL_FILENAME
 
151
#WIN32_MODULE_PRODUCTNAME
 
152
 
 
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;
 
159
my $override_module;
 
160
my $override_copyright;
 
161
my $override_trademarks;
 
162
my $override_filename;
 
163
my $override_productname;
 
164
if (open(VERFILE, "<$srcdir/module.ver")) 
 
165
{
 
166
 
 
167
        my ($a,$b) = getNextEntry();
 
168
        while (defined($a))
 
169
        {
 
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();
 
181
        }
 
182
        close(VERFILE)
 
183
}
 
184
else
 
185
{
 
186
        if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; }
 
187
}
 
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/;
 
198
 
 
199
if ($debug eq "1")
 
200
{
 
201
        $fileflags .= " | VS_FF_DEBUG";
 
202
        $mpversion .= " Debug";
 
203
        $mfversion .= " Debug";
 
204
}
 
205
 
 
206
if ($official eq "1") {
 
207
        #its an official build
 
208
        $privateinfo = "";
 
209
        $fileflags = "VS_FF_PRERELEASE";
 
210
        if ($debug eq "1") {
 
211
                $fileflags = "VS_FF_PRERELEASE | VS_FF_DEBUG";
 
212
        }
 
213
 
 
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);
 
221
        }
 
222
 
 
223
        if ($milestone ne "" && $milestone !~ /\+$/) {
 
224
                #its a milestone build
 
225
 
 
226
                $mpversion = $milestone;
 
227
 
 
228
                $fileflags = "0";
 
229
              
 
230
                my @mstone = split(/\./,$milestone);
 
231
                $mstone[1] =~s/\D*$//g;
 
232
                $productversion="$mstone[0],$mstone[1],0,0";
 
233
 
 
234
        }
 
235
 
 
236
        my ($buildid, $buildid_hi, $buildid_lo);
 
237
        open(NUMBER, "<$BUILDID_FILE") || die "No build number file\n";
 
238
        while ( <NUMBER> ) { $buildid = $_ }
 
239
        close (NUMBER);
 
240
        $buildid =~ s/^\s*(.*)\s*$/$1/;
 
241
        $buildid_hi = substr($buildid, 0, 5);
 
242
        $buildid_lo = substr($buildid, 5);
 
243
 
 
244
        $mfversion = $mpversion = "$milestone: $buildid";
 
245
        my @pvarray = split(',', $productversion);
 
246
        $fileversion = "$pvarray[0],$pvarray[1],$buildid_hi,$buildid_lo";
 
247
}
 
248
 
 
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";
 
253
 
 
254
 
 
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;}
 
265
 
 
266
 
 
267
#Override section
 
268
 
 
269
open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n");
 
270
print RCFILE qq{
 
271
// ***** BEGIN LICENSE BLOCK *****
 
272
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
273
//
 
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/
 
278
//
 
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
 
282
// License.
 
283
//
 
284
// The Original Code is the Win32 Version System.
 
285
//
 
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.
 
289
//
 
290
// Contributor(s):
 
291
//
 
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.
 
303
//
 
304
// ***** END LICENSE BLOCK *****
 
305
 
 
306
#include<winver.h>
 
307
 
 
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
 
311
 
 
312
// Do not edit this file. Changes won't affect the build.
 
313
 
 
314
};
 
315
 
 
316
my $versionlevel=0;
 
317
my $insideversion=0;
 
318
if (open(RCINCLUDE, "<$rcinclude")) 
 
319
{
 
320
        print RCFILE "// From included resource $rcinclude\n";
 
321
#       my $mstring="";
 
322
        while (<RCINCLUDE>) 
 
323
        {
 
324
                print RCFILE $_;
 
325
#               my $instr=$_;
 
326
#               chomp($instr);
 
327
#               $mstring .= "$instr\;";
 
328
        }
 
329
        close(RCINCLUDE);
 
330
#       $mstring =~ s/\/\*.*\*\///g;
 
331
#       my @mlines = split(/\;/,$mstring);
 
332
#       for(@mlines)
 
333
#       {
 
334
#               my ($nocomment)=split(/\/\//,$_);
 
335
#               if (defined($nocomment) && $nocomment ne "")
 
336
#               {
 
337
#                       my ($firststring,$secondstring) = split(/\s+/,$nocomment);
 
338
#                       if (!defined($firststring)) {$firststring="";}
 
339
#                       if (!defined($secondstring)) {$secondstring="";}
 
340
#                       if ($secondstring eq "VERSIONINFO") 
 
341
#                       {
 
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";
 
346
#}
 
347
#                               $versionlevel = 0;
 
348
#                               $insideversion = 1; 
 
349
#                       }
 
350
#                       if ($firststring eq "BEGIN") { $versionlevel++; }
 
351
#                       if ($secondstring eq "END") 
 
352
#                       { 
 
353
#                               $versionlevel--; 
 
354
#                               if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;}
 
355
#                       }
 
356
#                       my $includecheck = $firststring . $secondstring;
 
357
#                       $includecheck =~ s/<|>/"/g;
 
358
#                       $includecheck = lc($includecheck);
 
359
#                       if ($includecheck ne "#include\"winver.h\"")
 
360
#                       {
 
361
#                               if ($insideversion == 0 && $versionlevel == 0)
 
362
#                               {
 
363
#                                       print RCFILE "$nocomment\n";    
 
364
#                               }
 
365
#                       }
 
366
#               }
 
367
#       }
 
368
        
 
369
}
 
370
 
 
371
print RCFILE qq{
 
372
 
 
373
 
 
374
/////////////////////////////////////////////////////////////////////////////
 
375
//
 
376
// Version
 
377
//
 
378
 
 
379
1 VERSIONINFO
 
380
 FILEVERSION $fileversion
 
381
 PRODUCTVERSION $productversion
 
382
 FILEFLAGSMASK 0x3fL
 
383
 FILEFLAGS $fileflags
 
384
 FILEOS $fileos
 
385
 FILETYPE VFT_DLL
 
386
 FILESUBTYPE 0x0L
 
387
BEGIN
 
388
    BLOCK "StringFileInfo"
 
389
    BEGIN
 
390
        BLOCK "000004b0"
 
391
        BEGIN
 
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"
 
401
};
 
402
if ($official ne "1") {
 
403
print RCFILE qq{
 
404
            VALUE "PrivateBuild", "$privateinfo"
 
405
};
 
406
}
 
407
print RCFILE qq{
 
408
            VALUE "ProductName", "$productname"
 
409
        END
 
410
    END
 
411
    BLOCK "VarFileInfo"
 
412
    BEGIN
 
413
        VALUE "Translation", 0x0, 1200
 
414
    END
 
415
END
 
416
 
 
417
};
 
418
close(RCFILE);