Made make-jars.pl not make intermediate copy. Fixed problem calling zip multiple times.
git-svn-id: svn://10.0.0.236/trunk@79743 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
82afea4c09
commit
22384dd887
@ -1,6 +1,6 @@
|
||||
#!/perl
|
||||
|
||||
# make-jars [-c] [-f] [-v] [-d <destPath>] [-s <srcdir>] < <jar.mn>
|
||||
# make-jars [-f] [-v] [-d <chromeDir>] [-s <srcdir>] < <jar.mn>
|
||||
|
||||
use strict;
|
||||
|
||||
@ -12,30 +12,18 @@ use Cwd;
|
||||
use File::Copy;
|
||||
use File::Path;
|
||||
|
||||
my @cleanupList = ();
|
||||
my $IS_DIR = 1;
|
||||
my $IS_FILE = 2;
|
||||
|
||||
my $objdir = getcwd;
|
||||
|
||||
getopts("d:s:cvf");
|
||||
getopts("d:s:vf");
|
||||
|
||||
my $usrcdir = undef;
|
||||
my $baseFilesDir = ".";
|
||||
if (defined($::opt_s)) {
|
||||
$usrcdir = $::opt_s;
|
||||
$baseFilesDir = $::opt_s;
|
||||
}
|
||||
|
||||
my $destPath = ".";
|
||||
my $chromeDir = ".";
|
||||
if (defined($::opt_d)) {
|
||||
$destPath = $::opt_d;
|
||||
if ( defined($usrcdir) && substr($destPath, 0, 1) ne "/") {
|
||||
$destPath = "$objdir/$destPath";
|
||||
}
|
||||
}
|
||||
|
||||
my $copyFiles = 0;
|
||||
if (defined($::opt_c)) {
|
||||
$copyFiles = 1;
|
||||
$chromeDir = $::opt_d;
|
||||
}
|
||||
|
||||
my $verbose = 0;
|
||||
@ -50,150 +38,97 @@ if (defined($::opt_f)) {
|
||||
|
||||
if ($verbose) {
|
||||
print "make-jars "
|
||||
. ($copyFiles ? "-c " : "")
|
||||
# . ($srcDir ? "-s $srcDir " : "")
|
||||
. "-v -d $destPath\n";
|
||||
}
|
||||
|
||||
sub Cleanup
|
||||
{
|
||||
while (1) {
|
||||
my $isDir = pop(@cleanupList);
|
||||
if ($isDir == undef) {
|
||||
return 0;
|
||||
}
|
||||
my $path = pop(@cleanupList);
|
||||
#print "Cleaning up $path\n";
|
||||
if ($isDir == $IS_DIR) {
|
||||
rmdir($path) || die "can't remove dir $path: $!";
|
||||
}
|
||||
else {
|
||||
unlink($path) || die "can't remove file $path: $!";
|
||||
}
|
||||
}
|
||||
. "-v -d $chromeDir "
|
||||
. ($flatfilesonly ? "-f " : "")
|
||||
. ($baseFilesDir ? "-s $baseFilesDir " : "")
|
||||
. "\n";
|
||||
}
|
||||
|
||||
sub zipErrorCheck($)
|
||||
{
|
||||
my ($err) = @_;
|
||||
|
||||
return if ($err == 0 || $err == 12);
|
||||
|
||||
die ("Error invoking zip: $err\n");
|
||||
|
||||
}
|
||||
|
||||
sub JarIt
|
||||
{
|
||||
my ($destPath, $jarfile, $copyFiles, $args, $overrides) = @_;
|
||||
my ($destPath, $jarfile, $args, $overrides) = @_;
|
||||
|
||||
my $dir = $destPath;
|
||||
if ("$dir/$jarfile" =~ /([\w\d.\-\\\/]+)[\\\/]([\w\d.\-]+)/) {
|
||||
$dir = $1;
|
||||
}
|
||||
|
||||
MkDirs($dir, ".", 0);
|
||||
|
||||
if ($copyFiles) {
|
||||
my $indivDir = $jarfile;
|
||||
if ($indivDir =~ /(.*).jar/) {
|
||||
$indivDir = $1;
|
||||
}
|
||||
my $indivPath = "$destPath/$indivDir";
|
||||
MkDirs($indivPath, ".", 0);
|
||||
|
||||
my $file;
|
||||
foreach $file (split(' ', $args)) {
|
||||
if ($verbose) {
|
||||
print "adding individual file $file to dist\n";
|
||||
}
|
||||
EnsureFileInDir("$indivPath/$file", $file, 0, 0);
|
||||
}
|
||||
foreach $file (split(' ', $overrides)) {
|
||||
if ($verbose) {
|
||||
print "override: adding individual file $file to dist\n";
|
||||
}
|
||||
EnsureFileInDir("$indivPath/$file", $file, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$flatfilesonly) {
|
||||
|
||||
if (!($args eq "")) {
|
||||
my $cwd = getcwd;
|
||||
my $err = 0;
|
||||
#print("in $cwd; zip -u $destPath/$jarfile $args\n");
|
||||
system("zip -u $destPath/$jarfile $args") == 0 or
|
||||
$err = $? >> 8;
|
||||
zipErrorCheck($err);
|
||||
}
|
||||
if (!($overrides eq "")) {
|
||||
my $err = 0;
|
||||
print "+++ overriding $overrides\n";
|
||||
system("zip $destPath/$jarfile $overrides\n") == 0 or
|
||||
$err = $? >> 8;
|
||||
zipErrorCheck($err);
|
||||
}
|
||||
if ($flatfilesonly) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Cleanup();
|
||||
}
|
||||
my $oldDir = cwd();
|
||||
chdir("$destPath/$jarfile");
|
||||
#print "cd $destPath/$jarfile\n";
|
||||
|
||||
sub MkDirs
|
||||
{
|
||||
my ($path, $containingDir, $doCleanup) = @_;
|
||||
my $cwd = getcwd;
|
||||
my (@dirlist, $dir);
|
||||
|
||||
return if ($path eq "");
|
||||
|
||||
#print "MkDirs $cwd |$path| $containingDir $doCleanup\n";
|
||||
|
||||
@dirlist = mkpath("$path", 0, 0755);
|
||||
|
||||
if ($doCleanup == 1) {
|
||||
foreach $dir ( @dirlist) {
|
||||
#push(@cleanupList, "$cwd/$containingDir/$path");
|
||||
push(@cleanupList, "$dir");
|
||||
push(@cleanupList, $IS_DIR);
|
||||
}
|
||||
if (!($args eq "")) {
|
||||
my $cwd = getcwd;
|
||||
my $err = 0;
|
||||
#print "zip -u ../$jarfile.jar $args\n";
|
||||
system("zip -u ../$jarfile.jar $args") == 0 or
|
||||
$err = $? >> 8;
|
||||
zipErrorCheck($err);
|
||||
}
|
||||
}
|
||||
|
||||
sub CopyFile
|
||||
{
|
||||
my ($from, $to, $doCleanup) = @_;
|
||||
if ($verbose) {
|
||||
print "copying $from to $to\n";
|
||||
if (!($overrides eq "")) {
|
||||
my $err = 0;
|
||||
print "+++ overriding $overrides\n";
|
||||
system("zip ../$jarfile.jar $overrides\n") == 0 or
|
||||
$err = $? >> 8;
|
||||
zipErrorCheck($err);
|
||||
}
|
||||
copy("$from", "$to") || die "CopyFile failed: $!\n";
|
||||
|
||||
# fix the mod date so we don't jar everything (is this faster than just jarring everything?)
|
||||
my $atime = stat($from)->atime || die $!;
|
||||
my $mtime = stat($from)->mtime || die $!;
|
||||
utime($atime, $mtime, $to);
|
||||
|
||||
if ($doCleanup) {
|
||||
push(@cleanupList, "$to");
|
||||
push(@cleanupList, $IS_FILE);
|
||||
}
|
||||
chdir($oldDir);
|
||||
#print "cd $oldDir\n";
|
||||
}
|
||||
|
||||
sub EnsureFileInDir
|
||||
{
|
||||
my ($destPath, $srcPath, $doCleanup, $override) = @_;
|
||||
my ($destPath, $srcPath, $destFile, $srcFile, $override) = @_;
|
||||
|
||||
#print "EnsureFileInDir($destPath, $srcPath, $destFile, $srcFile, $override)\n";
|
||||
|
||||
my $src = $srcFile;
|
||||
if (defined($src)) {
|
||||
$src = "$srcPath/$srcFile";
|
||||
}
|
||||
else {
|
||||
$src = "$srcPath/$destFile";
|
||||
# check for the complete jar path in the dest dir
|
||||
if (!-e $src) {
|
||||
#else check for just the file name in the dest dir
|
||||
my $dir = "";
|
||||
my $file;
|
||||
if ($destFile =~ /([\w\d.\-\_\\\/]+)[\\\/]([\w\d.\-\_]+)/) {
|
||||
$dir = $1;
|
||||
$file = $2;
|
||||
}
|
||||
else {
|
||||
die "file not found: $srcPath/$destFile";
|
||||
}
|
||||
$src = "$srcPath/$file";
|
||||
if (!-e $src) {
|
||||
die "file not found: $srcPath/$destFile";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$srcPath = $src;
|
||||
$destPath = "$destPath/$destFile";
|
||||
|
||||
#print "EnsureFileInDir($destPath, $srcPath, $doCleanup, $override)\n";
|
||||
my $destStat = stat($destPath);
|
||||
my $destMtime = $destStat ? $destStat->mtime : 0;
|
||||
my $srcStat = stat($srcPath);
|
||||
my $srcMtime = $srcStat ? $srcStat->mtime : 0;
|
||||
|
||||
my $destStat = stat($destPath);
|
||||
my $destMtime = $destStat ? $destStat->mtime : 0;
|
||||
#print "destMtime = $destMtime, srcMtime = $srcMtime\n";
|
||||
|
||||
if (!-e $destPath || $destMtime < $srcMtime || $override) {
|
||||
#print "copying $destPath, from $srcPath\n";
|
||||
my $dir = "";
|
||||
my $file;
|
||||
if ($destPath =~ /([\w\d.\-\\\/]+)[\\\/]([\w\d.\-]+)/) {
|
||||
if ($destPath =~ /([\w\d.\-\_\\\/]+)[\\\/]([\w\d.\-\_]+)/) {
|
||||
$dir = $1;
|
||||
$file = $2;
|
||||
}
|
||||
@ -206,98 +141,52 @@ sub EnsureFileInDir
|
||||
}
|
||||
|
||||
if (!-e $file) {
|
||||
if (defined($usrcdir)) {
|
||||
if (-e "$usrcdir/$file") {
|
||||
$file = "$usrcdir/$file";
|
||||
} else {
|
||||
die "error: file '$usrcdir/$file' doesn't exist\n";
|
||||
}
|
||||
} else {
|
||||
die "error: file '$file' doesn't exist\n";
|
||||
}
|
||||
die "error: file '$file' doesn't exist\n";
|
||||
}
|
||||
MkDirs($dir, ".", $doCleanup);
|
||||
CopyFile($file, $destPath, $doCleanup);
|
||||
if (!-e $dir) {
|
||||
mkpath($dir, 0, 0775) || die "can't mkpath $dir: $!\n";
|
||||
}
|
||||
copy($file, $destPath) || die "copy($file, $destPath) failed: $!\n";
|
||||
|
||||
# fix the mod date so we don't jar everything (is this faster than just jarring everything?)
|
||||
my $atime = stat($file)->atime || die $!;
|
||||
my $mtime = stat($file)->mtime || die $!;
|
||||
utime($atime, $mtime, $destPath);
|
||||
|
||||
return 1;
|
||||
}
|
||||
# elsif ($doCleanup == 0 && -e $destPath) {
|
||||
# print "!!! file $destPath already exists -- need to add '+' rule to jar.mn\n";
|
||||
# }
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (defined($usrcdir)) {
|
||||
if ( -e "$usrcdir" ) {
|
||||
print "Change to $usrcdir from $objdir\n";
|
||||
chdir($usrcdir) or die "chdir: $!\n";
|
||||
} else {
|
||||
die "srcdir $usrcdir does not exist!\n";
|
||||
}
|
||||
}
|
||||
|
||||
while (<STDIN>) {
|
||||
chomp;
|
||||
start:
|
||||
if (/^([\w\d.\-\\\/]+)\:\s*$/) {
|
||||
if (/^([\w\d.\-\_\\\/]+).jar\:\s*$/) {
|
||||
my $jarfile = $1;
|
||||
my $args = "";
|
||||
my $overrides = "";
|
||||
my $cwd = cwd();
|
||||
print "+++ making chrome $cwd => $destPath/$jarfile\n";
|
||||
print "+++ making chrome $cwd => $chromeDir/$jarfile.jar\n";
|
||||
while (<STDIN>) {
|
||||
if (/^\s+([\w\d.\-\\\/]+)\s*(\([\w\d.\-\\\/]+\))?$\s*/) {
|
||||
if (/^\s+([\w\d.\-\_\\\/]+)\s*(\([\w\d.\-\_\\\/]+\))?$\s*/) {
|
||||
my $dest = $1;
|
||||
my $srcPath = $2;
|
||||
|
||||
if ( $srcPath ) {
|
||||
$srcPath = substr($srcPath,1,-1);
|
||||
|
||||
if (defined($usrcdir)) {
|
||||
#print "Chkpt A: Switching to $objdir\n";
|
||||
chdir $objdir or die "chdir: $!\n";
|
||||
$srcPath = "$usrcdir/$srcPath";
|
||||
}
|
||||
}
|
||||
EnsureFileInDir($dest, $srcPath, 1);
|
||||
my $srcPath = defined($2) ? substr($2, 1, -1) : $2;
|
||||
EnsureFileInDir("$chromeDir/$jarfile", $baseFilesDir, $dest, $srcPath, 1);
|
||||
$args = "$args$dest ";
|
||||
JarIt($destPath, $jarfile, $copyFiles, $args, $overrides);
|
||||
|
||||
if ($srcPath && defined($usrcdir)) {
|
||||
#print "Chkpt B: Switching back to $usrcdir\n";
|
||||
chdir $usrcdir or die "chdir: $!\n";
|
||||
}
|
||||
} elsif (/^\+\s+([\w\d.\-\\\/]+)\s*(\([\w\d.\-\\\/]+\))?$\s*/) {
|
||||
} elsif (/^\+\s+([\w\d.\-\_\\\/]+)\s*(\([\w\d.\-\_\\\/]+\))?$\s*/) {
|
||||
my $dest = $1;
|
||||
my $srcPath = $2;
|
||||
|
||||
if ( $srcPath ) {
|
||||
$srcPath = substr($srcPath,1,-1);
|
||||
if (defined($usrcdir)) {
|
||||
#print "Chkpt C: Switching to $objdir\n";
|
||||
chdir $objdir or die "chdir: $!\n";
|
||||
$srcPath = "$usrcdir/$srcPath";
|
||||
}
|
||||
}
|
||||
EnsureFileInDir($dest, $srcPath, 1);
|
||||
my $srcPath = defined($2) ? substr($2, 1, -1) : $2;
|
||||
EnsureFileInDir("$chromeDir/$jarfile", $baseFilesDir, $dest, $srcPath, 0);
|
||||
$overrides = "$overrides$dest ";
|
||||
JarIt($destPath, $jarfile, $copyFiles, $args, $overrides);
|
||||
if ($srcPath && defined($usrcdir)) {
|
||||
#print "Chkpt D: Switching back to $usrcdir\n";
|
||||
chdir $usrcdir or die "chdir: $!\n";
|
||||
}
|
||||
} elsif (/^\s*$/) {
|
||||
# end with blank line
|
||||
last;
|
||||
} else {
|
||||
#print "Chkpt E\n";
|
||||
|
||||
JarIt($destPath, $jarfile, $copyFiles, $args, $overrides);
|
||||
|
||||
#print "Chkpt F\n";
|
||||
|
||||
JarIt($chromeDir, $jarfile, $args, $overrides);
|
||||
goto start;
|
||||
}
|
||||
}
|
||||
JarIt($chromeDir, $jarfile, $args, $overrides);
|
||||
|
||||
} elsif (/^\s*\#.*$/) {
|
||||
# skip comments
|
||||
@ -308,4 +197,3 @@ while (<STDIN>) {
|
||||
die "bad jar rule head at: $_";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -596,7 +596,7 @@ install:: chrome
|
||||
!if exist($(JAR_MANIFEST))
|
||||
|
||||
chrome::
|
||||
$(PERL) $(DEPTH)\config\make-jars.pl -c -d $(DIST)\bin\chrome < $(JAR_MANIFEST)
|
||||
$(PERL) $(DEPTH)\config\make-jars.pl -d $(DIST)\bin\chrome < $(JAR_MANIFEST)
|
||||
|
||||
!endif
|
||||
|
||||
|
||||
@ -1143,7 +1143,7 @@ _JAR_REGCHROME_JAR=0
|
||||
endif
|
||||
|
||||
chrome::
|
||||
@if test -f $(JAR_MANIFEST); then $(PERL) $(topsrcdir)/config/make-jars.pl -c $(_JAR_FLAT_FILES_ONLY) -d $(DIST)/bin/chrome -s $(srcdir) < $(JAR_MANIFEST); fi
|
||||
@if test -f $(JAR_MANIFEST); then $(PERL) $(topsrcdir)/config/make-jars.pl $(_JAR_FLAT_FILES_ONLY) -d $(DIST)/bin/chrome -s $(srcdir) < $(JAR_MANIFEST); fi
|
||||
|
||||
install:: chrome
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user