Once again fix for Fix for accounting for non-Cappuccino libraries placing things on

Object.prototype and Don't recreate sprited resources every time, and fix a bug where two
bundle tasks in the same jakefile would conflict when creating sprited
resources.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2010-02-20 02:24:54 -08:00
1 parent 551677d6fd
commit 3968d35cac
4 files changed
+86 -39

No files matched your search

+4 -3
View File
@@ -258,7 +258,7 @@ function loadExecutableAndResources(/*Bundle*/ aBundle, /*BOOL*/ shouldExecute)
else
return;
// Set resolved to true here in case during evaluation this bundle
// Set resolved to true here in case during evaluation this bundle
// needs to resolve another bundle which in turn needs it to be resolved (cycle).
resolveStaticResource(aBundle._staticResource);
@@ -481,7 +481,8 @@ function executeBundle(/*Bundle*/ aBundle, /*Function*/ aCallback)
var children = staticResource.children();
for (var name in children)
staticResources.push(children[name]);
if (hasOwnProperty.call(children, name))
staticResources.push(children[name]);
}
}
@@ -513,7 +514,7 @@ function decompileStaticFile(/*Bundle*/ aBundle, /*String*/ aString, /*String*/
bundlePath = aBundle.path(),
file = NULL;
while (marker = stream.getMarker())
while (marker = stream.getMarker())
{
var text = stream.getString();
+5 -5
View File
@@ -86,7 +86,7 @@ function serializePropertyList(/*CFPropertyList*/ aPropertyList, /*Object*/ seri
if (aPropertyList === YES || aPropertyList === NO)
type = "boolean";
else if (type === "number")
{
if (FLOOR(aPropertyList) === aPropertyList)
@@ -94,12 +94,12 @@ function serializePropertyList(/*CFPropertyList*/ aPropertyList, /*Object*/ seri
else
type = "real";
}
else if (type !== "string")
{
if (aPropertyList.slice)
type = "array";
else
type = "dictionary";
}
@@ -149,7 +149,7 @@ CFPropertyListSerializers[CFPropertyList.FormatXML_v1_0] =
for (; index < count; ++index)
string += serializePropertyList(anArray[index], serializers);
return string + "</array>";
},
@@ -200,7 +200,7 @@ CFPropertyListSerializers[CFPropertyList.Format280North_v1_0] =
{
return STRING_MARKER + ';' + aString.length + ';' + aString;
},
"boolean" : function(/*Boolean*/ aBoolean)
{
return (aBoolean ? TRUE_MARKER : FALSE_MARKER) + ';';
@@ -467,7 +467,11 @@ BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPa
FILE.write(spritedDestinationPath, base64.encode(FILE.read(aResourcePath, "b")), { charset:"UTF-8" });
});
task (anEnvironment.name() + "-sprites", [spritedDestinationPath]);
filedir (this.buildProductDataURLPathForEnvironment(anEnvironment), [spritedDestinationPath]);
filedir (this.buildProductMHTMLPathForEnvironment(anEnvironment), [spritedDestinationPath]);
filedir (this.buildProductMHTMLDataPathForEnvironment(anEnvironment), [spritedDestinationPath]);
filedir (this.buildProductMHTMLTestPathForEnvironment(anEnvironment), [spritedDestinationPath]);
}, this);
}
@@ -589,67 +593,109 @@ BundleTask.prototype.defineSpritedImagesTask = function()
return;
var folder = anEnvironment.name() + ".environment",
resourcesPath = FILE.join(this.buildIntermediatesProductPath(), folder, "Resources", ""),
dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment),
MHTMLPath = this.buildProductMHTMLPathForEnvironment(anEnvironment),
MHTMLDataPath = this.buildProductMHTMLDataPathForEnvironment(anEnvironment),
MHTMLTestDestinationPath = this.buildProductMHTMLTestPathForEnvironment(anEnvironment),
productName = this.productName();
resourcesPath = FILE.join(this.buildIntermediatesProductPath(), folder, "Resources", "");
task(anEnvironment.name() + "-sprites", function(aTask)
function isDataResource(/*String*/ aFilename)
{
TERM.stream.print("Creating sprited images file... \0green(" + dataURLPath +"\0)");
return FILE.isFile(aFilename) && aFilename.indexOf(resourcesPath) === 0 && isImage(aFilename);
}
var dataURLStream = FILE.open(dataURLPath, "w+", { charset:"UTF-8" }),
MHTMLStream = FILE.open(MHTMLPath, "w+", { charset:"UTF-8" }),
MHTMLDataStream = FILE.open(MHTMLDataPath, "w+", { charset:"UTF-8" });
var productName = this.productName(),
dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment);
filedir (dataURLPath, function(aTask)
{
TERM.stream.print("Creating data URLs file... \0green(" + dataURLPath +"\0)");
var dataURLStream = FILE.open(dataURLPath, "w+", { charset:"UTF-8" });
dataURLStream.write("@STATIC;1.0;");
MHTMLStream.write("@STATIC;1.0;");
MHTMLDataStream.write("/*\r\nContent-Type: multipart/related; boundary=\"_ANY_STRING_WILL_DO_AS_A_SEPARATOR\"\r\n\r\n");
aTask.prerequisites().forEach(function(aFilename)
{
if (!FILE.isFile(aFilename) || aFilename.indexOf(resourcesPath) !== 0 || !isImage(aFilename))
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
dataURLStream.write("u;" + resourcePath.length + ";" + resourcePath);
MHTMLStream.write("u;" + resourcePath.length + ";" + resourcePath);
// As data URL...
var contents = "data:" + mimeType(aFilename) +
";base64," + FILE.read(aFilename, "b").decodeToString("UTF-8");
dataURLStream.write(contents.length + ";" + contents);
});
// As MHTML...
contents = "mhtml:" + FILE.join(folder, "MHTMLData.txt!") + resourcePath;
dataURLStream.write("e;");
dataURLStream.close();
});
this.enhance([dataURLPath]);
var MHTMLPath = this.buildProductMHTMLPathForEnvironment(anEnvironment);
filedir (MHTMLPath, function(aTask)
{
TERM.stream.print("Creating MHTML paths file... \0green(" + MHTMLPath +"\0)");
var MHTMLStream = FILE.open(MHTMLPath, "w+", { charset:"UTF-8" });
MHTMLStream.write("@STATIC;1.0;");
aTask.prerequisites().forEach(function(aFilename)
{
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
MHTMLStream.write("u;" + resourcePath.length + ";" + resourcePath);
});
MHTMLStream.close();
});
this.enhance([MHTMLPath]);
var MHTMLDataPath = this.buildProductMHTMLDataPathForEnvironment(anEnvironment);
filedir (MHTMLDataPath, function(aTask)
{
TERM.stream.print("Creating MHTML images file... \0green(" + MHTMLDataPath +"\0)");
var MHTMLDataStream = FILE.open(MHTMLDataPath, "w+", { charset:"UTF-8" });
MHTMLDataStream.write("/*\r\nContent-Type: multipart/related; boundary=\"_ANY_STRING_WILL_DO_AS_A_SEPARATOR\"\r\n\r\n");
aTask.prerequisites().forEach(function(aFilename)
{
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
MHTMLDataStream.write("--_ANY_STRING_WILL_DO_AS_A_SEPARATOR\r\n");
MHTMLDataStream.write("Content-Location:" + resourcePath + "\r\nContent-Transfer-Encoding:base64\r\n\r\n");
MHTMLDataStream.write(FILE.read(aFilename, "b").decodeToString("UTF-8"));
MHTMLDataStream.write("\r\n");
MHTMLStream.write(contents.length + ";" + contents);
});
dataURLStream.write("e;");
dataURLStream.close();
MHTMLStream.write("e;");
MHTMLStream.close();
MHTMLDataStream.write("*/");
MHTMLDataStream.close();
});
this.enhance([MHTMLDataPath]);
var MHTMLTestDestinationPath = this.buildProductMHTMLTestPathForEnvironment(anEnvironment);
filedir (MHTMLTestDestinationPath, function(aTask)
{
TERM.stream.print("Copying MHTML test file... \0green(" + MHTMLTestDestinationPath +"\0)");
// copy the MHTML test file into this environment
FILE.copy(MHTMLTestPath, MHTMLTestDestinationPath);
});
this.enhance([anEnvironment.name() + "-sprites"]);
this.enhance([MHTMLTestDestinationPath]);
}, this);
}
+1 -1
View File
@@ -64,7 +64,7 @@ var DefaultDictionary = nil,
temporaryDictionary = [CPDictionary dictionary];
if (path && FILE.isReadable(path))
dictionary = CFPropertyList.propertyListFromFile(path);
dictionary = CFPropertyList.readPropertyListFromFile(path);
// readPlist will return nil if the file is empty
if (!dictionary)