зеркало из https://github.com/mozilla/pjs.git
Added "compile_script()" which compiles a text-based AppleScript into a compiled form which runs faster. _useManifestoLib() now ensures that the compiled script is up-to-date with the text script.
This commit is contained in:
Родитель
59144c97f7
Коммит
4c30efe4aa
|
@ -60,6 +60,19 @@ sub current_directory()
|
||||||
return $current_directory;
|
return $current_directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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);
|
||||||
|
}
|
||||||
|
|
||||||
# _useMANIFESTOLib()
|
# _useMANIFESTOLib()
|
||||||
# returns 1 on success
|
# returns 1 on success
|
||||||
# Search the include path for the file called MANIFESTOLib
|
# Search the include path for the file called MANIFESTOLib
|
||||||
|
@ -67,31 +80,34 @@ sub _useMANIFESTOLib()
|
||||||
{
|
{
|
||||||
unless ( defined($MANIFESTOLib) )
|
unless ( defined($MANIFESTOLib) )
|
||||||
{
|
{
|
||||||
my($libname) = "MANIFESTOLib";
|
my($scriptName) = "MANIFESTOLib.script";
|
||||||
# try the directory we were run from
|
my($libName) = "MANIFESTOLib";
|
||||||
my($c) = dirname($0) . ":" . $libname;
|
# try the directory we were run from
|
||||||
if ( -e $c)
|
my($scriptPath) = dirname($0) . ":" . $scriptName;
|
||||||
{
|
my($libPath) = dirname($0) . ":" . $libName;
|
||||||
$MANIFESTOLib = $c;
|
# 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);
|
||||||
}
|
}
|
||||||
else
|
if ( -e $libPath) {
|
||||||
{
|
$MANIFESTOLib = $libPath;
|
||||||
# now search the include directories
|
} else {
|
||||||
|
# now search the include directories
|
||||||
foreach (@INC)
|
foreach (@INC)
|
||||||
{
|
{
|
||||||
unless ( m/^Dev:Pseudo/ ) # This is some bizarre MacPerl special-case directory
|
unless ( m/^Dev:Pseudo/ ) # This is some bizarre MacPerl special-case directory
|
||||||
{
|
{
|
||||||
$c = $_ . $libname;
|
$libPath = $_ . $libName;
|
||||||
if (-e $c)
|
if (-e $libPath)
|
||||||
{
|
{
|
||||||
$MANIFESTOLib = $c;
|
$MANIFESTOLib = $libPath;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! (-e $MANIFESTOLib))
|
if (! (-e $MANIFESTOLib)) {
|
||||||
{
|
|
||||||
print STDERR "MANIFESTOLib lib could not be found! $MANIFESTOLib";
|
print STDERR "MANIFESTOLib lib could not be found! $MANIFESTOLib";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +137,7 @@ sub setExtension($;$;$) {
|
||||||
|
|
||||||
sub ReconcileProject($;$) {
|
sub ReconcileProject($;$) {
|
||||||
#// turn this feature on by removing the following line.
|
#// turn this feature on by removing the following line.
|
||||||
return 0;
|
return 1;
|
||||||
|
|
||||||
my($projectPath, $manifestoPath) = @_;
|
my($projectPath, $manifestoPath) = @_;
|
||||||
my($sourceTree) = current_directory();
|
my($sourceTree) = current_directory();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче