Skip to content

Commit

Permalink
Bug 386740 - Windows file versions are incorrect, r=luser
Browse files Browse the repository at this point in the history
  • Loading branch information
bsmedberg committed Jan 14, 2008
1 parent d146e7d commit d4a93bc
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 62 deletions.
9 changes: 9 additions & 0 deletions config/Makefile.in
Expand Up @@ -105,6 +105,15 @@ ifdef HOST_PROGRAM
$(INSTALL) $(HOST_PROGRAM) $(DIST)/bin
endif

# Generate a new buildid every time we "export" in config... that's only
# supposed to be once per-build!
export::
ifdef MOZ_BUILD_DATE
printf "%s" $(MOZ_BUILD_DATE) > buildid
else
$(PYTHON) $(topsrcdir)/toolkit/xre/make-platformini.py --print-buildid > buildid
endif

ifdef WRAP_SYSTEM_INCLUDES
export::
if test ! -d system_wrappers; then mkdir system_wrappers; fi
Expand Down
12 changes: 1 addition & 11 deletions config/version.mk
Expand Up @@ -36,8 +36,6 @@
ifndef INCLUDED_VERSION_MK
INCLUDED_VERSION_MK=1



# Windows gmake build:
# Build default .rc file if $(RESFILE) isn't defined.
# TODO:
Expand Down Expand Up @@ -78,18 +76,10 @@ GARBAGE += $(RESFILE) $(RCFILE)
#dummy target so $(RCFILE) doesn't become the default =P
all::

$(RCFILE): $(RCINCLUDE)
$(RCFILE): $(RCINCLUDE) $(topsrcdir)/config/version_win.pl
$(PERL) $(topsrcdir)/config/version_win.pl $(_RC_STRING)

endif # RESFILE
endif # Windows


ifdef VERSION_TMPL
GARBAGE += $(VERSION_TMPL)

export::
$(PERL) $(topsrcdir)/config/milestone.pl --topsrcdir $(topsrcdir) --objdir . --srcdir $(srcdir) --template $(VERSION_TMPL)
endif

endif
98 changes: 51 additions & 47 deletions config/version_win.pl
Expand Up @@ -43,14 +43,27 @@
require "Moz/Milestone.pm";
use Getopt::Long;
use Getopt::Std;
use POSIX;

# Calculate the number of days since Jan. 1, 2000 from a buildid string
sub daysFromBuildID
{
my ($buildid,) = @_;

my ($y, $m, $d, $h) = ($buildid =~ /^(\d{4})(\d{2})(\d{2})(\d{2})$/);
$d || die("Unrecognized buildid string.");

my $secondstodays = 60 * 60 * 24;
return (POSIX::mktime(00, 00, 00, $d, $m, $y - 1900) -
POSIX::mktime(00, 00, 00, 01, 01, 100)) / $secondstodays;
}

#Creates version resource file

#Paramaters are passed on the command line:

#Example: -PBI=blah -DEBUG=1
#Example: -MODNAME nsToolkitCompsModule -DEBUG=1

# PBI - your private build information (if not a milestone or nightly)
# DEBUG - Mozilla's global debug variable - tells if its debug version
# OFFICIAL - tells Mozilla is building a milestone or nightly
# MSTONE - tells which milestone is being built;
Expand Down Expand Up @@ -90,10 +103,9 @@ sub getNextEntry
return undef;
}

my ($quiet,$privateinfo,$objdir,$debug,$official,$milestone,$module,$binary,$depth,$rcinclude,$bits,$srcdir);
my ($quiet,$objdir,$debug,$official,$milestone,$buildid,$module,$binary,$depth,$rcinclude,$bits,$srcdir,$fileversion,$productversion);

GetOptions( "QUIET" => \$quiet,
"PBI=s" => \$privateinfo,
"DEBUG=s" => \$debug,
"OFFICIAL=s" => \$official,
"MSTONE=s" => \$milestone,
Expand All @@ -106,7 +118,6 @@ sub getNextEntry
"RCINCLUDE=s" => \$rcinclude,
"OBJDIR=s" => \$objdir,
"BITS=s" => \$bits);
if (!defined($privateinfo)) {$privateinfo="";}
if (!defined($debug)) {$debug="";}
if (!defined($official)) {$official="";}
if (!defined($milestone)) {$milestone="";}
Expand All @@ -121,7 +132,7 @@ sub getNextEntry
if (!defined($bits)) {$bits="";}
my $mfversion = "Personal";
my $mpversion = "Personal";
my $fileflags = "VS_FF_PRIVATEBUILD";
my @fileflags = ("0");
my $comment="";
my $description="";
if (!defined($module))
Expand All @@ -130,14 +141,13 @@ sub getNextEntry
($module) = split(/\./,$module);
}

my $productversion = "0,0,0,0";
my $fileversion = $productversion;
my $fileos = "VOS__WINDOWS32";
if ($bits eq "16") { $fileos="VOS__WINDOWS16"; }

my $bufferstr=" ";

my $MILESTONE_FILE = "$topsrcdir/config/milestone.txt";
my $BUILDID_FILE = "$depth/config/buildid";

#Read module.ver file
#Version file overrides for WIN32:
Expand Down Expand Up @@ -201,49 +211,46 @@ sub getNextEntry
$description =~ s/^\s*(.*)\s*$/$1/;
$module =~ s/^\s*(.*)\s*$/$1/;
$depth =~ s/^\s*(.*)\s*$/$1/;
$privateinfo =~ s/^\s*(.*)\s*$/$1/;
$binary =~ s/^\s*(.*)\s*$/$1/;
$displayname =~ s/^\s*(.*)\s*$/$1/;

open(BUILDID, "<", $BUILDID_FILE) || die("Couldn't open buildid file: $BUILDID_FILE");
$buildid = <BUILDID>;
$buildid =~ s/\s*$//;
close BUILDID;

my $daycount = daysFromBuildID($buildid);

if ($milestone eq "") {
$milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
}

$mfversion = $mpversion = $milestone;

if ($debug eq "1")
{
$fileflags .= " | VS_FF_DEBUG";
push @fileflags, "VS_FF_DEBUG";
$mpversion .= " Debug";
$mfversion .= " Debug";
}

if ($official eq "1") {
#its an official build
$privateinfo = "";
$fileflags = "VS_FF_PRERELEASE";
if ($debug eq "1") {
$fileflags = "VS_FF_PRERELEASE | VS_FF_DEBUG";
}

# Try to grab milestone.
# I'd love to put this in the makefiles rather than here,
# since I could run it once per build rather than once per
# dll/program, but I can't seem to get backticks working
# properly in the makefiles =P
if ($milestone eq "") {
$milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
}

if ($milestone ne "" && $milestone !~ /\+$/) {
#its a milestone build

$mpversion = $milestone;

$fileflags = "0";

my @mstone = split(/\./,$milestone);
$mstone[1] =~s/\D*$//g;
$productversion="$mstone[0],$mstone[1],0,0";
if ($official ne "1") {
push @fileflags, "VS_FF_PRIVATEBUILD";
}

}
if ($milestone =~ /[a-z]/) {
push @fileflags, "VS_FF_PRERELEASE";
}

$mfversion = $mpversion = "$milestone";
my @mstone = split(/\./,$milestone);
$mstone[1] =~s/\D.*$//;
if (!$mstone[2]) {
$mstone[2] = "0";
}
else {
$mstone[2] =~s/\D.*$//;
}
$fileversion = $productversion="$mstone[0],$mstone[1],$mstone[2],$daycount";

my $copyright = "License: MPL 1.1/GPL 2.0/LGPL 2.1";
my $company = "Mozilla Foundation";
Expand All @@ -257,7 +264,7 @@ sub getNextEntry
if (defined($override_mfversion)){$mfversion=$override_mfversion;}
if (defined($override_company)){$company=$override_company;}
if (defined($override_module)){$override_module =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $module=$override_module;}
if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_company;}
if (defined($override_copyright)){$override_copyright =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $copyright=$override_copyright;}
if (defined($override_trademarks)){$override_trademarks =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $trademarks=$override_trademarks;}
if (defined($override_filename)){$binary=$override_filename;}
if (defined($override_productname)){$override_productname =~ s/\@MOZ_APP_DISPLAYNAME\@/$displayname/g; $productname=$override_productname;}
Expand Down Expand Up @@ -370,6 +377,8 @@ sub getNextEntry

}

my $fileflags = join(' | ', @fileflags);

print RCFILE qq{
Expand All @@ -379,6 +388,7 @@ sub getNextEntry
//
1 VERSIONINFO
FILEVERSION $fileversion
PRODUCTVERSION $productversion
FILEFLAGSMASK 0x3fL
FILEFLAGS $fileflags
Expand All @@ -399,14 +409,8 @@ BEGIN
VALUE "InternalName", "$module"
VALUE "LegalTrademarks", "$trademarks"
VALUE "OriginalFilename", "$binary"
};
if ($official ne "1") {
print RCFILE qq{
VALUE "PrivateBuild", "$privateinfo"
};
}
print RCFILE qq{
VALUE "ProductName", "$productname"
VALUE "BuildID", "$buildid"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion toolkit/xre/Makefile.in
Expand Up @@ -245,7 +245,7 @@ export:: $(addprefix $(topsrcdir)/xpfe/bootstrap/, $(SHAREDCPPSRCS))
$(INSTALL) $^ .

platform.ini: FORCE
$(PYTHON) $(srcdir)/make-platformini.py $(topsrcdir)/config/milestone.txt > $@
$(PYTHON) $(srcdir)/make-platformini.py --buildid=$(shell cat $(DEPTH)/config/buildid) $(topsrcdir)/config/milestone.txt > $@

libs:: platform.ini
$(INSTALL) $^ $(DIST)/bin
Expand Down
10 changes: 7 additions & 3 deletions toolkit/xre/make-platformini.py
Expand Up @@ -6,15 +6,19 @@
import os

o = OptionParser()
o.add_option("--buildid", dest="buildid")
o.add_option("--print-buildid", action="store_true", dest="print_buildid")

(options, args) = o.parse_args()
buildid = os.environ.get('MOZ_BUILD_DATE', datetime.now().strftime('%Y%m%d%H'))

if options.print_buildid:
print buildid
print datetime.now().strftime('%Y%m%d%H')
sys.exit(0)

if not options.buildid:
print >>sys.stderr, "--buildid is required"
sys.exit(1)

(milestoneFile,) = args
for line in open(milestoneFile, 'r'):
if line[0] == '#':
Expand All @@ -28,4 +32,4 @@

print """[Build]
BuildID=%s
Milestone=%s""" % (buildid, milestone)
Milestone=%s""" % (options.buildid, milestone)

0 comments on commit d4a93bc

Please sign in to comment.