~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to mozilla/config/version_win.pl

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
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/.
 
6
 
 
7
#use diagnostics;
 
8
require strict;
 
9
my $dir = $0;
 
10
$dir =~ s/[^\/]*$//;
 
11
push(@INC, "$dir");
 
12
require "Moz/Milestone.pm";
 
13
use Getopt::Long;
 
14
use Getopt::Std;
 
15
use POSIX;
 
16
 
 
17
# Calculate the number of days since Jan. 1, 2000 from a buildid string
 
18
sub daysFromBuildID
 
19
{
 
20
    my ($buildid,) = @_;
 
21
 
 
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.");
 
24
 
 
25
    my $secondstodays = 60 * 60 * 24;
 
26
    return sprintf("%d",
 
27
                   (POSIX::mktime(00, 00, 00, $d, $m - 1, $y - 1900) -
 
28
                    POSIX::mktime(00, 00, 00, 01, 00, 100)) / $secondstodays);
 
29
}
 
30
 
 
31
#Creates version resource file
 
32
 
 
33
#Paramaters are passed on the command line:
 
34
 
 
35
#Example: -MODNAME nsToolkitCompsModule -DEBUG=1
 
36
 
 
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
 
50
 
 
51
#Description and Comment come from module.ver
 
52
#Bug 23560
 
53
#http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/rc_7x2d.asp
 
54
 
 
55
#Get next .ver file entry
 
56
sub getNextEntry
 
