Merge branch 'master' of git://github.com/280north/cappuccino

This commit is contained in:
Randall Luecke
2010-02-20 03:59:40 -05:00
25 changed files with 311 additions and 207 deletions
+2
View File
@@ -1,6 +1,8 @@
require("../common.jake");
var framework = require("objective-j/jake").framework;
var BundleTask = require("objective-j/jake").BundleTask;
$BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, 'AppKit');
+1
View File
@@ -1,6 +1,7 @@
require("../../../common.jake");
var blend = require("cappuccino/jake").blend;
blend ("Aristo.blend", function(aristoTask)
{
+2
View File
@@ -1,6 +1,8 @@
require("../../../common.jake");
var framework = require("objective-j/jake").framework;
var BundleTask = require("objective-j/jake").BundleTask;
blendKitTask = framework ("BlendKit", function(blendKitTask)
{
-1
View File
@@ -3,7 +3,6 @@ require("../../../common.jake");
var FILE = require("file");
$BLENDTASK = "blendtask.j";
$BUILD_CJS_BLENDTASK = FILE.join($BUILD_CJS_CAPPUCCINO, "lib", "cappuccino", "jake", "blendtask.j");
-2
View File
@@ -1,6 +1,4 @@
#!/usr/bin/env narwhal
require("../../common.jake");
subtasks(["BlendKit", "CommonJS", "Aristo"], ["build", "clean", "clobber"]);
-1
View File
@@ -1,7 +1,6 @@
require("../common.jake");
var FILE = require("file");
new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
+15
View File
@@ -70,6 +70,11 @@
return self;
}
- (id)initWithString:(CPString)aString
{
return [self initWithSerializedPlistObject:aPlistObject];
}
- (id)initWithSerializedPlistObject:(id)aPlistObject
{
self = [super init];
@@ -90,6 +95,16 @@
return self;
}
- (void)setString:(CPString)aString
{
return [self setSerializedPlistObject:aString];
}
- (CPString)string
{
return [self serializedPlistObject];
}
- (int)length
{
return [[self encodedString] length];
+2
View File
@@ -22,6 +22,8 @@
require("../common.jake");
var framework = require("objective-j/jake").framework;
var BundleTask = require("objective-j/jake").BundleTask;
foundationTask = framework ("Foundation", function(foundationTask)
{
+7 -4
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env narwhal
require("./common.jake");
var FILE = require("file"),
SYSTEM = require("system"),
@@ -6,8 +7,6 @@ var FILE = require("file"),
jake = require("jake"),
stream = require("term").stream;
require(FILE.absolute("common.jake"));
var subprojects = ["Objective-J", "CommonJS", "Foundation", "AppKit", "Tools"];
["build", "clean", "clobber"].forEach(function(aTaskName)
@@ -57,7 +56,11 @@ task ("sudo-install", ["CommonJS"], function()
// FIXME: require("narwhal/tusk/install").install({}, $COMMONJS);
// Doesn't work due to some weird this.print business.
if (OS.system(["sudo", "tusk", "install", "--force", $BUILD_CJS_OBJECTIVE_J, $BUILD_CJS_CAPPUCCINO]))
OS.exit(1); //rake abort if ($? != 0)
{
// Attempt a hackish work-around for sudo compiled with the --with-secure-path option
if (OS.system("sudo bash -c 'source `sh shell_config_file.sh`; tusk install --force " + $BUILD_CJS_OBJECTIVE_J + " " + $BUILD_CJS_CAPPUCCINO + "'"))
OS.exit(1); //rake abort if ($? != 0)
}
});
// Documentation
+40 -21
View File
@@ -283,7 +283,7 @@ function loadExecutableForBundle(/*Bundle*/ aBundle, success, failure)
{
try
{
decompileStaticFile(aBundle, anEvent.request.responseText());
decompileStaticFile(aBundle, anEvent.request.responseText(), aBundle.executablePath());
aBundle._loadStatus &= ~CFBundleLoadingExecutable;
success();
}
@@ -319,7 +319,7 @@ function loadSpritedImagesForBundle(/*Bundle*/ aBundle, success, failure)
{
try
{
decompileStaticFile(aBundle, anEvent.request.responseText());
decompileStaticFile(aBundle, anEvent.request.responseText(), spritedImagesPath);
aBundle._loadStatus &= ~CFBundleLoadingSpritedImages;
success();
}
@@ -356,9 +356,10 @@ function CFBundleTestSpriteSupport(/*String*/ MHTMLPath, /*Function*/ aCallback)
CFBundleDataURLSpriteType,
"data:image/gif;base64,R0lGODlhAQABAIAAAMc9BQAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==",
CFBundleMHTMLSpriteType,
MHTMLPath,
MHTMLPath+"!test",
CFBundleMHTMLUncachedSpriteType,
MHTMLPath+"?"+CFCacheBuster]);
MHTMLPath+"?"+CFCacheBuster+"!test"
]);
}
function CFBundleNotifySpriteSupportListeners()
@@ -371,6 +372,13 @@ function CFBundleNotifySpriteSupportListeners()
function CFBundleTestSpriteTypes(/*Array*/ spriteTypes)
{
if (spriteTypes.length < 2)
{
CFBundleSupportedSpriteType = CFBundleNoSpriteType;
CFBundleNotifySpriteSupportListeners();
return;
}
var image = new Image();
image.onload = function()
@@ -386,21 +394,25 @@ function CFBundleTestSpriteTypes(/*Array*/ spriteTypes)
image.onerror = function()
{
if (spriteTypes.length === 2)
{
CFBundleSupportedSpriteType = CFBundleNoSpriteType;
CFBundleNotifySpriteSupportListeners();
}
else
CFBundleTestSpriteTypes(spriteTypes.slice(2));
CFBundleTestSpriteTypes(spriteTypes.slice(2));
}
image.src = spriteTypes[1];
}
function mhtmlBasePath()
{
#ifdef BROWSER
//FIXME: URL stuff is kind of broken
return window.location.protocol + "//" + window.location.hostname + (window.location.port ? (":" + window.location.port) : "");
#else
return "";
#endif
}
function spritedImagesTestPathForBundle(/*Bundle*/ aBundle)
{
return FILE.join(aBundle.path(), aBundle.mostEligibleEnvironment() + ".environment", "MHTMLTest.txt");
return "mhtml:" + mhtmlBasePath() + FILE.join(aBundle.path(), aBundle.mostEligibleEnvironment() + ".environment", "MHTMLTest.txt");
}
function spritedImagesPathForBundle(/*Bundle*/ aBundle)
@@ -408,12 +420,9 @@ function spritedImagesPathForBundle(/*Bundle*/ aBundle)
if (CFBundleSupportedSpriteType === CFBundleDataURLSpriteType)
return FILE.join(aBundle.path(), aBundle.mostEligibleEnvironment() + ".environment", "dataURLs.txt");
if (CFBundleSupportedSpriteType === CFBundleMHTMLSpriteType)
return FILE.join(aBundle.path(), aBundle.mostEligibleEnvironment() + ".environment", "MHTML.txt");
if (CFBundleSupportedSpriteType === CFBundleMHTMLSpriteType || CFBundleSupportedSpriteType === CFBundleMHTMLUncachedSpriteType)
return mhtmlBasePath() + FILE.join(aBundle.path(), aBundle.mostEligibleEnvironment() + ".environment", "MHTMLPaths.txt");
if (CFBundleSupportedSpriteType === CFBundleMHTMLUncachedSpriteType)
return FILE.join(aBundle.path(), aBundle.mostEligibleEnvironment() + ".environment", "MHTML.txt?" + CFCacheBuster);
return NULL;
}
@@ -482,15 +491,15 @@ var STATIC_MAGIC_NUMBER = "@STATIC",
MARKER_IMPORT_STD = 'I',
MARKER_IMPORT_LOCAL = 'i';
function decompileStaticFile(/*Bundle*/ aBundle, /*String*/ aString)
function decompileStaticFile(/*Bundle*/ aBundle, /*String*/ aString, /*String*/ aPath)
{
var stream = new MarkedStream(aString);
if (stream.magicNumber() !== STATIC_MAGIC_NUMBER)
throw new Error("Could not read static file.");
throw new Error("Could not read static file: "+aPath);
if (stream.version() !== "1.0")
throw new Error("Could not read static file.");
throw new Error("Could not read static file: "+aPath);
var marker,
bundlePath = aBundle.path(),
@@ -513,8 +522,18 @@ function decompileStaticFile(/*Bundle*/ aBundle, /*String*/ aString)
var URI = stream.getString();
if (URI.toLowerCase().indexOf("mhtml:") === 0)
URI = "mhtml:" + FILE.join(bundlePath, URI.substr("mhtml:".length));
{
URI = "mhtml:" + mhtmlBasePath() + FILE.join(bundlePath, URI.substr("mhtml:".length));
if (CFBundleSupportedSpriteType === CFBundleMHTMLUncachedSpriteType)
{
var exclamationIndex = URI.indexOf("!"),
firstPart = URI.substring(0, exclamationIndex),
lastPart = URI.substring(exclamationIndex);
URI = firstPart + "?" + CFCacheBuster + lastPart;
}
}
aBundle._URIMap[text] = URI;
// The unresolved directories must not be bundles.
+2 -2
View File
@@ -66,9 +66,9 @@ CFPropertyList.readPropertyListFromFile = function(/*String*/ aFilePath)
return CFPropertyList.propertyListFromString(FILE.read(aFilePath, { charset:"UTF-8" }));
}
CFPropertyList.writePropertyListToFile = function(/*CFPropertyList*/ aPropertyList, /*String*/ aFilePath)
CFPropertyList.writePropertyListToFile = function(/*CFPropertyList*/ aPropertyList, /*String*/ aFilePath, /*Format*/ aFormat)
{
return FILE.write(aFilePath, CFPropertyList.stringFromPropertyList(aPropertyList), { charset:"UTF-8" });
return FILE.write(aFilePath, CFPropertyList.stringFromPropertyList(aPropertyList, aFormat), { charset:"UTF-8" });
}
#endif
@@ -0,0 +1,9 @@
/*
Content-Type: multipart/related; boundary="_SEPARATOR_"
--_SEPARATOR_
Content-Location:test
Content-Transfer-Encoding:base64
R0lGODlhAQABAIAAAMc9BQAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
*/
@@ -1,6 +1,6 @@
var FILE = require("file"),
OS = require("OS"),
OS = require("os"),
Jake = require("jake"),
BundleTask = require("objective-j/jake/bundletask").BundleTask;
@@ -317,7 +317,17 @@ BundleTask.prototype.buildProductStaticPathForEnvironment = function(anEnvironme
BundleTask.prototype.buildProductMHTMLPathForEnvironment = function(anEnvironment)
{
return FILE.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTML.txt");
return FILE.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLPaths.txt");
}
BundleTask.prototype.buildProductMHTMLDataPathForEnvironment = function(anEnvironment)
{
return FILE.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLData.txt");
}
BundleTask.prototype.buildProductMHTMLTestPathForEnvironment = function(anEnvironment)
{
return FILE.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLTest.txt");
}
BundleTask.prototype.buildProductDataURLPathForEnvironment = function(anEnvironment)
@@ -460,8 +470,7 @@ BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPa
FILE.write(spritedDestinationPath, base64.encode(FILE.read(aResourcePath, "b")), { charset:"UTF-8" });
});
filedir (this.buildProductDataURLPathForEnvironment(anEnvironment), [spritedDestinationPath]);
filedir (this.buildProductMHTMLPathForEnvironment(anEnvironment), [spritedDestinationPath]);
task (anEnvironment.name() + "-sprites", [spritedDestinationPath]);
}, this);
}
@@ -571,6 +580,10 @@ BundleTask.prototype.defineResourceTasks = function()
}, this);
}
var RESOURCES_PATH = FILE.join(FILE.absolute(FILE.dirname(module.path)), "RESOURCES"),
MHTMLTestPath = FILE.join(RESOURCES_PATH, "MHTMLTest.txt");
BundleTask.prototype.defineSpritedImagesTask = function()
{
this.environments().forEach(function(/*Environment*/ anEnvironment)
@@ -580,16 +593,23 @@ BundleTask.prototype.defineSpritedImagesTask = function()
var folder = anEnvironment.name() + ".environment",
resourcesPath = FILE.join(this.buildIntermediatesProductPath(), folder, "Resources", ""),
productName = this.productName(),
dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment);
dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment),
MHTMLPath = this.buildProductMHTMLPathForEnvironment(anEnvironment),
MHTMLDataPath = this.buildProductMHTMLDataPathForEnvironment(anEnvironment),
MHTMLTestDestinationPath = this.buildProductMHTMLTestPathForEnvironment(anEnvironment),
productName = this.productName();
filedir (dataURLPath, function(aTask)
task(anEnvironment.name() + "-sprites", function(aTask)
{
TERM.stream.print("Creating data URLs file... \0green(" + dataURLPath + "\0)");
TERM.stream.print("Creating sprited images file... \0green(" + dataURLPath +"\0)");
var dataURLStream = FILE.open(dataURLPath, "w+", { charset:"UTF-8" });
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" });
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)
{
@@ -599,56 +619,39 @@ BundleTask.prototype.defineSpritedImagesTask = function()
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);
});
dataURLStream.write("e;");
dataURLStream.close();
});
this.enhance([dataURLPath]);
var MHTMLPath = this.buildProductMHTMLPathForEnvironment(anEnvironment);
filedir (MHTMLPath, function(aTask)
{
TERM.stream.print("Creating MHTML images file... \0green(" + MHTMLPath +"\0)");
var MHTMLStream = FILE.open(MHTMLPath, "w+", { charset:"UTF-8" }),
MHTMLContents = "/*\r\nContent-Type: multipart/related; boundary=\"_ANY_STRING_WILL_DO_AS_A_SEPARATOR\"\r\n\r\n";
MHTMLStream.write("@STATIC;1.0;");
aTask.prerequisites().forEach(function(aFilename)
{
if (!FILE.isFile(aFilename) || aFilename.indexOf(resourcesPath) !== 0 || !isImage(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
MHTMLStream.write("u;" + resourcePath.length + ";" + resourcePath);
// As MHTML...
contents = "mhtml:" + FILE.join(folder, productName + ".sj!") + resourcePath;
contents = "mhtml:" + FILE.join(folder, "MHTMLData.txt!") + resourcePath;
MHTMLContents += "--_ANY_STRING_WILL_DO_AS_A_SEPARATOR\r\n";
MHTMLContents += "Content-Location:" + resourcePath + "\r\nContent-Transfer-Encoding:base64\r\n\r\n";
MHTMLContents += FILE.read(aFilename, "b").decodeToString("UTF-8");
MHTMLContents += "\r\n";
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.write(MHTMLContents + "*/");
MHTMLStream.close();
MHTMLDataStream.write("*/");
MHTMLDataStream.close();
// copy the MHTML test file into this environment
FILE.copy(MHTMLTestPath, MHTMLTestDestinationPath);
});
this.enhance([MHTMLPath]);
this.enhance([anEnvironment.name() + "-sprites"]);
}, this);
}
@@ -668,8 +671,7 @@ BundleTask.prototype.defineStaticTask = function()
{
TERM.stream.print("Creating static file... \0green(" + staticPath +"\0)");
var fileStream = FILE.open(staticPath, "w+", { charset:"UTF-8" }),
MHTMLContents = "";
var fileStream = FILE.open(staticPath, "w+", { charset:"UTF-8" });
fileStream.write("@STATIC;1.0;");
+15 -11
View File
@@ -12,13 +12,15 @@ function EventDispatcher(/*Object*/ anOwner)
EventDispatcher.prototype.addEventListener = function(/*String*/ anEventName, /*Function*/ anEventListener)
{
var eventListenersForEventName = this._eventListenersForEventNames[anEventName];
var eventListenersForEventNames = this._eventListenersForEventNames;
if (!eventListenersForEventName)
if (!hasOwnProperty.call(this._eventListenersForEventNames, anEventName))
{
eventListenersForEventName = [];
this._eventListenersForEventNames[anEventName] = eventListenersForEventName;
var eventListenersForEventName = [];
eventListenersForEventNames[anEventName] = eventListenersForEventName;
}
else
var eventListenersForEventName = eventListenersForEventNames[anEventName];
var index = eventListenersForEventName.length;
@@ -31,12 +33,13 @@ EventDispatcher.prototype.addEventListener = function(/*String*/ anEventName, /*
EventDispatcher.prototype.removeEventListener = function(/*String*/ anEventName, /*Function*/ anEventListener)
{
var eventListenersForEventName = this._eventListenersForEventNames[anEventName];
var eventListenersForEventNames = this._eventListenersForEventNames;
if (!eventListenersForEventName)
if (!hasOwnProperty.call(eventListenersForEventNames, anEventName))
return;
var index = eventListenersForEventName.length;
var eventListenersForEventName = eventListenersForEventNames[anEventName].
index = eventListenersForEventName.length;
while (index--)
if (eventListenersForEventName[index] === anEventListener)
@@ -46,13 +49,14 @@ EventDispatcher.prototype.removeEventListener = function(/*String*/ anEventName,
EventDispatcher.prototype.dispatchEvent = function(/*Event*/ anEvent)
{
var type = anEvent.type,
eventListenersForEventName = this._eventListenersForEventNames[type];
eventListenersForEventNames = this._eventListenersForEventNames;
if (eventListenersForEventName)
if (hasOwnProperty.call(eventListenersForEventNames, type))
{
var index = 0,
var eventListenersForEventName = this._eventListenersForEventNames[type],
index = 0,
count = eventListenersForEventName.length;
for (; index < count; ++index)
eventListenersForEventName[index](anEvent);
}
+2 -1
View File
@@ -20,11 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
require("../common.jake");
var FILE = require("file"),
OS = require("os"),
stream = require("term").stream;
require("../common.jake");
//$BUILD_CONFIGURATION_DIR = "../Build"
$BROWSER_FILE = FILE.join("Browser", "Objective-J.js");
+7
View File
@@ -146,6 +146,13 @@ function preprocess(/*String*/ aString, /*String*/ aPath, /*unsigned*/ flags)
return new Preprocessor(aString, aPath, flags).executable();
}
objj_preprocess = preprocess;
objj_eval = function(/*String*/ aString)
{
return eval(objj_preprocess(aString).code());
}
function Preprocessor(/*String*/ aString, /*String*/ aPath, /*unsigned*/ flags)
{
// Remove the shebang.
-2
View File
@@ -1,7 +1,5 @@
#!/usr/bin/env narwhal
require("../common.jake");
// nib2cib has to come before capp since capp uses nib2cib
subtasks(["nib2cib", "capp"/*, "bake"*/, "press"], ["build"/*, "clean", "clobber"*/]);
+135 -74
View File
@@ -6,69 +6,98 @@ var OS = require("os"),
FILE = require("file"),
OBJJ = require("objective-j");
var stream = require("term").stream;
var parser = new (require("args").Parser)();
parser.usage("DESTINATION_DIRECTORY");
parser.help("Generate a Cappuccino project or Frameworks directory");
parser.option("-t", "--template", "template")
.set()
.def("Application")
.help("Selects a project template to use (default: Application).");
parser.option("-f", "--frameworks", "justFrameworks")
.set(true)
.help("Only generate or update Frameworks directory.");
parser.option("-F", "--framework", "framework", "frameworks")
.def([])
.push()
.help("Additional framework to copy/symlink (default: Objective-J, Foundation, AppKit)");
parser.option("--no-frameworks", "noFrameworks")
.set(true)
.help("Don't copy any default frameworks (can be overridden with -F)");
parser.option("--symlink", "symlink")
.set(true)
.help("Creates a symlink to each framework instead of copying.");
parser.option("--build", "useCappBuild")
.set(true)
.help("Uses frameworks in the $CAPP_BUILD.");
parser.option("-l")
.action(function(o) { o.symlink = o.shouldUseCappBuild = true; })
.help("Enables both the --symlink and --build options.");
parser.option("--force", "force")
.set(true)
.help("Overwrite update existing frameworks.");
parser.option("--noconfig", "noconfig")
.set()
.help("Selects a project template to use.");
parser.option("--list-templates", "listTemplates")
.set(true)
.help("Lists available templates.");
parser.option("--list-frameworks", "listFrameworks")
.set(true)
.help("Lists available frameworks.");
parser.helpful();
// FIXME: better way to do this:
var CAPP_HOME = require("packages").catalog["cappuccino"].directory;
var templatesDirectory = FILE.join(CAPP_HOME, "lib", "capp", "Resources", "Templates");
function gen(/*va_args*/)
{
var index = 0,
count = arguments.length,
var args = ["capp gen"].concat(Array.prototype.slice.call(arguments));
var options = parser.parse(args);
shouldSymbolicallyLink = false,
shouldUseCappBuild = false,
justFrameworks = false,
noConfig = false,
force = false,
template = "Application",
destination = "";
if (options.listTemplates) {
listTemplates();
return;
}
for (; index < count; ++index)
{
var argument = arguments[index];
if (options.listFrameworks) {
listFrameworks();
return;
}
switch (argument)
{
var destination = options.args[0];
case "-l": shouldSymbolicallyLink = true;
shouldUseCappBuild = true;
break;
case "--symlink":
shouldSymbolicallyLink = true;
break;
case "--build":
shouldUseCappBuild = true;
break;
case "-t":
case "--template": template = arguments[++index];
break;
case "-f":
case "--frameworks": justFrameworks = true;
break;
case "--noconfig": noConfig = true;
break;
case "--force": force = true;
break;
default: destination = argument;
if (!destination) {
if (options.justFrameworks)
destination = ".";
else {
parser.printUsage(options);
OS.exit(1);
}
}
if (destination.length === 0)
destination = justFrameworks ? "." : "Untitled";
var sourceTemplate = null;
if (FILE.isAbsolute(template))
sourceTemplate = FILE.join(template);
if (FILE.isAbsolute(options.template))
sourceTemplate = FILE.join(options.template);
else
sourceTemplate = FILE.join(CAPP_HOME, "lib", "capp", "Resources", "Templates", template);
sourceTemplate = FILE.join(templatesDirectory, options.template);
var configFile = FILE.join(sourceTemplate, "template.config"),
config = {};
@@ -77,10 +106,15 @@ function gen(/*va_args*/)
config = JSON.parse(FILE.read(configFile, { charset:"UTF-8" }));
var destinationProject = destination,
configuration = noConfig ? [Configuration defaultConfiguration] : [Configuration userConfiguration];
configuration = options.noconfig ? [Configuration defaultConfiguration] : [Configuration userConfiguration];
if (justFrameworks)
createFrameworksInFile(destinationProject, shouldSymbolicallyLink, shouldUseCappBuild, force);
var frameworks = options.frameworks;
if (!options.noFrameworks) {
frameworks.push("Objective-J", "Foundation", "AppKit");
}
if (options.justFrameworks)
createFrameworksInFile(frameworks, destinationProject, options.symlink, options.useCappBuild, options.force);
else if (!FILE.exists(destinationProject))
{
@@ -124,7 +158,7 @@ function gen(/*va_args*/)
}
catch (anException)
{
print("Copying and modifying " + path + " failed.");
stream.print("Copying and modifying " + path + " failed.");
}
}
@@ -133,24 +167,23 @@ function gen(/*va_args*/)
if (config.FrameworksPath)
frameworkDestination = FILE.join(frameworkDestination, config.FrameworksPath);
createFrameworksInFile(frameworkDestination, shouldSymbolicallyLink, shouldUseCappBuild);
createFrameworksInFile(frameworks, frameworkDestination, options.symlink, options.useCappBuild);
}
else
print("Directory already exists");
stream.print("Directory already exists");
}
function createFrameworksInFile(/*String*/ aFile, /*Boolean*/ symlink, /*Boolean*/ build, /*Boolean*/ force)
function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolean*/ symlink, /*Boolean*/ build, /*Boolean*/ force)
{
var destination = FILE.path(FILE.absolute(aFile));
var frameworks = ["Foundation", "AppKit"];
if (!destination.isDirectory())
throw new Error("Can't create Frameworks. Directory does not exist: " + destination);
var destinationFrameworks = destination.join("Frameworks"),
destinationDebugFrameworks = destination.join("Frameworks", "Debug");
print("Creating Frameworks directory in " + destinationFrameworks + ".");
stream.print("Creating Frameworks directory in " + destinationFrameworks + ".");
//destinationFrameworks.mkdirs(); // redundant
destinationDebugFrameworks.mkdirs();
@@ -164,24 +197,29 @@ function createFrameworksInFile(/*String*/ aFile, /*Boolean*/ symlink, /*Boolean
var sourceFrameworks = builtFrameworks.join("Release"),
sourceDebugFrameworks = builtFrameworks.join("Debug");
frameworks.concat("Objective-J").forEach(function(framework) {
frameworks.forEach(function(framework) {
installFramework(sourceFrameworks.join(framework), destinationFrameworks.join(framework), force, symlink);
installFramework(sourceDebugFrameworks.join(framework), destinationDebugFrameworks.join(framework), force, symlink);
});
}
else {
// Objective-J. Take from OBJJ_HOME.
var objjHome = FILE.path(OBJJ.OBJJ_HOME);
var objjPath = objjHome.join("Frameworks", "Objective-J");
var objjDebugPath = objjHome.join("Frameworks", "Debug", "Objective-J");
installFramework(objjPath, destinationFrameworks.join("Objective-J"), force, symlink);
installFramework(objjDebugPath, destinationDebugFrameworks.join("Objective-J"), force, symlink);
// Frameworks. Search frameworks paths
frameworks.forEach(function(framework) {
// Need a special case for Objective-J
if (framework === "Objective-J") {
// Objective-J. Take from OBJJ_HOME.
var objjHome = FILE.path(OBJJ.OBJJ_HOME);
var objjPath = objjHome.join("Frameworks", "Objective-J");
var objjDebugPath = objjHome.join("Frameworks", "Debug", "Objective-J");
installFramework(objjPath, destinationFrameworks.join("Objective-J"), force, symlink);
installFramework(objjDebugPath, destinationDebugFrameworks.join("Objective-J"), force, symlink);
return;
}
var found;
for (var i = 0, found = false; !found && i < OBJJ.objj_frameworks.length; i++) {
var sourceFramework = FILE.path(OBJJ.objj_frameworks[i]).join(framework);
if (FILE.isDirectory(sourceFramework)) {
@@ -190,8 +228,8 @@ function createFrameworksInFile(/*String*/ aFile, /*Boolean*/ symlink, /*Boolean
}
}
if (!found)
print("Warning: Couldn't find framework \"" + framework +"\"");
stream.print("\0yellow(Warning:\0) Couldn't find framework \0cyan(" + framework +"\0)");
for (var i = 0, found = false; !found && i < OBJJ.objj_debug_frameworks.length; i++) {
var sourceDebugFramework = FILE.path(OBJJ.objj_debug_frameworks[i]).join(framework);
if (FILE.isDirectory(sourceDebugFramework)) {
@@ -200,7 +238,7 @@ function createFrameworksInFile(/*String*/ aFile, /*Boolean*/ symlink, /*Boolean
}
}
if (!found)
print("Warning: Couldn't find debug framework \"" + framework +"\"");
stream.print("\0yellow(Warning:\0) Couldn't find debug framework \0cyan(" + framework +"\0)");
});
}
}
@@ -210,19 +248,19 @@ function installFramework(source, dest, force, symlink) {
if (force) {
dest.rmtree();
} else {
print("Warning: " + dest + " already exists. Use --force to overwrite.");
stream.print("\0yellow(Warning:\0) " + dest + " already exists. Use --force to overwrite.");
return;
}
}
if (source.exists()) {
print((symlink ? "Symlinking " : "Copying ") + source + " to " + dest);
stream.print((symlink ? "Symlinking " : "Copying ") + source + " to " + dest);
if (symlink)
FILE.symlink(source, dest);
else
FILE.copyTree(source, dest);
}
else
print("Warning: "+source+" doesn't exist.");
stream.print("\0yellow(Warning:\0) "+source+" doesn't exist.");
}
function toIdentifier(/*String*/ aString)
@@ -253,3 +291,26 @@ function toIdentifier(/*String*/ aString)
return identifier;
}
function listTemplates() {
FILE.list(templatesDirectory).forEach(function(templateName) {
stream.print(templateName);
});
}
function listFrameworks() {
stream.print("Frameworks:");
OBJJ.objj_frameworks.forEach(function(frameworksDirectory) {
stream.print(" " + frameworksDirectory);
FILE.list(frameworksDirectory).forEach(function(templateName) {
stream.print(" + " + templateName);
});
});
stream.print("Frameworks (Debug):");
OBJJ.objj_debug_frameworks.forEach(function(frameworksDirectory) {
stream.print(" " + frameworksDirectory);
FILE.list(frameworksDirectory).forEach(function(frameworkName) {
stream.print(" + " + frameworkName);
});
});
}
+2 -1
View File
@@ -1,7 +1,8 @@
require ("../../common.jake");
var app = require("objective-j/jake").app;
var BundleTask = require("objective-j/jake").BundleTask;
app ("capp", function(cappTask)
{
+4 -3
View File
@@ -1,9 +1,10 @@
var FILE = require("file");
require("../../common.jake");
var FILE = require("file");
var app = require("objective-j/jake").app;
var BundleTask = require("objective-j/jake").BundleTask;
app ("nib2cib", function(nib2cibTask)
{
+2 -1
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env narwhal
require ("../../common.jake");
var app = require("objective-j/jake").app;
var BundleTask = require("objective-j/jake").BundleTask;
app ("press", function(pressTask)
{
+1 -11
View File
@@ -35,17 +35,7 @@ function ask_remove_dir () {
function ask_append_shell_config () {
config_string="$1"
shell_config_file=""
# use order outlined by http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup
if [ -f "$HOME/.bash_profile" ]; then
shell_config_file="$HOME/.bash_profile"
elif [ -f "$HOME/.bash_login" ]; then
shell_config_file="$HOME/.bash_login"
elif [ -f "$HOME/.profile" ]; then
shell_config_file="$HOME/.profile"
elif [ -f "$HOME/.bashrc" ]; then
shell_config_file="$HOME/.bashrc"
fi
shell_config_file=`sh shell_config_file.sh`
echo " \"$config_string\" will be appended to \"$shell_config_file\"."
if prompt; then
+3 -27
View File
@@ -180,43 +180,19 @@ function reforkWithPackages()
reforkWithPackages();
function throwIfNotRequireError(e) {
function handleSetupEnvironmentError(e) {
if (String(e).indexOf("require error")==-1) {
print("setupEnvironment: " + e);
throw e;
//throw e;
}
}
function setupEnvironment()
{
// TODO: deprecate these globals
try {
var OBJECTIVE_J_JAKE = require("objective-j/jake");
global.app = OBJECTIVE_J_JAKE.app;
global.bundle = OBJECTIVE_J_JAKE.bundle;
global.framework = OBJECTIVE_J_JAKE.framework;
global.BundleTask = OBJECTIVE_J_JAKE.BundleTask;
} catch (e) {
throwIfNotRequireError(e);
}
try {
require("objective-j").OBJJ_INCLUDE_PATHS.push(FILE.join($BUILD_CONFIGURATION_DIR, "CommonJS", "cappuccino", "Frameworks"));
} catch (e) {
throwIfNotRequireError(e);
}
try {
var CAPPUCCINO_JAKE = require("cappuccino/jake");
if (CAPPUCCINO_JAKE.blend)
global.blend = CAPPUCCINO_JAKE.blend;
//else
// print("no blend!")
}
catch (e) {
throwIfNotRequireError(e);
handleSetupEnvironmentError(e);
}
}
+13
View File
@@ -0,0 +1,13 @@
shell_config_file=""
# use order outlined by http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup
if [ -f "$HOME/.bash_profile" ]; then
shell_config_file="$HOME/.bash_profile"
elif [ -f "$HOME/.bash_login" ]; then
shell_config_file="$HOME/.bash_login"
elif [ -f "$HOME/.profile" ]; then
shell_config_file="$HOME/.profile"
elif [ -f "$HOME/.bashrc" ]; then
shell_config_file="$HOME/.bashrc"
fi
echo $shell_config_file