mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
More transition to jake.
Reviewed by me.
This commit is contained in:
+12
-7
@@ -9,15 +9,20 @@ $BUILD_PATH = FILE.join($BUILD_DIR, $CONFIGURATION, "Foundation");
|
||||
|
||||
task ("build", ["Foundation"]);
|
||||
|
||||
framework ("Foundation", function(foundationTask)
|
||||
framework ("Foundation", function(FoundationTask)
|
||||
{
|
||||
foundationTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Foundation.build", $CONFIGURATION))
|
||||
foundationTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
|
||||
FoundationTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Foundation.build", $CONFIGURATION))
|
||||
FoundationTask.setBuildPath(FILE.join($BUILD_DIR, $CONFIGURATION));
|
||||
|
||||
foundationTask.setIdentifier("com.280n.Foundation");
|
||||
foundationTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
foundationTask.setSources(FILE.glob("**/*.j").concat(FILE.glob("*.j")));//terrible!
|
||||
foundationTask.setResources(FILE.glob("Resources/*"));
|
||||
FoundationTask.setIdentifier("com.280n.Foundation");
|
||||
FoundationTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
FoundationTask.setSources(FILE.glob("**/*.j").concat(FILE.glob("*.j")));//terrible!
|
||||
FoundationTask.setResources(FILE.glob("Resources/*"));
|
||||
|
||||
if ($CONFIGURATION === "Release")
|
||||
FoundationTask.setCompilerFlags("-O");
|
||||
else
|
||||
FoundationTask.setCompilerFlags("-DDEBUG -g");
|
||||
});
|
||||
|
||||
//CLOBBER.include($ENVIRONMENT_PRODUCT)
|
||||
|
||||
@@ -7,7 +7,7 @@ var FILE = require("file"),
|
||||
|
||||
require(FILE.absolute("common.jake"));
|
||||
|
||||
var subprojects = ["External", "Objective-J", "Foundation", "AppKit", "Tools", "External/ojunit"];
|
||||
var subprojects = [/*"External", */"Objective-J", "Foundation", "AppKit", "Tools", "External/ojunit"];
|
||||
|
||||
["build", "clean", "clobber"].forEach(function(/*String*/ aTaskName)
|
||||
{
|
||||
|
||||
@@ -4,14 +4,20 @@ var FILE = require("file");
|
||||
|
||||
require("../../common.jake");
|
||||
|
||||
$COMMON_JS_PRODUCT = FILE.join($BUILD_DIR, "objective-j");
|
||||
$COMMONJS_PRODUCT = FILE.join($BUILD_DIR, $CONFIGURATION, "objective-j"),
|
||||
$COMMONJS_OBJECTIVE_J_PRODUCT = FILE.join($COMMONJS_PRODUCT, "lib", "Frameworks", "Objective-J");
|
||||
|
||||
task ("build", [$COMMON_JS_PRODUCT]);
|
||||
task ("build", [$COMMONJS_PRODUCT, $COMMONJS_OBJECTIVE_J_PRODUCT]);
|
||||
|
||||
filedir ($COMMON_JS_PRODUCT, FILE.glob("objective-j/**/*"), function()
|
||||
filedir ($COMMONJS_PRODUCT, FILE.glob("objective-j/**/*"), function()
|
||||
{
|
||||
rm_rf($COMMON_JS_PRODUCT);
|
||||
cp_r('objective-j', $COMMON_JS_PRODUCT);
|
||||
rm_rf($COMMONJS_PRODUCT);
|
||||
cp_r('objective-j', $COMMONJS_PRODUCT);
|
||||
});
|
||||
|
||||
filedir ($COMMONJS_OBJECTIVE_J_PRODUCT, function()
|
||||
{
|
||||
cp_r(FILE.join($BUILD_DIR, $CONFIGURATION, "Objective-J"), $COMMONJS_OBJECTIVE_J_PRODUCT);
|
||||
});
|
||||
|
||||
//CLOBBER.include($ENVIRONMENT_OBJJ_PRODUCT)
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
var file = require("file"),
|
||||
readline = require("readline").readline;
|
||||
|
||||
var window = require("browser/window");
|
||||
window.isRhino = true
|
||||
|
||||
if (window.isRhino) {
|
||||
window.__parent__ = null;
|
||||
window.__proto__ = global;
|
||||
}
|
||||
|
||||
// setup OBJJ_HOME, OBJJ_INCLUDE_PATHS, etc
|
||||
window.OBJJ_HOME = exports.OBJJ_HOME = file.resolve(module.path, "..");
|
||||
|
||||
var frameworksPath = file.resolve(window.OBJJ_HOME, "lib/", "Frameworks/"),
|
||||
objectivejPath = file.resolve(frameworksPath, "Objective-J/", "rhino.platform/", "Objective-J.js");
|
||||
|
||||
window.OBJJ_INCLUDE_PATHS = [frameworksPath];
|
||||
if (system.env["OBJJ_INCLUDE_PATHS"])
|
||||
window.OBJJ_INCLUDE_PATHS = system.env["OBJJ_INCLUDE_PATHS"].split(":").concat(window.OBJJ_INCLUDE_PATHS);
|
||||
|
||||
// bring the "window" object into scope.
|
||||
// TODO: somehow make window object the top scope?
|
||||
with (window)
|
||||
{
|
||||
// read and eval Objective-J.js with the module's scope
|
||||
if (window.isRhino)
|
||||
Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(window, file.read(objectivejPath, { charset:"UTF-8" }), "Objective-J.js", 0, null);
|
||||
else
|
||||
eval(file.read(objectivejPath, { charset:"UTF-8" }));
|
||||
|
||||
// export desired variables. must eval variable name to obtain a reference.
|
||||
[
|
||||
"objj_preprocess",
|
||||
"FRAGMENT_FILE", "FRAGMENT_LOCAL",
|
||||
"MARKER_CODE", "MARKER_IMPORT_STD", "MARKER_IMPORT_LOCAL",
|
||||
"OBJJ_PREPROCESSOR_DEBUG_SYMBOLS",
|
||||
"objj_data",
|
||||
"CPPropertyListCreateData", "CPPropertyListCreateFromData",
|
||||
"kCFPropertyListXMLFormat_v1_0", "kCFPropertyList280NorthFormat_v1_0",
|
||||
"objj_dictionary"
|
||||
].forEach(function(v) {
|
||||
exports[v] = eval(v);
|
||||
});
|
||||
|
||||
// extra macros
|
||||
exports.SET_CONTEXT = function(aFragment, aContext) { aFragment.context = aContext; }
|
||||
exports.GET_CONTEXT = function(aFragment) { return aFragment.context; }
|
||||
|
||||
exports.SET_TYPE = function(aFragment, aType) { aFragment.type = aType; }
|
||||
exports.GET_TYPE = function(aFragment) { return aFragment.type; }
|
||||
|
||||
exports.GET_CODE = function(aFragment) { return aFragment.info; }
|
||||
exports.SET_CODE = function(aFragment, aCode) { aFragment.info = aCode; }
|
||||
|
||||
exports.GET_PATH = function(aFragment) { return aFragment.info; }
|
||||
exports.SET_PATH = function(aFragment, aPath) { aFragment.info = aPath; }
|
||||
|
||||
exports.GET_BUNDLE = function(aFragment) { return aFragment.bundle; }
|
||||
exports.SET_BUNDLE = function(aFragment, aBundle) { aFragment.bundle = aBundle; }
|
||||
|
||||
exports.GET_FILE = function(aFragment) { return aFragment.file; }
|
||||
exports.SET_FILE = function(aFragment, aFile) { aFragment.file = aFile; }
|
||||
|
||||
exports.IS_FILE = function(aFragment) { return (aFragment.type & FRAGMENT_FILE); }
|
||||
exports.IS_LOCAL = function(aFragment) { return (aFragment.type & FRAGMENT_LOCAL); }
|
||||
exports.IS_IMPORT = function(aFragment) { return (aFragment.type & FRAGMENT_IMPORT); }
|
||||
|
||||
/*
|
||||
objj_set_evaluator(function(code) {
|
||||
return function(OBJJ_CURRENT_BUNDLE) {
|
||||
with (window) {
|
||||
return eval("function(OBJJ_CURRENT_BUNDLE){"+code+"}");
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
// runs the objj repl or file provided in args
|
||||
exports.run = function(args)
|
||||
{
|
||||
args = args || [];
|
||||
window.args = args;
|
||||
|
||||
// FIXME: ARGS
|
||||
args.shift();
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
while (args.length && args[0].indexOf('-I') === 0)
|
||||
OBJJ_INCLUDE_PATHS = args.shift().substr(2).split(':').concat(OBJJ_INCLUDE_PATHS);
|
||||
|
||||
var mainFilePath = file.canonical(args.shift());
|
||||
|
||||
objj_import(mainFilePath, YES, function() {
|
||||
if (typeof main === "function")
|
||||
main.apply(main, args);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try {
|
||||
system.stdout.write("objj> ").flush();
|
||||
|
||||
var input = readline(),
|
||||
result = objj_eval(input);
|
||||
|
||||
if (result !== undefined)
|
||||
print(result);
|
||||
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
}
|
||||
}
|
||||
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
}
|
||||
|
||||
// synchronously evals Objective-J code
|
||||
var objj_eval = exports.objj_eval = function(code)
|
||||
{
|
||||
if (window.isRhino)
|
||||
var result = Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(window, objj_preprocess_sync(code), "objj_eval", 0, null);
|
||||
else
|
||||
var result = eval(objj_preprocess_sync(code));
|
||||
|
||||
//require("browser/timeout").serviceTimeouts();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// prepocesses Objective-J code into JavaScript, which will perform imports synchronously when eval'd
|
||||
var objj_preprocess_sync = function(code, path)
|
||||
{
|
||||
var fragments = objj_preprocess(code, new objj_bundle(), new objj_file(), OBJJ_PREPROCESSOR_DEBUG_SYMBOLS)
|
||||
|
||||
var preprocessed = [];
|
||||
|
||||
fragments.forEach(function(fragment) {
|
||||
if (fragment.type & FRAGMENT_CODE)
|
||||
preprocessed.push(fragment.info);
|
||||
else if (fragment.type & FRAGMENT_LOCAL)
|
||||
preprocessed.push("objj_import_sync('"+(path ? file.join(file.dirname(path), fragment.info) : fragment.info)+"',YES);");
|
||||
else
|
||||
preprocessed.push("objj_import_sync('"+fragment.info+"',NO);");
|
||||
});
|
||||
|
||||
return preprocessed.join("\n");
|
||||
}
|
||||
|
||||
// synchronously perform an import
|
||||
var objj_import_sync = function(pathOrPaths, isLocal)
|
||||
{
|
||||
var context = new objj_context();
|
||||
context.pushFragment(fragment_create_file(pathOrPaths, new objj_bundle(), isLocal, NULL));
|
||||
context.evaluate();
|
||||
|
||||
// HACK: need a real synchronous require
|
||||
// FIXME: this is bad. not really synchronous. shouldn't have to call serviceTimeouts.
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
}
|
||||
|
||||
// creates a narwhal factory function in the objj module scope
|
||||
exports.make_narwhal_factory = function(code, path) {
|
||||
var OBJJ_CURRENT_BUNDLE = new objj_bundle();
|
||||
|
||||
var factoryText = "(function(require,exports,module,system,print){" + objj_preprocess_sync(code, path) + "/**/\n})";
|
||||
|
||||
if (window.isRhino)
|
||||
return Packages.org.mozilla.javascript.Context.getCurrentContext().compileFunction(window, factoryText, path, 0, null);
|
||||
else
|
||||
return eval(factoryText);
|
||||
}
|
||||
|
||||
} // end "with"
|
||||
|
||||
if (require.main == module.id)
|
||||
exports.run(system.args);
|
||||
@@ -0,0 +1,177 @@
|
||||
var FILE = require("file"),
|
||||
OS = require("os"),
|
||||
objj = require("objective-j"),
|
||||
objj_preprocess = objj.objj_preprocess,
|
||||
IS_FILE = objj.IS_FILE,
|
||||
GET_CODE = objj.GET_CODE,
|
||||
IS_LOCAL = objj.IS_LOCAL,
|
||||
MARKER_IMPORT_STD = objj.MARKER_IMPORT_STD,
|
||||
MARKER_IMPORT_LOCAL = objj.MARKER_IMPORT_LOCAL,
|
||||
MARKER_CODE = objj.MARKER_CODE,
|
||||
GET_PATH = objj.GET_PATH;
|
||||
|
||||
require("objective-j/rhino/regexp-rhino-patch");
|
||||
|
||||
var OBJJ_PREPROCESSOR_DEBUG_SYMBOLS = exports.OBJJ_PREPROCESSOR_DEBUG_SYMBOLS = objj.OBJJ_PREPROCESSOR_DEBUG_SYMBOLS;
|
||||
var OBJJ_PREPROCESSOR_TYPE_SIGNATURES = exports.OBJJ_PREPROCESSOR_TYPE_SIGNATURES = objj.OBJJ_PREPROCESSOR_TYPE_SIGNATURES;
|
||||
var OBJJ_PREPROCESSOR_PREPROCESS = exports.OBJJ_PREPROCESSOR_PREPROCESS = 1 << 10;
|
||||
var OBJJ_PREPROCESSOR_COMPRESS = exports.OBJJ_PREPROCESSOR_COMPRESS = 1 << 11;
|
||||
var OBJJ_PREPROCESSOR_SYNTAX = exports.OBJJ_PREPROCESSOR_SYNTAX = 1 << 12;
|
||||
|
||||
var SHRINKSAFE_PATH = FILE.join(objj.OBJJ_HOME, "shrinksafe", "shrinksafe.jar"),
|
||||
RHINO_PATH = FILE.join(objj.OBJJ_HOME, "shrinksafe", "js.jar")
|
||||
|
||||
function compress(/*String*/ aCode, /*String*/ FIXME)
|
||||
{
|
||||
// FIXME: figure out why this doesn't work on Windows/Cygwin
|
||||
//var tmpFile = java.io.File.createTempFile("OBJJC", "");
|
||||
var tmpFile = new java.io.File("/tmp/" + FIXME + Math.random() + ".tmp");
|
||||
tmpFile.deleteOnExit();
|
||||
tmpFile = tmpFile.getAbsolutePath();
|
||||
|
||||
FILE.write(tmpFile, aCode, { charset:"UTF-8" });
|
||||
|
||||
return OS.command(["java", "-Dfile.encoding=UTF-8", "-classpath", [RHINO_PATH, SHRINKSAFE_PATH].join(":"), "org.dojotoolkit.shrinksafe.Main", tmpFile]);
|
||||
}
|
||||
|
||||
function compileWithResolvedFlags(aFilePath, objjcFlags, gccFlags)
|
||||
{
|
||||
var shouldObjjPreprocess = objjcFlags & OBJJ_PREPROCESSOR_PREPROCESS,
|
||||
shouldCheckSyntax = objjcFlags & OBJJ_PREPROCESSOR_SYNTAX,
|
||||
shouldCompress = objjcFlags & OBJJ_PREPROCESSOR_COMPRESS;
|
||||
|
||||
// GCC preprocess the file.
|
||||
var gcc = OS.popen("gcc -E -x c -P " + (gccFlags ? gccFlags.join(" ") : "") + " " + aFilePath),
|
||||
fileContents = "",
|
||||
chunk = "";
|
||||
|
||||
while (chunk = gcc.stdout.read())
|
||||
fileContents += chunk;
|
||||
|
||||
if (!shouldObjjPreprocess)
|
||||
return fileContents;
|
||||
|
||||
// Preprocess contents into fragments.
|
||||
var fragments = objj_preprocess(fileContents, { path : "/x" }, { path: FILE.basename(aFilePath) }, objjcFlags),
|
||||
preprocessed = "";
|
||||
|
||||
// Writer preprocessed fragments out.
|
||||
for (var index = 0; index < fragments.length; index++)
|
||||
{
|
||||
var fragment = fragments[index];
|
||||
|
||||
if (IS_FILE(fragment))
|
||||
preprocessed += (IS_LOCAL(fragment) ? MARKER_IMPORT_LOCAL : MARKER_IMPORT_STD) + ';' + GET_PATH(fragment).length + ';' + GET_PATH(fragment);
|
||||
else
|
||||
{
|
||||
var code = GET_CODE(fragment);
|
||||
|
||||
if (shouldCheckSyntax)
|
||||
{
|
||||
try
|
||||
{
|
||||
new Function(GET_CODE(fragment));
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
var lines = code.split("\n"),
|
||||
PAD = 3;
|
||||
|
||||
print("Syntax error in "+GET_FILE(fragment).path+
|
||||
" on preprocessed line number "+e.lineNumber+"\n"+
|
||||
"\t"+lines.slice(Math.max(0, e.lineNumber - 1 - PAD), e.lineNumber+PAD).join("\n\t"));
|
||||
|
||||
OS.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldCompress)
|
||||
{
|
||||
code = compress("function(){" + code + '}', FILE.basename(aFilePath));
|
||||
|
||||
code = code.substr("function(){".length, code.length - "function(){};\n\n".length);
|
||||
}
|
||||
|
||||
preprocessed += MARKER_CODE + ';' + code.length + ';' + code;
|
||||
}
|
||||
}
|
||||
|
||||
return preprocessed;
|
||||
}
|
||||
|
||||
function resolveFlags(args)
|
||||
{
|
||||
var filePaths = [],
|
||||
outputFilePaths = [],
|
||||
|
||||
index = 0,
|
||||
count = args.length,
|
||||
|
||||
gccFlags = [],
|
||||
objjcFlags = OBJJ_PREPROCESSOR_PREPROCESS | OBJJ_PREPROCESSOR_SYNTAX;
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var argument = args[index];
|
||||
|
||||
if (argument === "-o")
|
||||
{
|
||||
if (++index < count)
|
||||
outputFilePaths.push(args[index]);
|
||||
}
|
||||
|
||||
else if (argument.indexOf("-D") === 0)
|
||||
gccFlags.push(argument)
|
||||
|
||||
else if (argument.indexOf("-U") === 0)
|
||||
gccFlags.push(argument);
|
||||
|
||||
else if (argument.indexOf("-E") === 0)
|
||||
objjcFlags &= ~OBJJ_PREPROCESSOR_PREPROCESS;
|
||||
|
||||
else if (argument.indexOf("-S") === 0)
|
||||
objjcFlags &= ~OBJJ_PREPROCESSOR_SYNTAX;
|
||||
|
||||
else if (argument.indexOf("-g") === 0)
|
||||
objjcFlags |= OBJJ_PREPROCESSOR_DEBUG_SYMBOLS;
|
||||
|
||||
else if (argument.indexOf("-O") === 0)
|
||||
objjcFlags |= OBJJ_PREPROCESSOR_COMPRESS;
|
||||
|
||||
else
|
||||
filePaths.push(argument);
|
||||
}
|
||||
|
||||
return { filePaths:filePaths, outputFilePaths:outputFilePaths, objjcFlags:objjcFlags, gccFlags:gccFlags };
|
||||
}
|
||||
|
||||
exports.compile = function(aFilePath, flags)
|
||||
{
|
||||
if (flags.split)
|
||||
flags = flags.split(/\s+/);
|
||||
|
||||
var resolvedFlags = resolveFlags(flags);
|
||||
|
||||
return compileWithResolvedFlags(aFilePath, resolvedFlags.objjcFlags, resolvedFlags.gccFlags);
|
||||
}
|
||||
|
||||
exports.main = function(args)
|
||||
{
|
||||
// FIXME: ARGS
|
||||
args.shift();
|
||||
|
||||
var resolved = resolveFlags(args),
|
||||
outputFilePaths = resolved.outputFilePaths,
|
||||
objjcFlags = resolved.objjFlags,
|
||||
gccFlags = resolved.gccFlags;
|
||||
|
||||
resolved.filePaths.forEach(function(filePath, index)
|
||||
{
|
||||
print("Statically Compiling " + filePath);
|
||||
|
||||
FILE.write(outputFilePaths[index], compileWithResolvedFlags(filePath, objjcFlags, gccFlags), { charset: "UTF-8" });
|
||||
});
|
||||
}
|
||||
|
||||
if (require.main == module.id)
|
||||
exports.main(system.args);
|
||||
+28
-9
@@ -2,9 +2,9 @@
|
||||
var FILE = require("file"),
|
||||
OS = require("os"),
|
||||
Jake = require("jake"),
|
||||
objj = require("objj/objj"),
|
||||
objjc = require("objj/objjc"),
|
||||
plist = require("objj/plist");
|
||||
objj_dictionary = require("objective-j").objj_dictionary,
|
||||
compiler = require("objective-j/compiler"),
|
||||
plist = require("objective-j/plist");
|
||||
|
||||
var Task = Jake.Task,
|
||||
filedir = Jake.filedir;
|
||||
@@ -25,6 +25,7 @@ function BundleTask(aName, anApplication)
|
||||
this._resources = null;
|
||||
this._identifier = null;
|
||||
this._version = 0.1;
|
||||
this._compilerFlags = null;
|
||||
|
||||
this._productName = this.name();
|
||||
|
||||
@@ -210,6 +211,16 @@ BundleTask.prototype.productName = function()
|
||||
return this._productName;
|
||||
}
|
||||
|
||||
BundleTask.prototype.setCompilerFlags = function(flags)
|
||||
{
|
||||
this._compilerFlags = flags;
|
||||
}
|
||||
|
||||
BundleTask.prototype.compilerFlags = function()
|
||||
{
|
||||
return this._compilerFlags;
|
||||
}
|
||||
|
||||
BundleTask.prototype.setLicense = function(aLicense)
|
||||
{
|
||||
this._license = aLicense;
|
||||
@@ -272,7 +283,7 @@ BundleTask.prototype.packageType = function()
|
||||
|
||||
BundleTask.prototype.infoPlist = function()
|
||||
{
|
||||
var infoPlist = new objj.objj_dictionary();
|
||||
var infoPlist = new objj_dictionary();
|
||||
//util = require("util"),
|
||||
infoPlist.setValue("CPBundleInfoDictionaryVersion", 6.0);
|
||||
infoPlist.setValue("CPBundleName", this.productName());
|
||||
@@ -469,8 +480,7 @@ BundleTask.prototype.defineStaticTask = function()
|
||||
{
|
||||
print("Creating static file...");
|
||||
|
||||
// No newline!
|
||||
OS.system("echo -n \"@STATIC;1.0;\" > " + staticPath);
|
||||
FILE.write(staticPath, "@STATIC;1.0;", { charset:"UTF-8" });
|
||||
|
||||
aTask.prerequisites().forEach(function(aFilename)
|
||||
{
|
||||
@@ -491,12 +501,20 @@ BundleTask.prototype.defineSourceTasks = function()
|
||||
if (!sources)
|
||||
return;
|
||||
|
||||
var compilerFlags = this.compilerFlags();
|
||||
|
||||
if (!compilerFlags)
|
||||
compilerFlags = "";
|
||||
|
||||
else if (compilerFlags.join)
|
||||
compilerFlags = compilerFlags.join(" ");
|
||||
|
||||
this.platforms().forEach(function(/*String*/ aPlatform)
|
||||
{
|
||||
var platformSources = sources,
|
||||
platformBuildIntermediatesPath = FILE.join(this.buildIntermediatesProductPath(), BundleTask.PLATFORM_DIRECTORIES[aPlatform]),
|
||||
staticPath = this.buildProductStaticPathForPlatform(aPlatform),
|
||||
flags = BundleTask.PLATFORM_DEFAULT_FLAGS[aPlatform];
|
||||
flags = BundleTask.PLATFORM_DEFAULT_FLAGS[aPlatform].join(" ");
|
||||
|
||||
if (!Array.isArray(platformSources))
|
||||
platformSources = platformSources[aPlatform];
|
||||
@@ -510,8 +528,9 @@ BundleTask.prototype.defineSourceTasks = function()
|
||||
var compiledPlatformSource = FILE.join(platformBuildIntermediatesPath, FILE.basename(aFilename));
|
||||
|
||||
filedir (compiledPlatformSource, [aFilename], function()
|
||||
{//#{flags.join(' ')} #{PLATFORM_FLAGS[platform].join(' ')}
|
||||
objjc.preprocess(aFilename, compiledPlatformSource, flags);
|
||||
{
|
||||
print("Compiling " + aFilename + "...");
|
||||
FILE.write(compiledPlatformSource, compiler.compile(aFilename, flags + " " + compilerFlags), { charset:"UTF-8" });
|
||||
});
|
||||
|
||||
filedir (staticPath, [compiledPlatformSource]);
|
||||
@@ -0,0 +1,15 @@
|
||||
var file = require("file"),
|
||||
objj = require("objective-j"),
|
||||
CPPropertyListCreateData = objj.CPPropertyListCreateData,
|
||||
kCFPropertyListXMLFormat_v1_0 = objj.kCFPropertyListXMLFormat_v1_0;
|
||||
|
||||
exports.readPlist = function(path) {
|
||||
var plistData = new objj.objj_data();
|
||||
plistData.string = file.read(path);
|
||||
return objj.CPPropertyListCreateFromData(plistData);
|
||||
}
|
||||
|
||||
exports.writePlist = function(path, plist, format) {
|
||||
format = format || objj.kCFPropertyListXMLFormat_v1_0;
|
||||
file.write(path, objj.CPPropertyListCreateData(plist, format).string);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
var CachedRegexData = [];
|
||||
|
||||
function regexDataFromRegex(aRegex)
|
||||
{
|
||||
var source = "",
|
||||
flags = "";
|
||||
|
||||
if (typeof aRegex == "string")
|
||||
{
|
||||
if (CachedRegexData[aRegex])
|
||||
return CachedRegexData[aRegex];
|
||||
|
||||
string = aRegex;
|
||||
source = aRegex;
|
||||
}
|
||||
else
|
||||
{
|
||||
string = aRegex.toString();
|
||||
|
||||
if (CachedRegexData[string])
|
||||
return CachedRegexData[string];
|
||||
|
||||
var index = string.lastIndexOf('/');
|
||||
|
||||
source = string.substr(0, index);
|
||||
flags = string.substr(index + 1);
|
||||
}
|
||||
|
||||
source = source.replace("\\[\\^\\\\\\d\\]", ".", "g");
|
||||
source = source.replace("\\[([^\\]]*)\\\\b([^\\]]*)\\]", "[$1\\\\cH$2]", "g") // [...\b...] -> [...\cH...]
|
||||
source = source.replace("(?<!\\\\)\\{(?!\\d)", "\\\\{", "g");
|
||||
source = source.replace("(?<!(\\d,?|\\\\))\\}", "\\\\}", "g");
|
||||
|
||||
return CachedRegexData[string] = { pattern:java.util.regex.Pattern.compile(source, 0), flags:flags };
|
||||
}
|
||||
|
||||
function newMatch(regex)
|
||||
{
|
||||
var regexData = regexDataFromRegex(regex);
|
||||
|
||||
var matcher = regexData.pattern.matcher(new java.lang.String(this)),
|
||||
flags = regexData.flags;
|
||||
|
||||
if (!matcher.find())
|
||||
return [];
|
||||
|
||||
var index = matcher.start(0),
|
||||
groups = [];
|
||||
|
||||
if (flags.indexOf('g') != -1)
|
||||
{
|
||||
do
|
||||
{
|
||||
groups.push(matcher.group(0) + "");
|
||||
}
|
||||
while (matcher.find());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (index = 0; index <= matcher.groupCount(); ++index)
|
||||
{
|
||||
var group = matcher.group(index);
|
||||
|
||||
if (group != null)
|
||||
groups[index] = group;
|
||||
}
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
if (system.platform === "rhino")
|
||||
String.prototype.match = newMatch;
|
||||
@@ -1,5 +1,7 @@
|
||||
{
|
||||
"name": "objective-j",
|
||||
"dependencies": ["narwhal", "jack", "browserjs"],
|
||||
"lib": "lib-js",
|
||||
"author": "280 North, Inc. (http://280north.com/)",
|
||||
"description": "Objective-J module",
|
||||
"keywords": ["objective-j", "objj", "objective j", "cappuccino"],
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+22
-51
@@ -6,33 +6,23 @@ var FILE = require("file"),
|
||||
|
||||
require(FILE.absolute("../common.jake"));
|
||||
|
||||
task = Jake.task;
|
||||
file = Jake.file;
|
||||
filedir = Jake.filedir;
|
||||
FileList = Jake.FileList;
|
||||
$PRODUCT = FILE.join($PRODUCT_DIR, "Objective-J")
|
||||
$COMMONJS_PRODUCT = FILE.join($PRODUCT_DIR, "CommonJS", "objective-j");
|
||||
$COMMONJS_FRAMEWORK_PRODUCT = FILE.join($COMMONJS_PRODUCT, "lib", "Frameworks", "Objective-J");
|
||||
|
||||
/*
|
||||
require '../common'
|
||||
require 'objective-j'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
*/
|
||||
|
||||
$PRODUCT = FILE.join($PRODUCT_DIR, 'Objective-J')
|
||||
$ENVIRONMENT_PRODUCT = FILE.join($ENVIRONMENT_FRAMEWORKS_DIR, 'Objective-J')
|
||||
$LICENSE_PRODUCT = FILE.join($PRODUCT, 'LICENSE')
|
||||
|
||||
$LICENSE_FILE = FILE.join($HOME_DIR, 'Tools', 'Rake', 'lib', 'licenses', 'LGPL-v2.1')
|
||||
|
||||
$BROWSER_FILE = FILE.join($PRODUCT, 'Objective-J.js')
|
||||
$RHINO_FILE = FILE.join($PRODUCT, 'rhino.platform', 'Objective-J.js')
|
||||
|
||||
task ("Products", [$BROWSER_FILE, $RHINO_FILE, $LICENSE_PRODUCT]);
|
||||
Files = ["constants.js", "utilities.js", "json2.js", "runtime.js", "dictionary.js", "plist.js", "file.js", "exception.js", "preprocess.js", "evaluate.js", "bootstrap.js"];
|
||||
Files = ["Runtime/constants.js", "Runtime/utilities.js", "Runtime/json2.js", "Runtime/runtime.js", "Runtime/dictionary.js", "Runtime/plist.js", "Runtime/file.js", "Runtime/exception.js", "Runtime/preprocess.js", "Runtime/evaluate.js", "Runtime/bootstrap.js"];
|
||||
//Files = new FileList("constants.js", "utilities.js", "json2.js", "runtime.js", "dictionary.js", "plist.js", "file.js", "exception.js", "preprocess.js", "evaluate.js", "bootstrap.js");
|
||||
|
||||
if ($CONFIGURATION === "Debug")
|
||||
Files.push("debug.js")//Files.add('debug.js');
|
||||
Files.push("Runtime/debug.js")//Files.add('debug.js');
|
||||
|
||||
task ("build", [$BROWSER_FILE, $RHINO_FILE, $LICENSE_PRODUCT, $COMMONJS_PRODUCT, $COMMONJS_FRAMEWORK_PRODUCT]);
|
||||
|
||||
filedir ($BROWSER_FILE, Files, function(aTask)
|
||||
{
|
||||
@@ -47,18 +37,24 @@ filedir ($RHINO_FILE, Files, function(aTask)
|
||||
build_product(aTask.name(), flags)
|
||||
});
|
||||
|
||||
// Framework in environment directory
|
||||
filedir ($ENVIRONMENT_PRODUCT, ["Products"], function()
|
||||
{
|
||||
rm_rf($ENVIRONMENT_PRODUCT);
|
||||
cp_r($PRODUCT, $ENVIRONMENT_PRODUCT);
|
||||
});
|
||||
|
||||
filedir ($LICENSE_PRODUCT, [$LICENSE_FILE], function()
|
||||
{
|
||||
FILE.copy($LICENSE_FILE, $LICENSE_PRODUCT);
|
||||
});
|
||||
|
||||
filedir ($COMMONJS_PRODUCT, FILE.glob("CommonJS/objective-j/**/*"), function()
|
||||
{
|
||||
rm_rf($COMMONJS_PRODUCT);
|
||||
cp_r(FILE.join("CommonJS", "objective-j"), $COMMONJS_PRODUCT);
|
||||
});
|
||||
|
||||
filedir ($COMMONJS_FRAMEWORK_PRODUCT, function()
|
||||
{
|
||||
cp_r(FILE.join($BUILD_DIR, $CONFIGURATION, "Objective-J"), $COMMONJS_FRAMEWORK_PRODUCT);
|
||||
});
|
||||
|
||||
//CLOBBER.include($ENVIRONMENT_OBJJ_PRODUCT)
|
||||
|
||||
function platform_flags()
|
||||
{
|
||||
return "-DPLATFORMS=\"[" + Array.prototype.map.apply(arguments, [function(aPlatform)
|
||||
@@ -69,9 +65,7 @@ function platform_flags()
|
||||
|
||||
function build_product(path, flags)
|
||||
{
|
||||
var preprocessor = OS.popen("gcc " + flags + " -E -x c -P -");
|
||||
|
||||
OS.system("cat header.txt > " + OS.enquote(path));
|
||||
OS.system("cat Runtime/header.txt > " + OS.enquote(path));
|
||||
OS.system("cat " +
|
||||
Files.filter(function(aName)
|
||||
{
|
||||
@@ -79,32 +73,9 @@ function build_product(path, flags)
|
||||
}).map(function(aName)
|
||||
{
|
||||
return OS.enquote(aName);
|
||||
}).join(' ') + " | gcc -E -x c -P - >> " + OS.enquote(path));
|
||||
}).join(' ') + " | gcc " + flags + " -E -x c -P - >> " + OS.enquote(path));
|
||||
// rake abort if ($? != 0)
|
||||
}
|
||||
|
||||
task ("build", ["Products", "build_subprojects", $ENVIRONMENT_PRODUCT]);
|
||||
|
||||
task ("clean", ["clean_suprojects"]);
|
||||
|
||||
task ("clobber", ["clobber_subprojects"]);
|
||||
|
||||
subprojects = ["CommonJS"];
|
||||
|
||||
task ("build_subprojects", function()
|
||||
{
|
||||
subjake(subprojects, "build");
|
||||
});
|
||||
|
||||
task ("clean_suprojects", function()
|
||||
{
|
||||
subjake(subprojects, "clean");
|
||||
});
|
||||
|
||||
task ("clobber_subprojects", function()
|
||||
{
|
||||
subjake(subprojects, "clobber");
|
||||
});
|
||||
|
||||
//CLEAN.include() no temporary files.
|
||||
//CLOBBER.include($PRODUCT, $ENVIRONMENT_PRODUCT);
|
||||
|
||||
+3
-3
@@ -66,11 +66,11 @@ global.$ENVIRONMENT_FRAMEWORKS_DIR = FILE.join($ENVIRONMENT_LIB_DIR, 'Frameworks
|
||||
global.$HOME_DIR = FILE.absolute(FILE.dirname(module.path));
|
||||
global.$LICENSE_FILE = FILE.absolute(FILE.join(FILE.dirname(module.path), 'LICENSE'));
|
||||
|
||||
var objectiveJLib = FILE.join($BUILD_DIR, "objective-j", "lib");
|
||||
var objectiveJLibJS = FILE.join($BUILD_DIR, $CONFIGURATION, "CommonJS", "objective-j", "lib-js");
|
||||
|
||||
if (FILE.exists(objectiveJLib))
|
||||
if (FILE.exists(objectiveJLibJS))
|
||||
{
|
||||
require.paths.unshift(objectiveJLib);
|
||||
require.paths.unshift(objectiveJLibJS);
|
||||
|
||||
var OBJECTIVE_J_JAKE = require("objective-j/jake");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user