bugscape 17934, which has code for unhardcoding versions in both trees
(bugzilla reference 169074). r=cls, no sr= needed for build changes.
This commit is contained in:
Родитель
8b0f24e328
Коммит
3d4f1395e6
|
@ -1,576 +0,0 @@
|
|||
#!perl -w
|
||||
package Moz::Jar;
|
||||
|
||||
#
|
||||
# Module for creating jar files, either using a jar manifest, or
|
||||
# simply jarring up folders on disk.
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Archive::Zip;
|
||||
use File::Path;
|
||||
|
||||
use Mac::Files;
|
||||
|
||||
use Moz::Moz;
|
||||
|
||||
use vars qw( @ISA @EXPORT );
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
CreateJarFileFromDirectory
|
||||
CreateJarFromManifest
|
||||
WriteOutJarFiles
|
||||
SanityCheckJarOptions
|
||||
);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Add the contents of a directory to the zip file
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub _addDirToJar($$$$)
|
||||
{
|
||||
my($dir, $jar_root, $zip, $compress) = @_;
|
||||
|
||||
opendir(DIR, $dir) or die "Error: Cannot open dir $dir\n";
|
||||
my @files = readdir(DIR);
|
||||
closedir DIR;
|
||||
|
||||
my $unix_jar_root = $jar_root;
|
||||
$unix_jar_root =~ s|:|/|g; # colon to slash conversion
|
||||
|
||||
my $file;
|
||||
|
||||
foreach $file (@files)
|
||||
{
|
||||
my $filepath = $dir.":".$file;
|
||||
|
||||
if (-d $filepath)
|
||||
{
|
||||
print "Adding files to jar from $filepath\n";
|
||||
_addDirToJar($filepath, $jar_root, $zip, $compress);
|
||||
}
|
||||
else
|
||||
{
|
||||
my $member = Archive::Zip::Member->newFromFile($filepath);
|
||||
die "Error: Failed to create zip file member $filepath\n" unless $member;
|
||||
|
||||
my $unixName = $filepath;
|
||||
$unixName =~ s|:|/|g; # colon to slash conversion
|
||||
$unixName =~ s|^$unix_jar_root||; # relativise
|
||||
|
||||
$member->fileName($unixName);
|
||||
|
||||
# print "Adding $file as $unixName\n";
|
||||
|
||||
if ($compress) {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
|
||||
} else {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
|
||||
}
|
||||
|
||||
$zip->addMember($member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Add the contents of a directory to the zip file
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub CreateJarFileFromDirectory($$$)
|
||||
{
|
||||
my($srcdir, $jarpath, $compress) = @_;
|
||||
|
||||
my $zip = Archive::Zip->new();
|
||||
|
||||
_addDirToJar($srcdir, $srcdir, $zip, $compress);
|
||||
|
||||
print "Saving zip file...\n";
|
||||
my $status = $zip->writeToFileNamed($jarpath);
|
||||
if ($status == 0) {
|
||||
print "Zipping completed successfully\n";
|
||||
} else {
|
||||
print "Error saving zip file\n";
|
||||
}
|
||||
|
||||
# set the file type/creator to something reasonable
|
||||
MacPerl::SetFileInfo("ZIP ", "ZIP ", $jarpath);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# printZipContents
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub printZipContents($)
|
||||
{
|
||||
my($zip) = @_;
|
||||
|
||||
my(@members) = $zip->memberNames();
|
||||
|
||||
print "Zip contains:\n";
|
||||
|
||||
my($member);
|
||||
foreach $member (@members)
|
||||
{
|
||||
print " $member\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# safeSaveJarFile
|
||||
#
|
||||
# Archive::Zip has a problem where you cannot save a zip file on top of
|
||||
# an existing zip file that it has open, because it holds references
|
||||
# into that zip. So we have to save to a temp file, then do a swap.
|
||||
#
|
||||
# Note that the zip will become invalid after this operation.
|
||||
# If you want to do further operations on it, you'll have to reread it.
|
||||
#-------------------------------------------------------------------------------
|
||||
sub safeSaveJarFile($$)
|
||||
{
|
||||
my($zip, $full_dest_path) = @_;
|
||||
|
||||
my($temp_file_name) = $full_dest_path."_temp";
|
||||
|
||||
($zip->writeToFileNamed($temp_file_name) == Archive::Zip::AZ_OK) || die "Error: died writing jar to temp file $temp_file_name\n";
|
||||
|
||||
unlink $full_dest_path;
|
||||
|
||||
(rename $temp_file_name, $full_dest_path) || die "Error: Failed to rename $temp_file_name\n";
|
||||
|
||||
MacPerl::SetFileInfo("ZIP ", "ZIP ", $full_dest_path);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# addToJarFile
|
||||
#
|
||||
# Add a file to a jar file
|
||||
#
|
||||
# Parameters:
|
||||
# 1. Jar ID. Unix path of jar file inside chrome.
|
||||
# 2. Abs path to jar.mn file (i.e. source) (mac breaks)
|
||||
# 3. File source, relative to jar.mn path (mac breaks)
|
||||
# 4. Abs path to the resulting .jar file (mac breaks)
|
||||
# 5. Relative file path within the jar (unix breaks)
|
||||
# 6. Reference to hash of jar files
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub addToJarFile($$$$$$$)
|
||||
{
|
||||
my($jar_id, $jar_man_dir, $file_src, $jar_path, $file_jar_path, $override, $jars) = @_;
|
||||
|
||||
# print "addToJarFile with:\n $jar_man_dir\n $file_src\n $jar_path\n $file_jar_path\n";
|
||||
|
||||
unless ($jar_path =~ m/(.+:)([^:]+)$/) { die "Error: Bad jar path $jar_path\n"; }
|
||||
|
||||
my($target_dir) = $1;
|
||||
my($jar_name) = $2;
|
||||
|
||||
$target_dir =~ s/[^:]+$//;
|
||||
|
||||
# print "¥ $target_dir $jar_name\n";
|
||||
|
||||
# find the source file
|
||||
my($src) = $jar_man_dir.":".$file_src;
|
||||
if ((!-e $src) && ($file_src =~ m/.+:([^:]+)$/)) # src does not exist. Fall back to looking for src in jar.mn dir
|
||||
{
|
||||
$file_src = $1;
|
||||
$src = $jar_man_dir.":".$file_src;
|
||||
|
||||
if (!-e $src) {
|
||||
die "Error: Can't find chrome file $src\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
my($zip) = $jars->{$jar_id};
|
||||
unless ($zip) { die "Error: Can't find Zip entry for $jar_id\n"; }
|
||||
|
||||
# print "Adding $file_src to jar file $jar_path at $file_jar_path\n";
|
||||
my($member) = Archive::Zip::Member->newFromFile($src);
|
||||
unless ($member) { die "Error: Failed to create zip file member $src\n"; }
|
||||
|
||||
$member->fileName($file_jar_path);
|
||||
|
||||
my($compress) = 1;
|
||||
if ($compress) {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
|
||||
$member->desiredCompressionLevel(Archive::Zip::COMPRESSION_LEVEL_DEFAULT); # defaults to 6
|
||||
} else {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
|
||||
}
|
||||
|
||||
my($old_member) = $zip->memberNamed($file_jar_path);
|
||||
|
||||
if ($override)
|
||||
{
|
||||
if ($old_member)
|
||||
{
|
||||
# print "Overriding $file_jar_path in jar file $jar_id\n";
|
||||
# need to compare mod dates or use the + here
|
||||
$zip->removeMember($old_member);
|
||||
}
|
||||
|
||||
$zip->addMember($member);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($old_member)
|
||||
{
|
||||
#compare dates here
|
||||
my($member_moddate) = $old_member->lastModTime();
|
||||
my($file_moddate) = GetFileModDate($src);
|
||||
|
||||
if ($file_moddate > $member_moddate)
|
||||
{
|
||||
print "Updating older file $file_jar_path in $jar_id\n";
|
||||
$zip->removeMember($old_member);
|
||||
$zip->addMember($member);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "File $file_jar_path in $jar_id is more recent. Not updating.\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$zip->addMember($member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($main::options{chrome_files}) # we install raw files too
|
||||
{
|
||||
my($rel_path) = $file_jar_path;
|
||||
$rel_path =~ s|/|:|g; # slash to colons
|
||||
|
||||
my($dir_name) = $jar_name;
|
||||
$dir_name =~ s/\.jar$//;
|
||||
|
||||
my($dst) = $target_dir.$dir_name.":".$rel_path;
|
||||
|
||||
# print "Aliassing $src\n to\n$dst\n";
|
||||
if ($override)
|
||||
{
|
||||
unlink $dst;
|
||||
MakeAlias($src, $dst); # don't check errors, otherwise we fail on replacement
|
||||
}
|
||||
else
|
||||
{
|
||||
if (-e $dst)
|
||||
{
|
||||
#compare dates here
|
||||
my($dst_moddate) = GetFileModDate($dst);
|
||||
my($file_moddate) = GetFileModDate($src);
|
||||
|
||||
if ($file_moddate > $dst_moddate)
|
||||
{
|
||||
print "Updating older file $rel_path in $dir_name\n";
|
||||
unlink $dst;
|
||||
MakeAlias($src, $dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "File $file_jar_path in $jar_id is more recent. Not updating.\n";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeAlias($src, $dst);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# setupJarFile
|
||||
#
|
||||
# setup a zip for writing
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub setupJarFile($$$)
|
||||
{
|
||||
my($jar_id, $dest_path, $jar_hash) = @_;
|
||||
|
||||
# print "Creating jar file $jar_id at $jar_path\n";
|
||||
|
||||
my($jar_file) = $jar_id;
|
||||
$jar_file =~ s|/|:|g; # slash to colons
|
||||
my($full_jar_path) = full_path_to($dest_path.":".$jar_file);
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
my($zip) = $jar_hash->{$jar_id};
|
||||
if (!$zip) # if we haven't made it already, do so
|
||||
{
|
||||
my($zip) = Archive::Zip->new();
|
||||
$jar_hash->{$jar_id} = $zip;
|
||||
|
||||
# does the jar file exist already? If so, read it in
|
||||
if (-e $full_jar_path)
|
||||
{
|
||||
print "Reading in jar file $jar_id\n";
|
||||
if ($zip->read($full_jar_path) != Archive::Zip::AZ_OK) { die "Error: Failed to re-read $full_jar_path\n"; }
|
||||
|
||||
# printZipContents($zip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# installing files.
|
||||
# nothing to do. MakeAlias creates dirs as needed.
|
||||
|
||||
# add this jar to the list
|
||||
$jar_hash->{$jar_id} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# closeJarFile
|
||||
#
|
||||
# We're done with this jar file _for this jar.mn_. We may add more entries
|
||||
# to it later, so keep it open in the hash.
|
||||
#-------------------------------------------------------------------------------
|
||||
sub closeJarFile($$)
|
||||
{
|
||||
my($jar_path, $jar_hash) = @_;
|
||||
|
||||
# print "Closing jar file $jar_path\n";
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
# installing files.
|
||||
# nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# WriteOutJarFiles
|
||||
#
|
||||
# Now we dump out the jars
|
||||
#-------------------------------------------------------------------------------
|
||||
sub WriteOutJarFiles($$)
|
||||
{
|
||||
my($chrome_dir, $jars) = @_;
|
||||
|
||||
unless ($main::options{chrome_jars}) { return; }
|
||||
|
||||
my($full_chrome_path) = full_path_to($chrome_dir);
|
||||
|
||||
my($key);
|
||||
foreach $key (keys %$jars)
|
||||
{
|
||||
my($zip) = $jars->{$key};
|
||||
|
||||
my($rel_path) = $key;
|
||||
$rel_path =~ s/\//:/g;
|
||||
|
||||
my($output_path) = $full_chrome_path.":".$rel_path;
|
||||
|
||||
print "Writing zip file $key to $output_path\n";
|
||||
|
||||
# ensure the target dirs exist
|
||||
my($path) = $output_path;
|
||||
$path =~ s/[^:]+$//;
|
||||
mkpath($path);
|
||||
|
||||
# unlink $output_path; # remove any existing jar
|
||||
safeSaveJarFile($zip, $output_path);
|
||||
# $zip is invalid after this operation, so nuke it here
|
||||
$jars->{$key} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# registerChromePackage
|
||||
#
|
||||
# Enter a chrome package into the installed-chrome.txt file
|
||||
#-------------------------------------------------------------------------------
|
||||
sub registerChromePackage($$$$$$)
|
||||
{
|
||||
my($jar_file, $file_path, $chrome_dir, $jar_hash, $chrome_type, $pkg_name) = @_;
|
||||
|
||||
my($manifest_subdir) = $jar_file;
|
||||
$manifest_subdir =~ s/:/\//g;
|
||||
|
||||
if (index($manifest_subdir, "-unix") == -1 && index($manifest_subdir, "-win") == -1) {
|
||||
|
||||
my($chrome_entry);
|
||||
|
||||
if ($main::options{use_jars}) {
|
||||
$chrome_entry = "$chrome_type,install,url,jar:resource:/chrome/$manifest_subdir!/$chrome_type/$pkg_name";
|
||||
} else {
|
||||
$manifest_subdir =~ s/\.jar$//;
|
||||
$chrome_entry = "$chrome_type,install,url,resource:/chrome/$manifest_subdir/$chrome_type/$pkg_name";
|
||||
}
|
||||
|
||||
# print "Entering $chrome_entry in installed-chrome.txt\n";
|
||||
|
||||
# ensure chrome_dir exists
|
||||
mkpath($chrome_dir);
|
||||
|
||||
my($inst_chrome) = ${chrome_dir}.":installed-chrome.txt";
|
||||
|
||||
if (open(CHROMEFILE, "<$inst_chrome")) {
|
||||
while (<CHROMEFILE>) {
|
||||
chomp;
|
||||
if ($_ eq $chrome_entry) {
|
||||
# $chrome_entry already appears in installed-chrome.txt file
|
||||
# just update the mod date
|
||||
my $now = time;
|
||||
utime($now, $now, $inst_chrome) || die "Error: Couldn't touch $inst_chrome";
|
||||
print "+++ updating chrome $inst_chrome\n+++\t\t$chrome_entry\n";
|
||||
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
|
||||
}
|
||||
open(CHROMEFILE, ">>${inst_chrome}") || die "Error: Failed to open $inst_chrome\n";
|
||||
print(CHROMEFILE "${chrome_entry}\n");
|
||||
close(CHROMEFILE) || die "Error: Failed to close $inst_chrome\n";
|
||||
print "+++ adding chrome $inst_chrome\n+++\t\t$chrome_entry\n";
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create or add to a jar file from a jar.mn file.
|
||||
# Both arguments are relative to the mozilla root dir.
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub CreateJarFromManifest($$$)
|
||||
{
|
||||
my($jar_man_path, $dest_path, $jars) = @_;
|
||||
|
||||
if ($main::options{chrome_jars}) {
|
||||
print "Jarring from $jar_man_path\n";
|
||||
}
|
||||
if ($main::options{chrome_files}) {
|
||||
print "Installing files from $jar_man_path\n";
|
||||
}
|
||||
|
||||
$jar_man_path = full_path_to($jar_man_path);
|
||||
$dest_path = full_path_to($dest_path);
|
||||
|
||||
# if the jars hash is empty, nuke installed-chrome.txt
|
||||
if (! scalar(%$jars))
|
||||
{
|
||||
print "Nuking installed-chrome.txt\n";
|
||||
my($installed_chrome) = $dest_path.":installed-chrome.txt";
|
||||
# unlink $installed_chrome;
|
||||
}
|
||||
|
||||
my $jar_man_dir = "";
|
||||
my $jar_man_file = "";
|
||||
|
||||
if ($jar_man_path =~ /(.+):([^:]+)$/)
|
||||
{
|
||||
$jar_man_dir = $1; # no trailing :
|
||||
$jar_man_file = $2;
|
||||
}
|
||||
|
||||
# Keep a hash of jar files, keyed on relative jar path (e.g. "packages/core.jar")
|
||||
# Entries are open Archive::Zips (if zipping), and installed-chrome entries.
|
||||
|
||||
my($jar_id) = ""; # Current foo/bar.jar from jar.mn file
|
||||
my($jar_file) = ""; # relative path to jar file (from $dest_path), with mac separators
|
||||
my($full_jar_path);
|
||||
|
||||
open(FILE, "<$jar_man_path") || die "Error: could not open \"$jar_man_path\": $!";
|
||||
while (<FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# print "$line\n";
|
||||
|
||||
if ($line =~ /^\s*\#.*$/) { # skip comments
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~/^([\w\d.\-\_\\\/]+)\:\s*$/) # line start jar file entries
|
||||
{
|
||||
$jar_id = $1;
|
||||
$jar_file = $jar_id;
|
||||
$jar_file =~ s|/|:|g; # slash to colons
|
||||
$full_jar_path = $dest_path.":".$jar_file;
|
||||
|
||||
setupJarFile($jar_id, $dest_path, $jars);
|
||||
|
||||
}
|
||||
elsif ($line =~ /^(\+?)\s+([\w\d.\-\_\\\/]+)\s*(\([\w\d.\-\_\\\/]+\))?$\s*/) # jar file entry
|
||||
{
|
||||
my($override) = ($1 eq "+");
|
||||
my($file_dest) = $2;
|
||||
my($file_src) = $3;
|
||||
|
||||
if ($file_src) {
|
||||
$file_src = substr($file_src, 1, -1); #strip the ()
|
||||
} else {
|
||||
$file_src = $file_dest;
|
||||
}
|
||||
|
||||
$file_src =~ s|/|:|g;
|
||||
|
||||
if ($jar_file ne "") # if jar is open, add to jar
|
||||
{
|
||||
if ($file_dest =~ /([\w\d.\-\_]+)\/([\w\d.\-\_\\\/]+)contents.rdf/)
|
||||
{
|
||||
my $chrome_type = $1;
|
||||
my $pkg_name = $2;
|
||||
registerChromePackage($jar_file, $file_dest, $dest_path, $jars, $chrome_type, $pkg_name);
|
||||
}
|
||||
|
||||
addToJarFile($jar_id, $jar_man_dir, $file_src, $full_jar_path, $file_dest, $override, $jars);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: bad jar.mn format at $line\n";
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^\s*$/ ) # blank line
|
||||
{
|
||||
if ($jar_file ne "") #if a jar file is open, close it
|
||||
{
|
||||
closeJarFile($full_jar_path, $jars);
|
||||
|
||||
$jar_file = "";
|
||||
$full_jar_path = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
|
||||
if ($jar_file ne "") #if a jar file is open, close it
|
||||
{
|
||||
closeJarFile($full_jar_path, $jars);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,230 @@
|
|||
#!/usr/bin/perl -w
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Win32 Version System.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications Corporation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2002
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
package Moz::Milestone;
|
||||
use strict;
|
||||
|
||||
use vars qw($officialMilestone
|
||||
$milestone);
|
||||
|
||||
local $Moz::Milestone::milestone;
|
||||
local $Moz::Milestone::officialMilestone;
|
||||
|
||||
#
|
||||
# Usage: getOfficialMilestone($milestoneFile)
|
||||
# Returns full milestone (x.x.x.x[ab12pre+])
|
||||
#
|
||||
sub getOfficialMilestone($) {
|
||||
my $mfile = $_[0];
|
||||
open(FILE,"$mfile") ||
|
||||
die ("Can't open $mfile for reading!");
|
||||
|
||||
my $num = <FILE>;
|
||||
while($num =~ /^\s*#/ || $num !~ /^\d/) {
|
||||
$num = <FILE>;
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
if ($num !~ /^\d/) { return; }
|
||||
chomp($num);
|
||||
$Moz::Milestone::officialMilestone = $num;
|
||||
$Moz::Milestone::milestone = &getMilestoneNum;
|
||||
return $num;
|
||||
}
|
||||
|
||||
#
|
||||
# Usage: getMilestoneNum($num)
|
||||
# Returns: milestone without a + if it exists.
|
||||
#
|
||||
sub getMilestoneNum {
|
||||
if (defined($Moz::Milestone::milestone)) {
|
||||
return $Moz::Milestone::milestone;
|
||||
}
|
||||
|
||||
if (defined($Moz::Milestone::officialMilestone)) {
|
||||
$Moz::Milestone::milestone = $Moz::Milestone::officialMilestone;
|
||||
} else {
|
||||
$Moz::Milestone::milestone = $_[0];
|
||||
}
|
||||
|
||||
if ($Moz::Milestone::milestone =~ /\+$/) { # for x.x.x+, strip off the +
|
||||
$Moz::Milestone::milestone =~ s/\+$//;
|
||||
}
|
||||
|
||||
return $Moz::Milestone::milestone;
|
||||
}
|
||||
|
||||
#
|
||||
# Usage: getMilestoneQualifier($num)
|
||||
# Returns: + if it exists.
|
||||
#
|
||||
sub getMilestoneQualifier {
|
||||
my $milestoneQualifier;
|
||||
if (defined($Moz::Milestone::officialMilestone)) {
|
||||
$milestoneQualifier = $Moz::Milestone::officialMilestone;
|
||||
} else {
|
||||
$milestoneQualifier = $_[0];
|
||||
}
|
||||
|
||||
if ($milestoneQualifier =~ /\+$/) {
|
||||
return "+";
|
||||
}
|
||||
}
|
||||
|
||||
sub getMilestoneMajor {
|
||||
my $milestoneMajor;
|
||||
if (defined($Moz::Milestone::milestone)) {
|
||||
$milestoneMajor = $Moz::Milestone::milestone;
|
||||
} else {
|
||||
$milestoneMajor = $_[0];
|
||||
}
|
||||
my @parts = split(/\./,$milestoneMajor);
|
||||
return $parts[0];
|
||||
}
|
||||
|
||||
sub getMilestoneMinor {
|
||||
my $milestoneMinor;
|
||||
if (defined($Moz::Milestone::milestone)) {
|
||||
$milestoneMinor = $Moz::Milestone::milestone;
|
||||
} else {
|
||||
$milestoneMinor = $_[0];
|
||||
}
|
||||
my @parts = split(/\./,$milestoneMinor);
|
||||
|
||||
if ($#parts < 1 ) { return 0; }
|
||||
return $parts[1];
|
||||
}
|
||||
|
||||
sub getMilestoneMini {
|
||||
my $milestoneMini;
|
||||
if (defined($Moz::Milestone::milestone)) {
|
||||
$milestoneMini = $Moz::Milestone::milestone;
|
||||
} else {
|
||||
$milestoneMini = $_[0];
|
||||
}
|
||||
my @parts = split(/\./,$milestoneMini);
|
||||
|
||||
if ($#parts < 2 ) { return 0; }
|
||||
return $parts[2];
|
||||
}
|
||||
|
||||
sub getMilestoneMicro {
|
||||
my $milestoneMicro;
|
||||
if (defined($Moz::Milestone::milestone)) {
|
||||
$milestoneMicro = $Moz::Milestone::milestone;
|
||||
} else {
|
||||
$milestoneMicro = $_[0];
|
||||
}
|
||||
my @parts = split(/\./,$milestoneMicro);
|
||||
|
||||
if ($#parts < 3 ) { return 0; }
|
||||
return $parts[3];
|
||||
}
|
||||
|
||||
sub getMilestoneAB {
|
||||
my $milestoneAB;
|
||||
if (defined($Moz::Milestone::milestone)) {
|
||||
$milestoneAB = $Moz::Milestone::milestone;
|
||||
} else {
|
||||
$milestoneAB = $_[0];
|
||||
}
|
||||
|
||||
if ($milestoneAB =~ /a/) { return "alpha"; }
|
||||
if ($milestoneAB =~ /b/) { return "beta"; }
|
||||
return "final";
|
||||
}
|
||||
|
||||
#
|
||||
# build_file($template_file,$output_file)
|
||||
#
|
||||
sub build_file($$) {
|
||||
my @FILE;
|
||||
my @MILESTONE_PARTS;
|
||||
my $MINI_VERSION = 0;
|
||||
my $MICRO_VERSION = 0;
|
||||
my $OFFICIAL = 0;
|
||||
my $QUALIFIER = "";
|
||||
|
||||
if (!defined($Moz::Milestone::milestone)) { die("$0: no milestone file set!\n"); }
|
||||
@MILESTONE_PARTS = split(/\./, &getMilestoneNum);
|
||||
if ($#MILESTONE_PARTS >= 2) {
|
||||
$MINI_VERSION = 1;
|
||||
} else {
|
||||
$MILESTONE_PARTS[2] = 0;
|
||||
}
|
||||
if ($#MILESTONE_PARTS >= 3) {
|
||||
$MICRO_VERSION = 1;
|
||||
} else {
|
||||
$MILESTONE_PARTS[3] = 0;
|
||||
}
|
||||
if (! &getMilestoneQualifier) {
|
||||
$OFFICIAL = 1;
|
||||
} else {
|
||||
$QUALIFIER = "+";
|
||||
}
|
||||
|
||||
if (-e $_[0]) {
|
||||
open(FILE, "$_[0]") || die("$0: Can't open $_[0] for reading!\n");
|
||||
@FILE = <FILE>;
|
||||
close(FILE);
|
||||
|
||||
open(FILE, ">$_[1]") || die("$0: Can't open $_[1] for writing!\n");
|
||||
|
||||
#
|
||||
# There will be more of these based on what we need for files.
|
||||
#
|
||||
foreach(@FILE) {
|
||||
s/__MOZ_MAJOR_VERSION__/$MILESTONE_PARTS[0]/g;
|
||||
s/__MOZ_MINOR_VERSION__/$MILESTONE_PARTS[1]/g;
|
||||
s/__MOZ_MINI_VERSION__/$MILESTONE_PARTS[2]/g;
|
||||
s/__MOZ_MICRO_VERSION__/$MILESTONE_PARTS[3]/g;
|
||||
if ($MINI_VERSION) {
|
||||
s/__MOZ_OPTIONAL_MINI_VERSION__/.$MILESTONE_PARTS[2]/g;
|
||||
}
|
||||
if ($MICRO_VERSION) {
|
||||
s/__MOZ_OPTIONAL_MICRO_VERSION__/.$MILESTONE_PARTS[3]/g;
|
||||
}
|
||||
|
||||
print FILE $_;
|
||||
}
|
||||
close(FILE);
|
||||
} else {
|
||||
die("$0: $_[0] doesn't exist for autoversioning!\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
|
@ -261,6 +261,7 @@ sub RegIt
|
|||
sub EnsureFileInDir
|
||||
{
|
||||
my ($destPath, $srcPath, $destFile, $srcFile, $override, $preproc) = @_;
|
||||
my $objPath;
|
||||
|
||||
#print "EnsureFileInDir($destPath, $srcPath, $destFile, $srcFile, $override)\n";
|
||||
|
||||
|
@ -316,9 +317,14 @@ sub EnsureFileInDir
|
|||
if ($srcPath) {
|
||||
$file = $srcPath;
|
||||
}
|
||||
$objPath = "$objdir/$destFile";
|
||||
|
||||
if (!-e $file) {
|
||||
if (!-e $objPath) {
|
||||
die "error: file '$file' doesn't exist";
|
||||
} else {
|
||||
$file = "$objPath";
|
||||
}
|
||||
}
|
||||
if (!-e $dir) {
|
||||
mkpath($dir, 0, 0775) || die "can't mkpath $dir: $!";
|
||||
|
|
|
@ -38,71 +38,73 @@ use Getopt::Long;
|
|||
|
||||
use strict;
|
||||
use vars qw(
|
||||
$OBJDIR
|
||||
$SRCDIR
|
||||
$TOPSRCDIR
|
||||
$SCRIPTDIR
|
||||
@TEMPLATE_FILE
|
||||
$MILESTONE_FILE
|
||||
$MILESTONE
|
||||
$MILESTONE_NUM
|
||||
@MILESTONE_PARTS
|
||||
$MILESTONE_BUILD
|
||||
$MILESTONE_QUALIFIER
|
||||
$opt_getms
|
||||
$MINI_VERSION
|
||||
$MICRO_VERSION
|
||||
$opt_debug
|
||||
$opt_template
|
||||
$opt_help
|
||||
);
|
||||
|
||||
&GetOptions('topsrcdir=s' => \$TOPSRCDIR, 'getms', 'debug', 'help');
|
||||
$SCRIPTDIR = $0;
|
||||
$SCRIPTDIR =~ s/[^\/]*$//;
|
||||
push(@INC,$SCRIPTDIR);
|
||||
|
||||
require "Moz/Milestone.pm";
|
||||
|
||||
&GetOptions('topsrcdir=s' => \$TOPSRCDIR, 'srcdir=s' => \$SRCDIR, 'objdir=s' => \$OBJDIR, 'debug', 'help', 'template');
|
||||
|
||||
if (defined($opt_help)) {
|
||||
&usage();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (defined($opt_template)) {
|
||||
@TEMPLATE_FILE = @ARGV;
|
||||
if ($opt_debug) {
|
||||
print("TEMPLATE_FILE = --@TEMPLATE_FILE--\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined($SRCDIR)) { $SRCDIR = '.'; }
|
||||
if (!defined($OBJDIR)) { $OBJDIR = '.'; }
|
||||
|
||||
$MILESTONE_FILE = "$TOPSRCDIR/config/milestone.txt";
|
||||
@MILESTONE_PARTS = (0, 0, 0, 0);
|
||||
$MILESTONE_QUALIFIER = "";
|
||||
|
||||
#
|
||||
# Grab milestone (top line of $MILESTONE_FILE that starts with a digit)
|
||||
#
|
||||
open(FILE,"$MILESTONE_FILE") ||
|
||||
die ("Can't open $MILESTONE_FILE for reading!");
|
||||
$MILESTONE = <FILE>;
|
||||
while($MILESTONE =~ /^\s*#/ || $MILESTONE !~ /^\d/) {
|
||||
$MILESTONE = <FILE>;
|
||||
}
|
||||
close(FILE);
|
||||
chomp($MILESTONE);
|
||||
$MILESTONE_NUM = $MILESTONE;
|
||||
Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
|
||||
|
||||
#
|
||||
# Split the milestone into parts (major, minor, minor2, minor3, ...)
|
||||
#
|
||||
if ($MILESTONE =~ /\+$/) { # for things like 0.9.9+, strip off the +
|
||||
$MILESTONE_QUALIFIER = "+";
|
||||
$MILESTONE_NUM =~ s/\D*$//;
|
||||
}
|
||||
@MILESTONE_PARTS = split(/\./, $MILESTONE_NUM);
|
||||
if (defined(@TEMPLATE_FILE)) {
|
||||
my $TFILE;
|
||||
|
||||
if ($opt_debug) {
|
||||
print ("MS $MILESTONE MSNUM $MILESTONE_NUM MSQ $MILESTONE_QUALIFIER MS_PARTS @MILESTONE_PARTS\n");
|
||||
}
|
||||
foreach $TFILE (@TEMPLATE_FILE) {
|
||||
my $BUILT_FILE = "$OBJDIR/$TFILE";
|
||||
$TFILE = "$SRCDIR/$TFILE.tmpl";
|
||||
|
||||
if ($opt_getms && !$MILESTONE_QUALIFIER) {
|
||||
print "$MILESTONE";
|
||||
exit;
|
||||
}
|
||||
if (-e $TFILE) {
|
||||
|
||||
# TODO
|
||||
# Later on I'll add options to update *all* hardcoded versions in
|
||||
# the source tree...
|
||||
# probably have a file listing all files that need to be changed,
|
||||
# and replace them with templates that have __MOZ_MAJOR_VERSION__
|
||||
# or whatever in place of 0, __MOZ_MINOR_VERSION__ instead of 9,
|
||||
# etc., given the right options.
|
||||
Moz::Milestone::build_file($TFILE,$BUILT_FILE);
|
||||
|
||||
} else {
|
||||
warn("$0: No such file $TFILE!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub usage() {
|
||||
print <<END
|
||||
`milestone.pl [--topsrcdir TOPSRCDIR] --getms` # will output \$MILESTONE if no '+'
|
||||
`milestone.pl [--topsrcdir TOPSRCDIR] [--objdir OBJDIR] [--srcdir SRCDIR] --template [file list]` # will build file list from .tmpl files
|
||||
END
|
||||
;
|
||||
}
|
||||
|
|
|
@ -61,8 +61,14 @@ endif
|
|||
ifdef PROGRAM
|
||||
_RC_STRING += -BINARY $(PROGRAM)
|
||||
else
|
||||
ifdef _PROGRAM
|
||||
_RC_STRING += -BINARY $(_PROGRAM)
|
||||
else
|
||||
ifdef SHARED_LIBRARY
|
||||
_RC_STRING += -BINARY $(SHARED_LIBRARY)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifdef RCINCLUDE
|
||||
_RC_STRING += -RCINCLUDE $(srcdir)/$(RCINCLUDE)
|
||||
endif
|
||||
|
@ -79,5 +85,11 @@ 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
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
|
||||
#use diagnostics;
|
||||
require strict;
|
||||
my $dir = $0;
|
||||
$dir =~ s/[^\/]*$//;
|
||||
push(@INC, "$dir");
|
||||
require "Moz/Milestone.pm";
|
||||
use Getopt::Long;
|
||||
use Getopt::Std;
|
||||
|
||||
|
@ -203,16 +207,16 @@ if ($official eq "1") {
|
|||
$fileflags = "VS_FF_PRERELEASE | VS_FF_DEBUG";
|
||||
}
|
||||
|
||||
# Try to grab milestone from milestone.pl
|
||||
# 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 = `perl $topsrcdir/config/milestone.pl --topsrcdir $topsrcdir --getms`;
|
||||
$milestone = Moz::Milestone::getOfficialMilestone();
|
||||
}
|
||||
|
||||
if ($milestone ne "") {
|
||||
if ($milestone ne "" && $milestone !~ /\+$/) {
|
||||
#its a milestone build
|
||||
|
||||
$mpversion = $milestone;
|
||||
|
|
Загрузка…
Ссылка в новой задаче