Update to new build scripts. NOT PART OF THE BUILD.
git-svn-id: svn://10.0.0.236/trunk@81504 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
974b919a65
commit
77cd4e7cd1
@ -44,14 +44,13 @@ $DEBUG = 0;
|
||||
$CARBON = 0; # turn on to build with TARGET_CARBON
|
||||
$PROFILE = 0;
|
||||
$GC_LEAK_DETECTOR = 0; # turn on to use GC leak detection
|
||||
$INCLUDE_CLASSIC_SKIN = 1;
|
||||
|
||||
#-----------------------------------------------
|
||||
# configuration variables that affect the manner
|
||||
# of building, but possibly affecting
|
||||
# the outcome.
|
||||
#-----------------------------------------------
|
||||
$DIST_DIRECTORY = ":mozilla:dist:viewer:";
|
||||
$BIN_DIRECTORY = ":mozilla:dist:viewer:";
|
||||
|
||||
$ALIAS_SYM_FILES = $DEBUG;
|
||||
$CLOBBER_LIBS = 1; # turn on to clobber existing libs and .xSYM files before
|
||||
|
||||
@ -42,16 +42,15 @@ my(%optiondefines);
|
||||
#-----------------------------------------------
|
||||
$DEBUG = 1;
|
||||
$CARBON = 0; # turn on to build with TARGET_CARBON
|
||||
$PROFILE = 0;
|
||||
$PROFILE = 1;
|
||||
$GC_LEAK_DETECTOR = 0; # turn on to use GC leak detection
|
||||
$INCLUDE_CLASSIC_SKIN = 1;
|
||||
|
||||
#-----------------------------------------------
|
||||
# configuration variables that affect the manner
|
||||
# of building, but possibly affecting
|
||||
# the outcome.
|
||||
#-----------------------------------------------
|
||||
$DIST_DIRECTORY = ":mozilla:dist:viewer_debug:";
|
||||
$BIN_DIRECTORY = ":mozilla:dist:viewer_debug:";
|
||||
|
||||
$ALIAS_SYM_FILES = $DEBUG;
|
||||
$CLOBBER_LIBS = 1; # turn on to clobber existing libs and .xSYM files before
|
||||
|
||||
@ -27,6 +27,7 @@ Replaces the AppleScript library I<CodeWarriorLib>.
|
||||
use strict;
|
||||
use Cwd;
|
||||
use Mac::Types;
|
||||
use Mac::Events;
|
||||
use Mac::AppleEvents;
|
||||
use Mac::AppleEvents::Simple;
|
||||
use Mac::Processes;
|
||||
@ -38,7 +39,7 @@ use vars qw($VERSION);
|
||||
$VERSION = '1.02';
|
||||
|
||||
my($app) = 'CWIE';
|
||||
my($scriptDir) = cwd();
|
||||
my($scriptDir) = cwd(); # could use $0 for this
|
||||
|
||||
# 0 == don't switch CWIE to front app in do_event(), 1 == do switch
|
||||
# note: activate() still switches when called
|
||||
@ -165,6 +166,57 @@ sub build_project ($;$$$) {
|
||||
return($had_errors);
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item appIsRunning()
|
||||
|
||||
=cut
|
||||
sub _appIsRunning($)
|
||||
{
|
||||
my ($appSignature) = @_;
|
||||
my ($psi);
|
||||
my ($found) = 0;
|
||||
my ($appPSN);
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item appIsFrontmost()
|
||||
|
||||
=cut
|
||||
sub _appIsFrontmost($)
|
||||
{
|
||||
my ($appSignature) = @_;
|
||||
my ($psi);
|
||||
my ($found) = 0;
|
||||
my ($appPSN);
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return (GetFrontProcess() == $appPSN);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item activate()
|
||||
@ -253,12 +305,66 @@ sub activate () {
|
||||
launchAppSpec => $appath,
|
||||
launchControlFlags => launchContinue() + launchNoFileFlags()
|
||||
);
|
||||
unless (LaunchApplication($lp)) {
|
||||
unlink($filepath);
|
||||
die $^E;
|
||||
}
|
||||
|
||||
unless (LaunchApplication($lp)) {
|
||||
unlink($filepath);
|
||||
die $^E;
|
||||
}
|
||||
|
||||
# wait for CodeWarrior to show up in the list of processes
|
||||
while (!_appIsRunning('CWIE'))
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
|
||||
# wait for CodeWarrior to come to the front
|
||||
while (!_appIsFrontmost('CWIE'))
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item getCodeWarriorPath()
|
||||
|
||||
Returns a file path relative to the CodeWarrior folder
|
||||
|
||||
=cut
|
||||
|
||||
sub getCodeWarriorPath($)
|
||||
{
|
||||
my($subfolder)=@_;
|
||||
|
||||
my($app_path) = _read_appath(":idepath.txt");
|
||||
if ($app_path eq "") { die "Error: Failed to get CodeWarrior IDE path\n"; }
|
||||
|
||||
my($codewarrior_root) = $app_path;
|
||||
$codewarrior_root =~ s/[^:]*$//;
|
||||
return ($codewarrior_root . $subfolder);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item getCodeWarriorIDEName()
|
||||
|
||||
Returns the name of the CodeWarrior application
|
||||
|
||||
=cut
|
||||
|
||||
sub getCodeWarriorIDEName()
|
||||
{
|
||||
my($subfolder)=@_;
|
||||
|
||||
my($app_path) = _read_appath(":idepath.txt");
|
||||
if ($app_path eq "") { die "Error: Failed to get CodeWarrior IDE path\n"; }
|
||||
|
||||
my(@codewarrior_path) = split(/:/, $app_path);
|
||||
return pop(@codewarrior_path);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item quit()
|
||||
|
||||
@ -20,6 +20,8 @@ use File::Basename;
|
||||
@EXPORT = qw( new print checkout);
|
||||
$VERSION = "1.00";
|
||||
|
||||
my($last_error) = 0;
|
||||
|
||||
# Architecture:
|
||||
# cvs session object:
|
||||
# name - session name
|
||||
@ -39,14 +41,25 @@ sub _myDoAppleScript($)
|
||||
{
|
||||
my($script) = @_;
|
||||
my $asresult = MacPerl::DoAppleScript($script);
|
||||
|
||||
if ($asresult eq "0")
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print STDERR "AppleScript error: $asresult\n";
|
||||
print STDERR "AppleScript was: \n $script \n";
|
||||
my($error_string) = "Unknown error";
|
||||
my($error_code) = 0;
|
||||
|
||||
if ($asresult =~ /^\"(.*)\.([0-9]+)\"$/)
|
||||
{
|
||||
$error_string = $1;
|
||||
$error_code = $2;
|
||||
}
|
||||
|
||||
print STDERR "Error. Script returned '$error_string (error $error_code)\n";
|
||||
# print STDERR "AppleScript was: \n $script \n";
|
||||
$last_error = $error_code;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -95,7 +108,8 @@ sub _useMacCVSLib()
|
||||
# Session object methods
|
||||
#
|
||||
|
||||
sub new {
|
||||
sub new
|
||||
{
|
||||
my ( $proto, $session_file) = @_;
|
||||
my $class = ref($proto) || $proto;
|
||||
my $self = {};
|
||||
@ -116,10 +130,14 @@ sub new {
|
||||
|
||||
# makes sure that the session is open
|
||||
# assertSessionOpen()
|
||||
# returns 1 on failure
|
||||
sub assertSessionOpen() {
|
||||
# returns 1 on success
|
||||
sub assertSessionOpen()
|
||||
{
|
||||
my ($self) = shift;
|
||||
_useMacCVSLib() || die "Could not load MacCVSLib\n";
|
||||
|
||||
$last_error = 0;
|
||||
|
||||
my $script = <<END_OF_APPLESCRIPT;
|
||||
tell (load script file "$MacCVSLib") to OpenSession("$self->{session_file}")
|
||||
END_OF_APPLESCRIPT
|
||||
@ -127,21 +145,25 @@ END_OF_APPLESCRIPT
|
||||
}
|
||||
|
||||
# prints the cvs object, used mostly for debugging
|
||||
sub print {
|
||||
sub print
|
||||
{
|
||||
my($self) = shift;
|
||||
$last_error = 0;
|
||||
print "MacCVS:: name: ", $self->{name}, " session file: ", $self->{session_file}, "\n";
|
||||
}
|
||||
|
||||
# checkout( self, module, revision, date)
|
||||
# MacCVS checkout command
|
||||
# returns 1 on failure
|
||||
sub checkout
|
||||
# returns 1 on success.
|
||||
sub checkout()
|
||||
{
|
||||
my($self, $module, $revision, $date ) = @_;
|
||||
unless( defined ($module) ) { $module = ""; } # get rid of the pesky undefined warnings
|
||||
unless( defined ($revision) ) { $revision = ""; }
|
||||
unless( defined ($date) ) { $date = ""; }
|
||||
|
||||
$last_error = 0;
|
||||
|
||||
$self->assertSessionOpen() || return 1;
|
||||
|
||||
my($revstring) = ($revision ne "") ? $revision : "(none)";
|
||||
@ -155,6 +177,11 @@ END_OF_APPLESCRIPT
|
||||
return _myDoAppleScript($script);
|
||||
}
|
||||
|
||||
sub getLastError()
|
||||
{
|
||||
return $last_error;
|
||||
}
|
||||
|
||||
1;
|
||||
=pod
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ use Mac::Processes;
|
||||
use File::Copy;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(current_directory full_path_to BuildProject BuildProjectClean OpenErrorLog MakeAlias StopForErrors DontStopForErrors InstallFromManifest InstallResources SetBuildNumber SetAgentString SetTimeBomb Delay ActivateApplication IsProcessRunning);
|
||||
@EXPORT = qw(LaunchCodeWarrior current_directory full_path_to BuildProject BuildProjectClean OpenErrorLog MakeAlias StopForErrors DontStopForErrors InstallFromManifest InstallResources SetBuildNumber SetAgentString SetTimeBomb Delay ActivateApplication IsProcessRunning);
|
||||
@EXPORT_OK = qw(CloseErrorLog UseCodeWarriorLib QUIET);
|
||||
|
||||
use Cwd;
|
||||
@ -402,10 +402,11 @@ sub InstallResources($;$;$)
|
||||
}
|
||||
|
||||
|
||||
sub SetBuildNumber
|
||||
{
|
||||
|
||||
open (OUTPUT, ">:mozilla:config:build_number") || die "could not open buildnumber";
|
||||
sub SetBuildNumber($$$)
|
||||
{
|
||||
my($build_num_file, $build_gen_script, $files_to_touch) = @_;
|
||||
|
||||
open (OUTPUT, ">$build_num_file") || die "could not open buildnumber";
|
||||
|
||||
open (BDATE, "perl :mozilla:config:bdate.pl|");
|
||||
|
||||
@ -416,10 +417,12 @@ sub InstallResources($;$;$)
|
||||
close (BDATE);
|
||||
close (OUTPUT);
|
||||
|
||||
|
||||
|
||||
system ("perl :mozilla:config:aboutime.pl :mozilla:xpfe:appshell:public:nsBuildID.h :mozilla:config:build_number");
|
||||
system ("perl :mozilla:config:aboutime.pl :mozilla:xpfe:browser:resources:locale:en-US:navigator.dtd :mozilla:config:build_number");
|
||||
my($file);
|
||||
foreach $file (@$files_to_touch)
|
||||
{
|
||||
print "Writing build number to $file\n";
|
||||
system ("perl $build_gen_script $file $build_num_file");
|
||||
}
|
||||
}
|
||||
|
||||
sub SetAgentString
|
||||
@ -478,6 +481,20 @@ sub Delay($)
|
||||
|
||||
}
|
||||
|
||||
sub GetFileModDate($)
|
||||
{
|
||||
my($filePath)=@_;
|
||||
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
||||
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filePath);
|
||||
return $mtime;
|
||||
}
|
||||
|
||||
|
||||
sub LaunchCodeWarrior()
|
||||
{
|
||||
# this both launches and writes idepath.txt
|
||||
CodeWarriorLib::activate();
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ActivateApplication
|
||||
@ -490,29 +507,28 @@ sub ActivateApplication($)
|
||||
my ($appPSN);
|
||||
|
||||
$found = 0;
|
||||
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found == 0)
|
||||
if ($found == 0 || SameProcess($appPSN, GetFrontProcess()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
SetFrontProcess($appPSN);
|
||||
|
||||
while (GetFrontProcess() != $appPSN)
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -61,8 +61,9 @@ my(@build_flags) =
|
||||
|
||||
my(@options_flags) =
|
||||
(
|
||||
["jar_manifests", 0], # use jar.mn files for resources, not MANIFESTs
|
||||
["jars", 0], # build jar files
|
||||
["chrome_jars", 1], # build jar files
|
||||
["chrome_files", 0], # build chrome files
|
||||
["use_jars", 1], # build chrome files
|
||||
["transformiix", 0], # obsolete?
|
||||
["mathml", 0],
|
||||
["svg", 0],
|
||||
@ -70,7 +71,7 @@ my(@options_flags) =
|
||||
["ldap", 0],
|
||||
["xmlextras", 0],
|
||||
["mailextras", 1], # mail importers
|
||||
["xptlink", 0] # xpt linker codewarrior plugin
|
||||
["xptlink", 0] # link xpt files using the MPW tool
|
||||
);
|
||||
|
||||
|
||||
@ -191,9 +192,9 @@ sub SetupBuildParams($$$$$)
|
||||
|
||||
PropagateAllFlags(\@build_flags);
|
||||
|
||||
SetPullFlags($pull);
|
||||
SetBuildFlags($build);
|
||||
SetBuildOptions($options);
|
||||
SetPullFlags($pull);
|
||||
SetBuildFlags($build);
|
||||
SetBuildOptions($options);
|
||||
SetOptionDefines($optiondefines);
|
||||
|
||||
#printHash($build);
|
||||
|
||||
@ -10,21 +10,31 @@ require Exporter;
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use Mac::Events;
|
||||
use Mac::StandardFile;
|
||||
|
||||
use Moz;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(GetDistDirectory BuildOneProject BuildIDLProject AskAndPersistFile DelayFor EmptyTree);
|
||||
@EXPORT = qw(GetBinDirectory
|
||||
BuildOneProject
|
||||
BuildIDLProject
|
||||
BuildFolderResourceAliases
|
||||
AskAndPersistFile
|
||||
DelayFor
|
||||
EmptyTree
|
||||
SetupBuildLog);
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# GetDistDirectory
|
||||
# GetBinDirectory
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub GetDistDirectory()
|
||||
sub GetBinDirectory()
|
||||
{
|
||||
if ($main::DIST_DIRECTORY eq "") { die "Dist directory not set\n"; }
|
||||
return $main::DIST_DIRECTORY;
|
||||
if ($main::BIN_DIRECTORY eq "") { die "Dist directory not set\n"; }
|
||||
return $main::BIN_DIRECTORY;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
@ -114,7 +124,7 @@ sub BuildOneProject($$$$$)
|
||||
|
||||
# $D becomes a suffix to target names for selecting either the debug or non-debug target of a project
|
||||
my($D) = $main::DEBUG ? "Debug" : "";
|
||||
my($dist_dir) = GetDistDirectory();
|
||||
my($dist_dir) = GetBinDirectory();
|
||||
|
||||
# Put libraries in "Essential Files" folder, Components in "Components" folder
|
||||
my($component_dir) = $component ? "Components:" : "Essential Files:";
|
||||
@ -134,6 +144,37 @@ sub BuildOneProject($$$$$)
|
||||
$alias_xSYM ? MakeAlias("$project_dir$target_name.xSYM", "$dist_dir$component_dir") : 0;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Make resource aliases for one directory
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildFolderResourceAliases($$)
|
||||
{
|
||||
my($src_dir, $dest_dir) = @_;
|
||||
|
||||
# get a list of all the resource files
|
||||
opendir(SRCDIR, $src_dir) || die("can't open $src_dir");
|
||||
my(@resource_files) = readdir(SRCDIR);
|
||||
closedir(SRCDIR);
|
||||
|
||||
# make aliases for each one into the dest directory
|
||||
print("Placing aliases to all files from $src_dir in $dest_dir\n");
|
||||
for ( @resource_files )
|
||||
{
|
||||
next if $_ eq "CVS";
|
||||
#print(" Doing $_\n");
|
||||
if (-l $src_dir.$_)
|
||||
{
|
||||
print(" $_ is an alias\n");
|
||||
next;
|
||||
}
|
||||
my($file_name) = $src_dir . $_;
|
||||
MakeAlias($file_name, $dest_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// DelayFor
|
||||
#//
|
||||
@ -158,7 +199,9 @@ sub DelayFor($)
|
||||
{
|
||||
print ".";
|
||||
$last_time = $cur_time;
|
||||
}
|
||||
}
|
||||
|
||||
WaitNextEvent();
|
||||
}
|
||||
|
||||
STDOUT->autoflush(0);
|
||||
@ -205,4 +248,32 @@ sub EmptyTree($)
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------
|
||||
# SetupBuildLog
|
||||
#-----------------------------------------------
|
||||
sub SetupBuildLog($)
|
||||
{
|
||||
my($timestamped_log) = @_;
|
||||
|
||||
if ($timestamped_log)
|
||||
{
|
||||
#Use time-stamped names so that you don't clobber your previous log file!
|
||||
my $now = localtime();
|
||||
while ($now =~ s@:@.@) {} # replace all colons by periods
|
||||
my $logdir = ":Build Logs:";
|
||||
if (!stat($logdir))
|
||||
{
|
||||
print "Creating directory $logdir\n";
|
||||
mkdir $logdir, 0777 || die "Couldn't create directory $logdir";
|
||||
}
|
||||
OpenErrorLog("$logdir$now");
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenErrorLog("NGLayoutBuildLog"); # Release build
|
||||
#OpenErrorLog("Mozilla.BuildLog"); # Tinderbox requires that name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@ -20,7 +20,7 @@ use Moz;
|
||||
use vars qw( @ISA @EXPORT );
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(CreateJarFileFromDirectory WriteOutJarFiles);
|
||||
@EXPORT = qw(CreateJarFileFromDirectory WriteOutJarFiles SanityCheckJarOptions);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -99,6 +99,78 @@ sub CreateJarFileFromDirectory($$$)
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SanityCheckJarOptions
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SanityCheckJarOptions()
|
||||
{
|
||||
if (!$main::options{chrome_jars} && !$main::options{chrome_files})
|
||||
{
|
||||
print "Both \$options{chrome_jars} and \$options{chrome_files} are off. You won't get any chrome.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$main::options{chrome_jars} && $main::options{use_jars})
|
||||
{
|
||||
print "\$options{chrome_jars} is off but \$options{use_jars} is on. Your build won't run (expects jars, got files).\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$main::options{chrome_files} && !$main::options{use_jars})
|
||||
{
|
||||
print "\$options{chrome_jars} is off but \$options{chrome_files} is on. Your build won't run (expects files, got jars).\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 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 writing jar to temp file $temp_file_name\n";
|
||||
|
||||
unlink $full_dest_path;
|
||||
|
||||
(rename $temp_file_name, $full_dest_path) || die "Failed to rename $temp_file_name\n";
|
||||
|
||||
MacPerl::SetFileInfo("ZIP ", "ZIP ", $full_dest_path);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# addToJarFile
|
||||
#
|
||||
@ -114,9 +186,9 @@ sub CreateJarFileFromDirectory($$$)
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub addToJarFile($$$$$$)
|
||||
sub addToJarFile($$$$$$$)
|
||||
{
|
||||
my($jar_id, $jar_man_dir, $file_src, $jar_path, $file_jar_path, $jars) = @_;
|
||||
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";
|
||||
|
||||
@ -141,13 +213,12 @@ sub addToJarFile($$$$$$)
|
||||
}
|
||||
}
|
||||
|
||||
if ($main::options{jars})
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
my($zip) = $jars->{$jar_id};
|
||||
unless ($zip) { die "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 "Failed to create zip file member $src\n"; }
|
||||
|
||||
@ -156,13 +227,51 @@ sub addToJarFile($$$$$$)
|
||||
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);
|
||||
}
|
||||
|
||||
$zip->addMember($member);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else # copy file
|
||||
|
||||
if ($main::options{chrome_files}) # we install raw files too
|
||||
{
|
||||
my($rel_path) = $file_jar_path;
|
||||
$rel_path =~ s|/|:|g; # slash to colons
|
||||
@ -173,7 +282,37 @@ sub addToJarFile($$$$$$)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,17 +325,31 @@ sub addToJarFile($$$$$$)
|
||||
|
||||
sub setupJarFile($$$)
|
||||
{
|
||||
my($jar_id, $jar_path, $jar_hash) = @_;
|
||||
my($jar_id, $dest_path, $jar_hash) = @_;
|
||||
|
||||
# print "Creating jar file $jar_id at $jar_path\n";
|
||||
|
||||
if ($main::options{jars})
|
||||
my($jar_file) = $jar_id;
|
||||
$jar_file =~ s|/|:|g; # slash to colons
|
||||
my($full_jar_path) = Moz::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 "Failed to re-read $full_jar_path\n"; }
|
||||
|
||||
# printZipContents($zip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -222,7 +375,7 @@ sub closeJarFile($$)
|
||||
|
||||
# print "Closing jar file $jar_path\n";
|
||||
|
||||
if ($main::options{jars})
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
|
||||
}
|
||||
@ -243,7 +396,7 @@ sub WriteOutJarFiles($$)
|
||||
{
|
||||
my($chrome_dir, $jars) = @_;
|
||||
|
||||
unless ($main::options{jars}) { return; }
|
||||
unless ($main::options{chrome_jars}) { return; }
|
||||
|
||||
my($full_chrome_path) = Moz::full_path_to($chrome_dir);
|
||||
|
||||
@ -261,12 +414,13 @@ sub WriteOutJarFiles($$)
|
||||
|
||||
# ensure the target dirs exist
|
||||
my($path) = $output_path;
|
||||
$path =~ s/\.jar$//;
|
||||
$path =~ s/[^:]+$//;
|
||||
mkpath($path);
|
||||
|
||||
($zip->writeToFileNamed($output_path) == Archive::Zip::AZ_OK) || die "Error writing jar $rel_path\n";
|
||||
|
||||
MacPerl::SetFileInfo("ZIP ", "ZIP ", $output_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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,43 +430,48 @@ sub WriteOutJarFiles($$)
|
||||
#
|
||||
# Enter a chrome package into the installed-chrome.txt file
|
||||
#-------------------------------------------------------------------------------
|
||||
sub registerChromePackage($$$$)
|
||||
sub registerChromePackage($$$$$$)
|
||||
{
|
||||
my($jar_file, $file_path, $chrome_dir, $jar_hash) = @_;
|
||||
my($jar_file, $file_path, $chrome_dir, $jar_hash, $chrome_type, $pkg_name) = @_;
|
||||
|
||||
my($manifest_subdir) = $jar_file;
|
||||
$manifest_subdir =~ s/:/\//g;
|
||||
|
||||
my($chrome_entry);
|
||||
|
||||
if ($main::options{jars}) {
|
||||
$chrome_entry = ",install,url,jar:resource:/Chrome/";
|
||||
$manifest_subdir.= "!/";
|
||||
if ($main::options{use_jars}) {
|
||||
$chrome_entry = "$chrome_type,install,url,jar:resource:/chrome/$manifest_subdir!/$chrome_type/$pkg_name";
|
||||
} else {
|
||||
$chrome_entry = ",install,url,resource:/Chrome/";
|
||||
$manifest_subdir =~ s/\.jar$/\//;
|
||||
$manifest_subdir =~ s/\.jar$//;
|
||||
$chrome_entry = "$chrome_type,install,url,resource:/chrome/$manifest_subdir/$chrome_type/$pkg_name";
|
||||
}
|
||||
|
||||
# print "Entering $chrome_entry$manifest_subdir in installed-chrome.txt\n";
|
||||
|
||||
# for now, regiser for content, locale and skin
|
||||
# we'll get the type from the path soon
|
||||
my($type) = "content";
|
||||
# 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 "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 "Failed to open $inst_chrome\n";
|
||||
|
||||
print(CHROMEFILE "${type}${chrome_entry}${manifest_subdir}\n");
|
||||
$type = "locale";
|
||||
print(CHROMEFILE "${type}${chrome_entry}${manifest_subdir}\n");
|
||||
$type = "skin";
|
||||
print(CHROMEFILE "${type}${chrome_entry}${manifest_subdir}\n");
|
||||
|
||||
close(CHROMEFILE);
|
||||
print(CHROMEFILE "${chrome_entry}\n");
|
||||
close(CHROMEFILE) || die "Failed to close $inst_chrome\n";
|
||||
print "+++ adding chrome $inst_chrome\n+++\t\t$chrome_entry\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -325,9 +484,10 @@ sub CreateJarFromManifest($$$)
|
||||
{
|
||||
my($jar_man_path, $dest_path, $jars) = @_;
|
||||
|
||||
if ($main::options{jars}) {
|
||||
if ($main::options{chrome_jars}) {
|
||||
print "Jarring from $jar_man_path\n";
|
||||
} else {
|
||||
}
|
||||
if ($main::options{chrome_files}) {
|
||||
print "Installing files from $jar_man_path\n";
|
||||
}
|
||||
|
||||
@ -337,7 +497,7 @@ sub CreateJarFromManifest($$$)
|
||||
# if the jars hash is empty, nuke installed-chrome.txt
|
||||
if (! scalar(%$jars))
|
||||
{
|
||||
print "Nuking chrome\n";
|
||||
print "Nuking installed-chrome.txt\n";
|
||||
my($installed_chrome) = $dest_path.":installed-chrome.txt";
|
||||
# unlink $installed_chrome;
|
||||
}
|
||||
@ -370,20 +530,21 @@ sub CreateJarFromManifest($$$)
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~/^([\w\d.\-\\\/]+)\:\s*$/) # line start jar file entries
|
||||
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, $full_jar_path, $jars);
|
||||
setupJarFile($jar_id, $dest_path, $jars);
|
||||
|
||||
}
|
||||
elsif ($line =~ /^\s+([\w\d.\-\\\/]+)\s*(\([\w\d.\-\\\/]+\))?$\s*/) # jar file entry
|
||||
elsif ($line =~ /^(\+?)\s+([\w\d.\-\_\\\/]+)\s*(\([\w\d.\-\_\\\/]+\))?$\s*/) # jar file entry
|
||||
{
|
||||
my($file_dest) = $1;
|
||||
my($file_src) = $2;
|
||||
my($override) = ($1 eq "+");
|
||||
my($file_dest) = $2;
|
||||
my($file_src) = $3;
|
||||
|
||||
if ($file_src) {
|
||||
$file_src = substr($file_src, 1, -1); #strip the ()
|
||||
@ -395,12 +556,14 @@ sub CreateJarFromManifest($$$)
|
||||
|
||||
if ($jar_file ne "") # if jar is open, add to jar
|
||||
{
|
||||
if ($file_dest eq "manifest.rdf") # will change to contents.rdf
|
||||
if ($file_dest =~ /([\w\d.\-\_]+)\/([\w\d.\-\_\\\/]+)contents.rdf/)
|
||||
{
|
||||
registerChromePackage($jar_file, $file_dest, $dest_path, $jars);
|
||||
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, $jars);
|
||||
addToJarFile($jar_id, $jar_man_dir, $file_src, $full_jar_path, $file_dest, $override, $jars);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user