57
{
 
58
        while (<VERFILE>) 
 
59
        { 
 
60
                my $mline = $_;
 
61
                ($mline) = split(/#/,$mline);
 
62
                my ($entry, $value)=split(/=/,$mline,2);
 
63
                if (defined($entry))
 
64
                {
 
65
                        if (defined($value))
 
66
                        {
 
67
                                $entry =~ s/^\s*(.*?)\s*$/$1/;
 
68
                                $value =~ s/^\s*(.*?)\s*$/$1/;
 
69
                                return ($entry,$value);
 
70
                        }
 
71
                }
 
72
        }
 
73
        return undef;
 
74
}
 
75
 
 
76
my ($quiet,$objdir,$debug,$official,$milestone,$buildid,$module,$binary,$depth,$rcinclude,$srcdir,$fileversion,$productversion);
 
77
 
 
78
GetOptions( "QUIET" => \$quiet,
 
79
                "DEBUG=s" => \$debug,
 
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,
 
88
                "DEPTH=s" => \$depth,
 
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");
 
106
my $comment="";
 
107
my $description="";
 
108
if (!defined($module))
 
109
{
 
110
        $module = $binary;
 
111
        ($module) = split(/\./,$module);
 
112
}
 
113
 
 
114
my $bufferstr="    ";
 
115
 
 
116
my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
 
117
my $BUILDID_FILE = "$depth/config/buildid";
 
118
 
 
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
 
126
#WIN32_MODULE_NAME
 
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
 
133
 
 
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;
 
140
my $override_module;
 
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")) 
 
148
{
 
149
 
 
150
        my ($a,$b) = getNextEntry();
 
151
        while (defined($a))
 
152
        {
 
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();
 
166
        }
 
167
        close(VERFILE)
 
168
}
 
169
else
 
170
{
 
171
        if (!$quiet || $quiet ne "1") { print "$bufferstr" . "WARNING: No module.ver file included ($module, $binary). Default values used\n"; }
 
172
}
 
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/;
 
183
 
 
184
open(BUILDID, "<", $BUILDID_FILE) || die("Couldn't open buildid file: $BUILDID_FILE");
 
185
$buildid = <BUILDID>;
 
186
$buildid =~ s/\s*$//;
 
187
close BUILDID;
 
188
 
 
189
my $daycount = daysFromBuildID($buildid);
 
190
 
 
191
if ($milestone eq "") {
 
192
    $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
 
193
}
 
194
 
 
195
$mfversion = $mpversion = $milestone;
 
196
if ($appversion eq "") {
 
197
  $appversion = $milestone;
 
198
}
 
199
 
 
200
if ($debug eq "1")
 
201
{
 
202
        push @fileflags, "VS_FF_DEBUG";
 
203
        $mpversion .= " Debug";
 
204
        $mfversion .= " Debug";
 
205
}
 
206
 
 
207
if ($official ne "1") {
 
208
    push @fileflags, "VS_FF_PRIVATEBUILD";
 
209
}
 
210
 
 
211
if ($milestone =~ /[a-z]/) {
 
212
    push @fileflags, "VS_FF_PRERELEASE";
 
213
}
 
214
 
 
215
my @mstone = split(/\./,$milestone);
 
216
$mstone[1] =~s/\D.*$//;
 
217
if (!$mstone[2]) {
 
218
    $mstone[2] = "0";
 
219
}
 
220
else {
 
221
    $mstone[2] =~s/\D.*$//;
 
222
}
 
223
$fileversion = $productversion="$mstone[0],$mstone[1],$mstone[2],$daycount";
 
224
 
 
225
my @appver = split(/\./,$appversion);
 
226
for ($j = 1; $j < 4; $j++)
 
227
{
 
228
    if (!$appver[$j]) {
 
229
        $appver[$j] = "0";
 
230
    }
 
231
    else {
 
232
        $appver[$j] =~s/\D.*$//;
 
233
    }
 
234
}
 
235
my $winappversion = "$appver[0],$appver[1],$appver[2],$appver[3]";
 
236
 
 
237
my $copyright = "License: MPL 1.1/GPL 2.0/LGPL 2.1";
 
238
my $company = "Mozilla Foundation";
 
239
my $trademarks = "Mozilla";
 
240
my $productname = $displayname;
 
241
 
 
242
 
 
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;}
 
255
 
 
256
 
 
257
#Override section
 
258
 
 
259
open(RCFILE, ">$objdir/module.rc") || die("Can't edit module.rc - It must be locked.\n");
 
260
print RCFILE qq{
 
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/.
 
264
 
 
265
#include<winver.h>
 
266
 
 
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
 
270
 
 
271
// Do not edit this file. Changes won't affect the build.
 
272
 
 
273
};
 
274
 
 
275
my $versionlevel=0;
 
276
my $insideversion=0;
 
277
if (open(RCINCLUDE, "<$rcinclude")) 
 
278
{
 
279
        print RCFILE "// From included resource $rcinclude\n";
 
280
#       my $mstring="";
 
281
        while (<RCINCLUDE>) 
 
282
        {
 
283
                $_ =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g;
 
284
                print RCFILE $_;
 
285
#               my $instr=$_;
 
286
#               chomp($instr);
 
287
#               $mstring .= "$instr\;";
 
288
        }
 
289
        close(RCINCLUDE);
 
290
#       $mstring =~ s/\/\*.*\*\///g;
 
291
#       my @mlines = split(/\;/,$mstring);
 
292
#       for(@mlines)
 
293
#       {
 
294
#               my ($nocomment)=split(/\/\//,$_);
 
295
#               if (defined($nocomment) && $nocomment ne "")
 
296
#               {
 
297
#                       my ($firststring,$secondstring) = split(/\s+/,$nocomment);
 
298
#                       if (!defined($firststring)) {$firststring="";}
 
299
#                       if (!defined($secondstring)) {$secondstring="";}
 
300
#                       if ($secondstring eq "VERSIONINFO") 
 
301
#                       {
 
302
#if (!$quiet || $quiet ne "1") { 
 
303
#                               print "$bufferstr" . "WARNING: Included RC file ($rcinclude, $module, $binary)\n";
 
304
#                               print "$bufferstr" . "WARNING: contains versioning information that will be discarded\n";
 
305
#                               print "$bufferstr" . "WARNING: Remove it and use relevant overrides (in module.ver)\n";
 
306
#}
 
307
#                               $versionlevel = 0;
 
308
#                               $insideversion = 1; 
 
309
#                       }
 
310
#                       if ($firststring eq "BEGIN") { $versionlevel++; }
 
311
#                       if ($secondstring eq "END") 
 
312
#                       { 
 
313
#                               $versionlevel--; 
 
314
#                               if ($insideversion==1 && $versionlevel==0) {$versionlevel=0;}
 
315
#                       }
 
316
#                       my $includecheck = $firststring . $secondstring;
 
317
#                       $includecheck =~ s/<|>/"/g;
 
318
#                       $includecheck = lc($includecheck);
 
319
#                       if ($includecheck ne "#include\"winver.h\"")
 
320
#                       {
 
321
#                               if ($insideversion == 0 && $versionlevel == 0)
 
322
#                               {
 
323
#                                       print RCFILE "$nocomment\n";    
 
324
#                               }
 
325
#                       }
 
326
#               }
 
327
#       }
 
328
        
 
329
}
 
330
 
 
331
my $fileflags = join(' | ', @fileflags);
 
332
 
 
333
print RCFILE qq{
 
334
 
 
335
 
 
336
/////////////////////////////////////////////////////////////////////////////
 
337
//
 
338
// Version
 
339
//
 
340
 
 
341
1 VERSIONINFO
 
342
 FILEVERSION    $fileversion
 
343
 PRODUCTVERSION $productversion
 
344
 FILEFLAGSMASK 0x3fL
 
345
 FILEFLAGS $fileflags
 
346
 FILEOS VOS__WINDOWS32
 
347
 FILETYPE VFT_DLL
 
348
 FILESUBTYPE 0x0L
 
349
BEGIN
 
350
    BLOCK "StringFileInfo"
 
351
    BEGIN
 
352
        BLOCK "000004b0"
 
353
        BEGIN
 
354
            VALUE "Comments", "$comment"
 
355
            VALUE "LegalCopyright", "$copyright"
 
356
            VALUE "CompanyName", "$company"
 
357
            VALUE "FileDescription", "$description"
 
358
            VALUE "FileVersion", "$mfversion"
 
359
            VALUE "ProductVersion", "$mpversion"
 
360
            VALUE "InternalName", "$module"
 
361
            VALUE "LegalTrademarks", "$trademarks"
 
362
            VALUE "OriginalFilename", "$binary"
 
363
            VALUE "ProductName", "$productname"
 
364
            VALUE "BuildID", "$buildid"
 
365
        END
 
366
    END
 
367
    BLOCK "VarFileInfo"
 
368
    BEGIN
 
369
        VALUE "Translation", 0x0, 1200
 
370
    END
 
371
END
 
372
 
 
373
};
 
374
close(RCFILE);