1998-12-13 05:08:00 +00:00
|
|
|
#!perl -w
|
|
|
|
package MANIFESTO;
|
|
|
|
|
|
|
|
require 5.004;
|
|
|
|
require Exporter;
|
|
|
|
|
1998-12-13 23:24:01 +00:00
|
|
|
#use strict;
|
1998-12-13 05:08:00 +00:00
|
|
|
|
|
|
|
use vars qw($VERSION @ISA @EXPORT $MANIFESTOLib);
|
|
|
|
use Mac::StandardFile;
|
|
|
|
use Moz;
|
|
|
|
use Cwd;
|
|
|
|
use Exporter;
|
|
|
|
use File::Basename;
|
|
|
|
|
|
|
|
@ISA = qw(Exporter);
|
|
|
|
@EXPORT = qw(ReconcileProject);
|
|
|
|
$VERSION = "1.00";
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
MANIFESTO - drives the Mac Project Reconciliation tool.
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
You want to use this script. It will make your life easier.
|
|
|
|
|
|
|
|
=head1 COPYRIGHT
|
|
|
|
|
1999-11-06 03:40:37 +00:00
|
|
|
The contents of this file are subject to the Netscape 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/NPL/
|
|
|
|
|
|
|
|
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 Mozilla Communicator client code, released
|
|
|
|
March 31, 1998.
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is Netscape
|
|
|
|
Communications Corporation. Portions created by Netscape are
|
|
|
|
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
|
|
|
Rights Reserved.
|
|
|
|
|
|
|
|
Contributor(s):
|
1998-12-13 05:08:00 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#
|
|
|
|
# globals
|
|
|
|
# $MANIFESTOLib - location of MANIFESTO applescript library
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# utility routines
|
|
|
|
#
|
|
|
|
|
|
|
|
sub current_directory()
|
|
|
|
{
|
|
|
|
my $current_directory = cwd();
|
|
|
|
chop($current_directory) if ( $current_directory =~ m/:$/ );
|
|
|
|
return $current_directory;
|
|
|
|
}
|
|
|
|
|
1998-12-24 19:35:20 +00:00
|
|
|
# Uses the "compile script" extension to compile a script.
|
|
|
|
sub compile_script($;$) {
|
|
|
|
my($scriptPath, $outputPath) = @_;
|
|
|
|
|
|
|
|
#// generate a script to compile a script file.
|
|
|
|
my $script = <<END_OF_APPLESCRIPT;
|
|
|
|
store script (compile script (alias "$scriptPath")) in (file "$outputPath") replacing yes
|
|
|
|
END_OF_APPLESCRIPT
|
|
|
|
|
|
|
|
#// run the script.
|
|
|
|
MacPerl::DoAppleScript($script);
|
|
|
|
}
|
|
|
|
|
1998-12-13 23:24:01 +00:00
|
|
|
# _useMANIFESTOLib()
|
1998-12-13 05:08:00 +00:00
|
|
|
# returns 1 on success
|
|
|
|
# Search the include path for the file called MANIFESTOLib
|
|
|
|
sub _useMANIFESTOLib()
|
|
|
|
{
|
|
|
|
unless ( defined($MANIFESTOLib) )
|
|
|
|
{
|
1998-12-24 19:35:20 +00:00
|
|
|
my($scriptName) = "MANIFESTOLib.script";
|
|
|
|
my($libName) = "MANIFESTOLib";
|
|
|
|
# try the directory we were run from
|
|
|
|
my($scriptPath) = dirname($0) . ":" . $scriptName;
|
|
|
|
my($libPath) = dirname($0) . ":" . $libName;
|
|
|
|
# make sure that the compiled script is up to date with the textual script.
|
|
|
|
unless (-e $libPath && getModificationDate($libPath) >= getModificationDate($scriptPath)) {
|
|
|
|
print "# Recompiling MANIFESTOLib.script.\n";
|
|
|
|
compile_script($scriptPath, $libPath);
|
1998-12-13 05:08:00 +00:00
|
|
|
}
|
1998-12-24 19:35:20 +00:00
|
|
|
if ( -e $libPath) {
|
|
|
|
$MANIFESTOLib = $libPath;
|
|
|
|
} else {
|
|
|
|
# now search the include directories
|
1998-12-13 05:08:00 +00:00
|
|
|
foreach (@INC)
|
|
|
|
{
|
|
|
|
unless ( m/^Dev:Pseudo/ ) # This is some bizarre MacPerl special-case directory
|
|
|
|
{
|
1998-12-24 19:35:20 +00:00
|
|
|
$libPath = $_ . $libName;
|
|
|
|
if (-e $libPath)
|
1998-12-13 05:08:00 +00:00
|
|
|
{
|
1998-12-24 19:35:20 +00:00
|
|
|
$MANIFESTOLib = $libPath;
|
1998-12-13 05:08:00 +00:00
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-12-24 19:35:20 +00:00
|
|
|
if (! (-e $MANIFESTOLib)) {
|
1998-12-13 05:08:00 +00:00
|
|
|
print STDERR "MANIFESTOLib lib could not be found! $MANIFESTOLib";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1998-12-13 23:24:01 +00:00
|
|
|
sub getModificationDate($) {
|
|
|
|
my($filePath)=@_;
|
|
|
|
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
|
|
|
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filePath);
|
|
|
|
return $mtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub setExtension($;$;$) {
|
|
|
|
my($filePath, $oldExtension, $newExtension)=@_;
|
|
|
|
my($name, $dir, $type) = fileparse($filePath, $oldExtension);
|
|
|
|
return "$dir$name$newExtension";
|
|
|
|
}
|
|
|
|
|
1998-12-13 05:08:00 +00:00
|
|
|
#
|
|
|
|
# ReconcileProject(projectPath, manifestoPath)
|
|
|
|
#
|
|
|
|
# Uses MANIFESTOLib AppleScript to reconcile the contents (toc?) of a
|
|
|
|
# CodeWarrior project with an external MANIFEST file.
|
|
|
|
#
|
|
|
|
|
|
|
|
sub ReconcileProject($;$) {
|
|
|
|
#// turn this feature on by removing the following line.
|
1998-12-24 19:35:20 +00:00
|
|
|
return 1;
|
1998-12-13 05:08:00 +00:00
|
|
|
|
|
|
|
my($projectPath, $manifestoPath) = @_;
|
|
|
|
my($sourceTree) = current_directory();
|
1998-12-13 23:24:01 +00:00
|
|
|
my($logPath) = setExtension($manifestoPath, ".toc", ".log");
|
|
|
|
|
|
|
|
print STDERR "# Reconciling Project: $projectPath with $manifestoPath\n";
|
|
|
|
|
|
|
|
#// compare the modification dates of the .toc and .log files. If .log is newer, do nothing.
|
|
|
|
if (-e $logPath && getModificationDate($logPath) >= getModificationDate($manifestoPath)) {
|
|
|
|
print "# Project is up to date.\n";
|
|
|
|
return 1;
|
|
|
|
}
|
1998-12-13 05:08:00 +00:00
|
|
|
|
|
|
|
_useMANIFESTOLib() || die "Could not load MANIFESTOLib\n";
|
|
|
|
|
|
|
|
my $script = <<END_OF_APPLESCRIPT;
|
|
|
|
tell (load script file "$MANIFESTOLib") to ReconcileProject("$sourceTree:", "$sourceTree$projectPath", "$sourceTree$manifestoPath")
|
|
|
|
END_OF_APPLESCRIPT
|
1998-12-13 23:24:01 +00:00
|
|
|
|
|
|
|
#// run the script, and store the results in a file called "$manifestoPath.log"
|
|
|
|
my $asresult = substr(MacPerl::DoAppleScript($script), 1, -1); #// chops off leading, trailing quotes.
|
|
|
|
|
|
|
|
#// print out to STDOUT to show progress.
|
|
|
|
print $asresult;
|
|
|
|
|
|
|
|
#// store the results in "$manifestoPath.log", which will act as a cache for later checks.
|
|
|
|
open(OUTPUT, ">$logPath") || die "can't open log file $logPath.";
|
|
|
|
print OUTPUT $asresult;
|
|
|
|
close(OUTPUT);
|
|
|
|
|
|
|
|
return 1;
|
1998-12-13 05:08:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
=pod
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
1998-12-13 23:24:01 +00:00
|
|
|
MANIFESTO - Scripts to process source .toc files.
|
1998-12-13 05:08:00 +00:00
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
1998-12-13 23:24:01 +00:00
|
|
|
use MANIFESTO;
|
|
|
|
ReconcileProject(<path to Mac project file>, <path to table of contents file>) || die "cannot reconcile project";
|
1998-12-13 05:08:00 +00:00
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
1998-12-13 23:24:01 +00:00
|
|
|
This is a PERL interface for talking to MANIFESTOLib AppleScripts.
|
1998-12-13 05:08:00 +00:00
|
|
|
|
|
|
|
=item ReconcileProject
|
|
|
|
ReconcileProject(<path to Mac project file>, <path to table of contents file>);
|
|
|
|
|
|
|
|
Reconciles the contents of a project with an external .toc file.
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item MacCVS Home Page
|
|
|
|
|
|
|
|
http://www.maccvs.org/
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=head1 AUTHORS
|
|
|
|
|
|
|
|
Patrick Beard beard@netscape.com
|
|
|
|
|
|
|
|
based on work by
|
|
|
|
|
|
|
|
Aleks Totic atotic@netscape.com
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
__END__
|