mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
further removal of narwhal APIs
This commit is contained in:
+19
-7
@@ -1,14 +1,26 @@
|
||||
console.log("at the top of CommonJS/Jakefile");
|
||||
|
||||
require("../common.jake");
|
||||
|
||||
var FILE = require("file");
|
||||
const { FileList } = require("../common.jake");
|
||||
const { task } = require("../common.jake");
|
||||
const { filedir } = require("../common.jake");
|
||||
|
||||
new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
|
||||
// var FILE = require("file");
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
|
||||
var tmp_list = new FileList();
|
||||
tmp_list.include("**/*");
|
||||
tmp_list.exclude("Jakefile");
|
||||
|
||||
tmp_list.forEach(function(aFilename)
|
||||
{
|
||||
if (!FILE.isFile(aFilename))
|
||||
|
||||
if (!fs.lstatSync(aFilename).isFile())
|
||||
return;
|
||||
|
||||
var buildFilename = FILE.join($BUILD_CJS_CAPPUCCINO, aFilename);
|
||||
var buildFilename = path.join($BUILD_CJS_CAPPUCCINO, aFilename);
|
||||
|
||||
filedir (buildFilename, [aFilename], function ()
|
||||
{
|
||||
@@ -16,11 +28,11 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
|
||||
});
|
||||
|
||||
// HACK: narwhal should copy permissions
|
||||
if (FILE.dirname(aFilename) === FILE.join("bin"))
|
||||
if (path.dirname(aFilename) === path.join("bin"))
|
||||
{
|
||||
filedir (buildFilename, function ()
|
||||
{
|
||||
FILE.chmod(buildFilename, 0755);
|
||||
fs.chmodSync(buildFilename, 0o755);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,5 +41,5 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
|
||||
});
|
||||
|
||||
task ("build", function() {
|
||||
setPackageMetadata(FILE.join($BUILD_CJS_CAPPUCCINO, "package.json"));
|
||||
setPackageMetadata(path.join($BUILD_CJS_CAPPUCCINO, "package.json"));
|
||||
});
|
||||
|
||||
+8
-6
@@ -22,12 +22,12 @@
|
||||
|
||||
require("../common.jake");
|
||||
|
||||
var framework = require("objective-j/jake").framework;
|
||||
var BundleTask = require("objective-j/jake").BundleTask;
|
||||
var framework = require("./objective-j/jake").framework;
|
||||
var BundleTask = require("./objective-j/jake").BundleTask;
|
||||
|
||||
foundationTask = framework ("Foundation", function(foundationTask)
|
||||
{
|
||||
foundationTask.setBuildIntermediatesPath(FILE.join($BUILD_DIR, "Foundation.build", $CONFIGURATION))
|
||||
foundationTask.setBuildIntermediatesPath(path.join($BUILD_DIR, "Foundation.build", $CONFIGURATION))
|
||||
foundationTask.setBuildPath($BUILD_CONFIGURATION_DIR);
|
||||
|
||||
foundationTask.setAuthor("280 North, Inc.");
|
||||
@@ -40,10 +40,12 @@ foundationTask = framework ("Foundation", function(foundationTask)
|
||||
foundationTask.setResources(new FileList("Resources/**/*"));
|
||||
foundationTask.setFlattensSources(true);
|
||||
foundationTask.setInfoPlistPath("Info.plist");
|
||||
foundationTask.setEnvironments(require("objective-j/jake/environment").ObjJ);
|
||||
foundationTask.setEnvironments(require("./objective-j/jake/environment").ObjJ);
|
||||
|
||||
// Grab all the .h's and just include them in each file.
|
||||
var INCLUDES = new FileList("**/*.h").map(function(aFilename)
|
||||
var INCLUDES_LIST = new FileList();
|
||||
INCLUDES_LIST.include("**/*.h");
|
||||
var INCLUDES = INCLUDES_LIST.map(function(aFilename)
|
||||
{
|
||||
return "--include \"" + aFilename + "\"";
|
||||
}).join(" ");
|
||||
@@ -56,7 +58,7 @@ foundationTask = framework ("Foundation", function(foundationTask)
|
||||
foundationTask.setCompilerFlags("-DDEBUG -g -S --inline-msg-send -Wno-unused-but-set-variable " + INCLUDES);
|
||||
});
|
||||
|
||||
$BUILD_CJS_FOUNDATION = FILE.join($BUILD_CJS_CAPPUCCINO_FRAMEWORKS, "Foundation");
|
||||
$BUILD_CJS_FOUNDATION = path.join($BUILD_CJS_CAPPUCCINO_FRAMEWORKS, "Foundation");
|
||||
|
||||
filedir ($BUILD_CJS_FOUNDATION, ["Foundation"], function()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Objective-J.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2008-2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
var FILE = require("file");
|
||||
var MD5 = require("md5");
|
||||
var FileList = (require("jake")).FileList;
|
||||
var BundleTask = (require("objective-j/jake/bundletask")).BundleTask;
|
||||
exports.generateManifest = function(productPath, options)
|
||||
{
|
||||
options = options || {};
|
||||
indexFilePath = options.index || FILE.join(productPath, "index.html");
|
||||
if (!FILE.isFile(indexFilePath))
|
||||
{
|
||||
print("Warning: Skipping cache manifest generation, no index file at " + indexFilePath);
|
||||
return;
|
||||
} var index = FILE.read(indexFilePath, {charset: "UTF-8"});
|
||||
var manifestName = "app.manifest";
|
||||
var manifestPath = FILE.join(productPath, manifestName);
|
||||
var manifestAttribute = 'manifest="' + manifestName + '"';
|
||||
print("Generating cache manifest: " + manifestPath);
|
||||
var manifestOut = FILE.open(manifestPath, "w", {charset: "UTF-8"});
|
||||
manifestOut.print("CACHE MANIFEST");
|
||||
manifestOut.print("");
|
||||
manifestOut.print("CACHE:");
|
||||
var list = new FileList(FILE.join(productPath, "**", "*"));
|
||||
list.exclude(manifestPath);
|
||||
list.exclude("**/.DS_Store", "**/.htaccess");
|
||||
list.exclude("**/LICENSE");
|
||||
list.exclude("**/MHTML*");
|
||||
list.exclude("**/CommonJS.environment/*");
|
||||
list.exclude("**/*.cur");
|
||||
if (index.indexOf('"Frameworks/Debug"') < 0)
|
||||
list.exclude("**/Frameworks/Debug/*");
|
||||
if (options.exclude)
|
||||
options.exclude.forEach(list.exclude.bind(list));
|
||||
list.forEach( function(path)
|
||||
{
|
||||
if (FILE.isFile(path))
|
||||
{
|
||||
var relative = FILE.relative(productPath, path);
|
||||
if (BundleTask.isSpritable(path) && index.indexOf(relative) < 0)
|
||||
return;
|
||||
var hash = (MD5.hash(FILE.read(path, "b"))).decodeToString("base16");
|
||||
manifestOut.print("# " + hash);
|
||||
manifestOut.print(relative);
|
||||
} });
|
||||
manifestOut.print("");
|
||||
manifestOut.print("NETWORK:");
|
||||
manifestOut.print("*");
|
||||
manifestOut.close();
|
||||
var matchTag = index.match(/<html[^>]*>/i);
|
||||
if (matchTag)
|
||||
{
|
||||
var htmlTag = matchTag[0];
|
||||
var newHTMLTag = null;
|
||||
var matchAttr = htmlTag.match(/manifest\s*=\s*"([^"]*)"/i);
|
||||
if (matchAttr)
|
||||
{
|
||||
if (matchAttr[1] !== manifestName)
|
||||
{
|
||||
newHTMLTag = htmlTag.replace(matchAttr[0], manifestAttribute);
|
||||
} } else
|
||||
{
|
||||
newHTMLTag = htmlTag.replace(/>$/, " " + manifestAttribute + ">");
|
||||
} if (newHTMLTag)
|
||||
{
|
||||
print("Replacing html tag: \n " + htmlTag + "\nwith:\n " + newHTMLTag);
|
||||
var newIndex = index.replace(htmlTag, newHTMLTag);
|
||||
if (newIndex === index)
|
||||
{
|
||||
print("Warning: No change!");
|
||||
} else
|
||||
{
|
||||
FILE.write(indexFilePath, newIndex, {charset: "UTF-8"});
|
||||
} } } else
|
||||
{
|
||||
print("Warning: Couldn't find <html> tag in " + indexFilePath);
|
||||
} var htaccessPath = FILE.join(productPath, ".htaccess");
|
||||
var htaccess = FILE.isFile(htaccessPath) ? FILE.read(htaccessPath, {charset: "UTF-8"}) : "";
|
||||
var htaccessOut = FILE.open(htaccessPath, "w", {charset: "UTF-8"});
|
||||
htaccessOut.print(htaccess);
|
||||
var openTag = "<Files " + manifestName + ">";
|
||||
if (htaccess.indexOf(openTag) < 0)
|
||||
{
|
||||
htaccessOut.print("");
|
||||
htaccessOut.print(openTag);
|
||||
htaccessOut.print("\tHeader set Content-Type text/cache-manifest");
|
||||
htaccessOut.print("</Files>");
|
||||
} htaccessOut.close();
|
||||
};
|
||||
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Objective-J.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2008-2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
var FILE = require("file"),
|
||||
OS = require("os"),
|
||||
ObjectiveJ = require("objective-j"),
|
||||
JAKE = require("jake");
|
||||
require("objective-j/rhino/regexp-rhino-patch");
|
||||
var compressors = {ss: {id: "minify/shrinksafe"}};
|
||||
var compressorStats = {};
|
||||
function compressor(code)
|
||||
{
|
||||
var winner,
|
||||
winnerName;
|
||||
compressorStats['original'] = (compressorStats['original'] || 0) + code.length;
|
||||
for (var name in compressors)
|
||||
{
|
||||
var aCompressor = require(compressors[name].id),
|
||||
result = aCompressor.compress(code, {charset: "UTF-8", useServer: true});
|
||||
compressorStats[name] = (compressorStats[name] || 0) + result.length;
|
||||
if (!winner || result < winner.length)
|
||||
{
|
||||
winner = result;
|
||||
winnerName = name;
|
||||
}
|
||||
}
|
||||
return winner;
|
||||
}
|
||||
function compileWithResolvedFlags(aFilePath, objjcFlags, gccFlags, asPlainJavascript)
|
||||
{
|
||||
var shouldObjjPreprocess = true,
|
||||
shouldCompress = objjcFlags.compress,
|
||||
fileContents = "",
|
||||
executable,
|
||||
code;
|
||||
if (!shouldObjjPreprocess)
|
||||
{
|
||||
try {
|
||||
var p = OS.popen("which gcc");
|
||||
if ((p.stdout.read()).length === 0)
|
||||
{
|
||||
fileContents = FILE.read(aFilePath, {charset: "UTF-8"});
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
var gcc = OS.popen("gcc -E -x c -P " + (gccFlags ? gccFlags.join(" ") : "") + " " + OS.enquote(aFilePath), {charset: "UTF-8"}),
|
||||
chunk = "";
|
||||
while (chunk = gcc.stdout.read())
|
||||
fileContents += chunk;
|
||||
}
|
||||
finally {
|
||||
gcc.stdin.close();
|
||||
gcc.stdout.close();
|
||||
gcc.stderr.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
p.stdin.close();
|
||||
p.stdout.close();
|
||||
p.stderr.close();
|
||||
}
|
||||
return fileContents;
|
||||
}
|
||||
try {
|
||||
var sources = new JAKE.FileList("**/*.j"),
|
||||
translateFilenameToPath = {},
|
||||
otherwayTranslateFilenameToPath = {};
|
||||
sources.forEach( function(aFilename)
|
||||
{
|
||||
translateFilenameToPath[FILE.basename(aFilename)] = aFilename;
|
||||
otherwayTranslateFilenameToPath[aFilename] = FILE.basename(aFilename);
|
||||
}, this);
|
||||
var translatedFilename = translateFilenameToPath[aFilePath] ? translateFilenameToPath[aFilePath] : aFilePath,
|
||||
otherwayTranslatedFilename = otherwayTranslateFilenameToPath[aFilePath] ? otherwayTranslateFilenameToPath[aFilePath] : aFilePath,
|
||||
theTranslatedFilename = otherwayTranslatedFilename ? otherwayTranslatedFilename : translatedFilename,
|
||||
absolutePath = FILE.absolute(theTranslatedFilename),
|
||||
basePath = absolutePath.substring(0, absolutePath.length - theTranslatedFilename.length);
|
||||
var rhinoUglyFix = false;
|
||||
if (system.engine === "rhino")
|
||||
{
|
||||
if (typeof document == "undefined")
|
||||
{
|
||||
document = {createElement: function(x)
|
||||
{
|
||||
return {innerText: "", style: {}};
|
||||
}};
|
||||
rhinoUglyFix = true;
|
||||
}
|
||||
if (typeof navigator == "undefined")
|
||||
{
|
||||
navigator = {"userAgent": "fakenavigator"};
|
||||
rhinoUglyFix = true;
|
||||
}
|
||||
}
|
||||
ObjectiveJ.FileExecutable.setCurrentCompilerFlags(objjcFlags);
|
||||
ObjectiveJ.make_narwhal_factory(absolutePath, basePath, translateFilenameToPath)(require, {}, module, system, print);
|
||||
executable = new ObjectiveJ.FileExecutable(FILE.basename(aFilePath));
|
||||
if (rhinoUglyFix)
|
||||
delete document;
|
||||
}
|
||||
catch(anException) {
|
||||
print(anException);
|
||||
return;
|
||||
}
|
||||
if (shouldCompress)
|
||||
{
|
||||
code = executable.code();
|
||||
code = compressor("function(){" + code + "}");
|
||||
code = code.replace(/^\s*function\s*\(\s*\)\s*{|}\s*;?\s*$/g, "");
|
||||
executable.setCode(code);
|
||||
}
|
||||
return asPlainJavascript ? executable.code() : executable.toMarkedString();
|
||||
}
|
||||
function resolveFlags(args)
|
||||
{
|
||||
var filePaths = [],
|
||||
outputFilePaths = [],
|
||||
index = 0,
|
||||
count = args.length,
|
||||
gccFlags = [],
|
||||
objjcFlags = {};
|
||||
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 === "--include")
|
||||
{
|
||||
if (++index < count)
|
||||
{
|
||||
gccFlags.push(argument);
|
||||
gccFlags.push(args[index]);
|
||||
}
|
||||
}
|
||||
else if (argument.indexOf("-T") === 0)
|
||||
{
|
||||
objjcFlags.includeIvarTypeSignatures = false;
|
||||
objjcFlags.includeMethodArgumentTypeSignatures = false;
|
||||
}
|
||||
else if (argument.indexOf("-g") === 0)
|
||||
objjcFlags.includeMethodFunctionNames = true;
|
||||
else if (argument.indexOf("-O") === 0)
|
||||
{
|
||||
objjcFlags.compress = true;
|
||||
if (argument.length > 2)
|
||||
objjcFlags.inlineMsgSendFunctions = true;
|
||||
}
|
||||
else if (argument.indexOf("-G") === 0)
|
||||
objjcFlags.generate = true;
|
||||
else if (argument.indexOf("--inline-msg-send") === 0)
|
||||
{
|
||||
objjcFlags.inlineMsgSendFunctions = true;
|
||||
}
|
||||
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)
|
||||
{
|
||||
var shouldPrintOutput = false,
|
||||
asPlainJavascript = false,
|
||||
objjcFlags = {};
|
||||
var argv = args.slice(1);
|
||||
while (argv.length)
|
||||
{
|
||||
if (argv[0] === '--')
|
||||
{
|
||||
argv.shift();
|
||||
break;
|
||||
} if (argv[0] === "-p" || argv[0] === "--print")
|
||||
{
|
||||
shouldPrintOutput = YES;
|
||||
argv.shift();
|
||||
continue;
|
||||
} if (argv[0] === "--unmarked")
|
||||
{
|
||||
asPlainJavascript = true;
|
||||
argv.shift();
|
||||
continue;
|
||||
} if (argv[0] === "-T" || argv[0] === "--includeTypeSignatures")
|
||||
{
|
||||
objjcFlags.includeIvarTypeSignatures = true;
|
||||
objjcFlags.includeMethodArgumentTypeSignatures = true;
|
||||
argv.shift();
|
||||
continue;
|
||||
} if (argv[0] === "--help" || argv[0].substr(0, 1) == '-')
|
||||
{
|
||||
print("Usage (objjc 2.0): " + args[0] + " [options] [--] file...");
|
||||
print(" -p, --print print the output directly to stdout");
|
||||
print(" --unmarked don't tag the output with @STATIC header");
|
||||
print("");
|
||||
print(" -T, --dont-include-type-signatures include type signatures in the compiled output");
|
||||
print(" -g, --include-debug-symbols include debug symbols in the compiled output");
|
||||
print(" -T, --include-type-signatures include type signatures in the compiled output");
|
||||
print(" -O, --compress compress the compiled output");
|
||||
print(" -O2, --inline-msg-send inline objj_msgSend function in the compiled output");
|
||||
print(" -Wno-unused-but-set-variable turn off warning when a local variable is never read");
|
||||
print(" -Wno-shadow-ivar turn off warning when a local variable is shadowing an instance variable for the class");
|
||||
print(" -Wno-create-global-inside-function-or-method turn off warning when creating a global variable inside a function or method");
|
||||
print(" -Wno-unknown-class-or-global. turn off warning when a class or global variable is not known");
|
||||
print(" -Wno-unknown-ivar-type turn off warning when the type for an instance variable is not known");
|
||||
print(" To turn on a warning flag remove the 'no-' prefix. Example: -Wunused-but-set-variable");
|
||||
print("");
|
||||
print(" --help print this help");
|
||||
return;
|
||||
} break;
|
||||
} var resolved = resolveFlags(argv),
|
||||
outputFilePaths = resolved.outputFilePaths,
|
||||
gccFlags = resolved.gccFlags,
|
||||
resolvedObjjcFlags = resolved.objjcFlags;
|
||||
for (var key in resolvedObjjcFlags)
|
||||
{
|
||||
if (resolvedObjjcFlags.hasOwnProperty(key))
|
||||
{
|
||||
if (resolvedObjjcFlags[key])
|
||||
objjcFlags[key] = resolvedObjjcFlags[key];
|
||||
} } resolved.filePaths.forEach( function(filePath, index)
|
||||
{
|
||||
if (!shouldPrintOutput)
|
||||
print("Statically Compiling " + filePath);
|
||||
var output = compileWithResolvedFlags(filePath, objjcFlags, gccFlags, asPlainJavascript);
|
||||
if (output !== undefined)
|
||||
{
|
||||
if (shouldPrintOutput)
|
||||
print(output);
|
||||
else
|
||||
FILE.write(outputFilePaths[index], output, {charset: "UTF-8"});
|
||||
} });
|
||||
};
|
||||
if (require.main == module.id)
|
||||
exports.main(system.args);
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Objective-J.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2008-2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
var BUNDLE_TASK = require("./jake/bundletask");
|
||||
exports.BundleTask = BUNDLE_TASK.BundleTask;
|
||||
exports.bundle = BUNDLE_TASK.bundle;
|
||||
var FRAMEWORK_TASK = require("./jake/frameworktask");
|
||||
exports.FrameworkTask = FRAMEWORK_TASK.FrameworkTask;
|
||||
exports.framework = FRAMEWORK_TASK.framework;
|
||||
var APPLICATION_TASK = require("./jake/applicationtask");
|
||||
exports.ApplicationTask = APPLICATION_TASK.ApplicationTask;
|
||||
exports.app = APPLICATION_TASK.app;
|
||||
@@ -0,0 +1,503 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Content-Type: multipart/related; boundary="_SEPARATOR_"
|
||||
|
||||
--_SEPARATOR_
|
||||
Content-Location:test
|
||||
Content-Transfer-Encoding:base64
|
||||
|
||||
R0lGODlhAQABAIAAAMc9BQAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
||||
*/
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Objective-J.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2008-2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
var /* FILE = require("file"), */
|
||||
OS = require("os"),
|
||||
Jake = require("jake"),
|
||||
BundleTask = (require("./bundletask")).BundleTask;
|
||||
|
||||
var fs = require("fs-extra");
|
||||
var path = require("path");
|
||||
|
||||
function ApplicationTask(aName)
|
||||
{
|
||||
BundleTask.apply(this, arguments);
|
||||
|
||||
if (fs.existsSync("index.html"))
|
||||
this._indexFilePath = "index.html";
|
||||
else
|
||||
this._indexFilePath = null;
|
||||
if (fs.existsSync("Frameworks"))
|
||||
this._frameworksPath = "Frameworks";
|
||||
else
|
||||
this._frameworksPath = null;
|
||||
this._shouldGenerateCacheManifest = false;
|
||||
}
|
||||
ApplicationTask.__proto__ = BundleTask;
|
||||
ApplicationTask.prototype.__proto__ = BundleTask.prototype;
|
||||
ApplicationTask.prototype.packageType = function()
|
||||
{
|
||||
return "APPL";
|
||||
};
|
||||
ApplicationTask.prototype.defineTasks = function()
|
||||
{
|
||||
BundleTask.prototype.defineTasks.apply(this, arguments);
|
||||
this.defineFrameworksTask();
|
||||
this.defineIndexFileTask();
|
||||
this.defineCacheManifestTask();
|
||||
};
|
||||
ApplicationTask.prototype.setIndexFilePath = function(aFilePath)
|
||||
{
|
||||
this._indexFilePath = aFilePath;
|
||||
};
|
||||
ApplicationTask.prototype.indexFilePath = function()
|
||||
{
|
||||
return this._indexFilePath;
|
||||
};
|
||||
ApplicationTask.prototype.setFrameworksPath = function(aFrameworksPath)
|
||||
{
|
||||
this._frameworksPath = aFrameworksPath;
|
||||
};
|
||||
ApplicationTask.prototype.frameworksPath = function()
|
||||
{
|
||||
return this._frameworksPath;
|
||||
};
|
||||
ApplicationTask.prototype.setShouldGenerateCacheManifest = function(shouldGenerateCacheManifest)
|
||||
{
|
||||
this._shouldGenerateCacheManifest = shouldGenerateCacheManifest;
|
||||
};
|
||||
ApplicationTask.prototype.shouldGenerateCacheManifest = function()
|
||||
{
|
||||
return this._shouldGenerateCacheManifest;
|
||||
};
|
||||
ApplicationTask.prototype.defineFrameworksTask = function()
|
||||
{
|
||||
if (!this._frameworksPath && (this.environments()).indexOf((require("objective-j/jake/environment")).Browser) === -1)
|
||||
return;
|
||||
var buildPath = this.buildProductPath(),
|
||||
newFrameworks = path.join(buildPath, "Frameworks"),
|
||||
thisTask = this;
|
||||
Jake.fileCreate(newFrameworks, function()
|
||||
{
|
||||
if (thisTask._frameworksPath === "capp")
|
||||
OS.system(["capp", "gen", "-f", "--force", buildPath]);
|
||||
else if (thisTask._frameworksPath)
|
||||
{
|
||||
if (fs.existsSync(newFrameworks))
|
||||
fs.rmSync(newFrameworks, { recursive: true });
|
||||
var sourcePath = path.join(thisTask._frameworksPath, "Source"),
|
||||
hasSource = fs.existsSync(sourcePath),
|
||||
tempPath = path.join(process.cwd(), ".__capp_Frameworks_Source__");
|
||||
if (hasSource)
|
||||
fs.moveSync(sourcePath, tempPath);
|
||||
fs.copySync(thisTask._frameworksPath, newFrameworks, { recursive: true });
|
||||
if (hasSource)
|
||||
fs.moveSync(tempPath, sourcePath);
|
||||
} });
|
||||
this.enhance([newFrameworks]);
|
||||
};
|
||||
ApplicationTask.prototype.buildIndexFilePath = function()
|
||||
{
|
||||
return path.join(this.buildProductPath(), path.basename(this.indexFilePath()));
|
||||
};
|
||||
ApplicationTask.prototype.defineIndexFileTask = function()
|
||||
{
|
||||
if (!this._indexFilePath)
|
||||
return;
|
||||
var indexFilePath = this.indexFilePath(),
|
||||
buildIndexFilePath = this.buildIndexFilePath();
|
||||
Jake.filedir(buildIndexFilePath, [indexFilePath], function()
|
||||
{
|
||||
fs.copyFileSync(indexFilePath, buildIndexFilePath);
|
||||
});
|
||||
this.enhance([buildIndexFilePath]);
|
||||
};
|
||||
ApplicationTask.prototype.defineCacheManifestTask = function()
|
||||
{
|
||||
if (!this.shouldGenerateCacheManifest())
|
||||
return;
|
||||
var productPath = path.join(this.buildProductPath(), "");
|
||||
var indexFilePath = this.buildIndexFilePath();
|
||||
var manifestPath = path.join(productPath, "app.manifest");
|
||||
Jake.task(manifestPath, function()
|
||||
{
|
||||
(require("../cache-manifest")).generateManifest(productPath, {index: indexFilePath});
|
||||
});
|
||||
this.enhance([manifestPath]);
|
||||
};
|
||||
exports.ApplicationTask = ApplicationTask;
|
||||
exports.app = function(aName, aFunction)
|
||||
{
|
||||
return ApplicationTask.defineTask(aName, aFunction);
|
||||
};
|
||||
@@ -0,0 +1,732 @@
|
||||
/*
|
||||
* Objective-J.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2008-2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
var /* FILE = require("file"),
|
||||
OS = require("os"),
|
||||
UTIL = require("narwhal/util"),
|
||||
TERM = require("narwhal/term"),
|
||||
base64 = require("base64"),
|
||||
Jake = require("jake"),*/
|
||||
CLEAN = require("../../../common.jake").CLEAN,
|
||||
CLOBBER = require("../../../common.jake").CLOBBER,
|
||||
ObjectiveJ = require("objj-runtime"),
|
||||
environment = require("./environment");
|
||||
|
||||
/* task = Jake.task;
|
||||
var Task = Jake.Task,
|
||||
filedir = Jake.filedir; */
|
||||
|
||||
var jake = require("jake");
|
||||
var fs = require("fs-extra");
|
||||
var glob = require("glob");
|
||||
|
||||
var Task = jake.Task;
|
||||
const { task } = require("../../../common.jake");
|
||||
const { filedir } = require("../../../common.jake");
|
||||
|
||||
var path = require("path");
|
||||
var child_process = require("child_process");
|
||||
|
||||
function isImage(aFilename)
|
||||
{
|
||||
return [".png", ".jpg", ".jpeg", ".gif", ".tif", ".tiff"].includes(path.extname(aFilename).toLowerCase());
|
||||
}
|
||||
function mimeType(aFilename)
|
||||
{
|
||||
return {".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".tif": "image/tiff", ".tiff": "image/tiff"}[(path.extname(aFilename)).toLowerCase()];
|
||||
}
|
||||
function BundleTask(aName, anApplication)
|
||||
{
|
||||
Task.apply(this, arguments);
|
||||
var ignoreCommonJS = system.env["CAPP_IGNORE_COMMONJS_ENV"];
|
||||
if (ignoreCommonJS && ignoreCommonJS.toLowerCase() == "no" || ignoreCommonJS == "1")
|
||||
this.setEnvironments([environment.Browser]);
|
||||
else
|
||||
this.setEnvironments([environment.Browser, environment.CommonJS]);
|
||||
this._author = null;
|
||||
this._email = null;
|
||||
this._summary = null;
|
||||
this._license = null;
|
||||
this._sources = null;
|
||||
this._resources = null;
|
||||
this._spritesResources = true;
|
||||
this._identifier = null;
|
||||
this._version = 0.1;
|
||||
this._compilerFlags = null;
|
||||
this._flattensSources = false;
|
||||
this._includesNibsAndXibs = false;
|
||||
this._preventsNib2Cib = false;
|
||||
this._productName = this.name();
|
||||
this._buildIntermediatesPath = null;
|
||||
this._buildPath = process.cwd();
|
||||
this._replacedFiles = {};
|
||||
this._nib2cibFlags = null;
|
||||
this._infoPlistPath = "Info.plist";
|
||||
this._principalClass = null;
|
||||
}
|
||||
BundleTask.__proto__ = Task;
|
||||
BundleTask.prototype.__proto__ = Task.prototype;
|
||||
BundleTask.defineTask = function(aName, aFunction)
|
||||
{
|
||||
var bundleTask = Task.defineTask.apply(this, [aName]);
|
||||
if (aFunction)
|
||||
aFunction(bundleTask);
|
||||
bundleTask.defineTasks();
|
||||
return bundleTask;
|
||||
};
|
||||
BundleTask.prototype.setEnvironments = function(environments)
|
||||
{
|
||||
if (arguments.length < 1)
|
||||
this._environments = [];
|
||||
else if (arguments.length > 1)
|
||||
this._environments = Array.prototype.slice.apply(environments);
|
||||
else if (typeof environments.slice === "function")
|
||||
this._environments = environments.slice();
|
||||
else
|
||||
this._environments = [environments];
|
||||
};
|
||||
BundleTask.prototype.environments = function()
|
||||
{
|
||||
return this._environments;
|
||||
};
|
||||
BundleTask.prototype.setAuthor = function(anAuthor)
|
||||
{
|
||||
this._author = anAuthor;
|
||||
};
|
||||
BundleTask.prototype.author = function()
|
||||
{
|
||||
return this._author;
|
||||
};
|
||||
BundleTask.prototype.setEmail = function(anEmail)
|
||||
{
|
||||
this._email = anEmail;
|
||||
};
|
||||
BundleTask.prototype.email = function()
|
||||
{
|
||||
return this._email;
|
||||
};
|
||||
BundleTask.prototype.setSummary = function(aSummary)
|
||||
{
|
||||
this._summary = aSummary;
|
||||
};
|
||||
BundleTask.prototype.summary = function()
|
||||
{
|
||||
return this._summary;
|
||||
};
|
||||
BundleTask.prototype.setIdentifier = function(anIdentifier)
|
||||
{
|
||||
this._identifier = anIdentifier;
|
||||
};
|
||||
BundleTask.prototype.identifier = function()
|
||||
{
|
||||
return this._identifier;
|
||||
};
|
||||
BundleTask.prototype.setVersion = function(aVersion)
|
||||
{
|
||||
this._version = aVersion;
|
||||
};
|
||||
BundleTask.prototype.version = function()
|
||||
{
|
||||
return this._version;
|
||||
};
|
||||
BundleTask.prototype.setSources = function(sources, environments)
|
||||
{
|
||||
if (!environments)
|
||||
this._sources = sources;
|
||||
else
|
||||
{
|
||||
if (!this._sources)
|
||||
this._sources = {};
|
||||
if (!Array.isArray(environments))
|
||||
environments = [environments];
|
||||
environments.forEach( function(anEnvironment)
|
||||
{
|
||||
this._sources[anEnvironment] = sources;
|
||||
}, this);
|
||||
}};
|
||||
BundleTask.prototype.sources = function()
|
||||
{
|
||||
return this._sources;
|
||||
};
|
||||
BundleTask.prototype.setResources = function(resources)
|
||||
{
|
||||
this._resources = resources;
|
||||
};
|
||||
BundleTask.prototype.resources = function(resources)
|
||||
{
|
||||
this._resources = resources;
|
||||
};
|
||||
BundleTask.prototype.setSpritesResources = function(shouldSpriteResources)
|
||||
{
|
||||
this._spritesResources = shouldSpriteResources;
|
||||
};
|
||||
BundleTask.prototype.spritesResources = function()
|
||||
{
|
||||
return this._spritesResources;
|
||||
};
|
||||
BundleTask.prototype.setIncludesNibsAndXibs = function(shouldIncludeNibsAndXibs)
|
||||
{
|
||||
this._includesNibsAndXibs = shouldIncludeNibsAndXibs;
|
||||
};
|
||||
BundleTask.prototype.includesNibsAndXibs = function()
|
||||
{
|
||||
return this._includesNibsAndXibs;
|
||||
};
|
||||
BundleTask.prototype.setPreventsNib2Cib = function(shouldPreventNib2Cib)
|
||||
{
|
||||
this._preventsNib2Cib = shouldPreventNib2Cib;
|
||||
};
|
||||
BundleTask.prototype.preventsNib2Cib = function()
|
||||
{
|
||||
return this._preventsNib2Cib;
|
||||
};
|
||||
BundleTask.prototype.setProductName = function(aProductName)
|
||||
{
|
||||
this._productName = aProductName;
|
||||
};
|
||||
BundleTask.prototype.productName = function()
|
||||
{
|
||||
return this._productName;
|
||||
};
|
||||
BundleTask.prototype.setInfoPlistPath = function(anInfoPlistPath)
|
||||
{
|
||||
this._infoPlistPath = anInfoPlistPath;
|
||||
};
|
||||
BundleTask.prototype.infoPlistPath = function()
|
||||
{
|
||||
return this._infoPlistPath;
|
||||
};
|
||||
BundleTask.prototype.setPrincipalClass = function(aPrincipalClass)
|
||||
{
|
||||
this._principalClass = aPrincipalClass;
|
||||
};
|
||||
BundleTask.prototype.principalClass = function()
|
||||
{
|
||||
return this._principalClass;
|
||||
};
|
||||
BundleTask.prototype.setCompilerFlags = function(flags)
|
||||
{
|
||||
this._compilerFlags = flags;
|
||||
};
|
||||
BundleTask.prototype.compilerFlags = function()
|
||||
{
|
||||
return this._compilerFlags;
|
||||
};
|
||||
BundleTask.prototype.setNib2cibFlags = function(flags)
|
||||
{
|
||||
this._nib2cibFlags = flags;
|
||||
};
|
||||
BundleTask.prototype.setNib2CibFlags = BundleTask.prototype.setNib2cibFlags;
|
||||
BundleTask.prototype.nib2cibFlags = function()
|
||||
{
|
||||
return this._nib2cibFlags;
|
||||
};
|
||||
BundleTask.prototype.flattensSources = function()
|
||||
{
|
||||
return this._flattensSources;
|
||||
};
|
||||
BundleTask.prototype.setFlattensSources = function(shouldFlattenSources)
|
||||
{
|
||||
this._flattensSources = shouldFlattenSources;
|
||||
};
|
||||
BundleTask.prototype.setLicense = function(aLicense)
|
||||
{
|
||||
this._license = aLicense;
|
||||
};
|
||||
BundleTask.prototype.license = function()
|
||||
{
|
||||
return this._license;
|
||||
};
|
||||
(BundleTask.prototype.setBuildPath = function(aBuildPath)
|
||||
{
|
||||
this._buildPath = aBuildPath;
|
||||
}, BundleTask.prototype.buildPath = function()
|
||||
{
|
||||
return this._buildPath;
|
||||
});
|
||||
BundleTask.prototype.setBuildIntermediatesPath = function(aBuildPath)
|
||||
{
|
||||
this._buildIntermediatesPath = aBuildPath;
|
||||
};
|
||||
BundleTask.prototype.buildIntermediatesPath = function()
|
||||
{
|
||||
return this._buildIntermediatesPath || this.buildPath();
|
||||
};
|
||||
BundleTask.prototype.buildProductPath = function()
|
||||
{
|
||||
return path.join(this.buildPath(), this.productName());
|
||||
};
|
||||
BundleTask.prototype.buildIntermediatesProductPath = function()
|
||||
{
|
||||
return this.buildIntermediatesPath() || path.join(this.buildPath(), this.productName() + ".build");
|
||||
};
|
||||
BundleTask.prototype.buildProductStaticPathForEnvironment = function(anEnvironment)
|
||||
{
|
||||
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", this.productName() + ".sj");
|
||||
};
|
||||
BundleTask.prototype.buildProductMHTMLPathForEnvironment = function(anEnvironment)
|
||||
{
|
||||
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLPaths.txt");
|
||||
};
|
||||
BundleTask.prototype.buildProductMHTMLDataPathForEnvironment = function(anEnvironment)
|
||||
{
|
||||
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLData.txt");
|
||||
};
|
||||
BundleTask.prototype.buildProductMHTMLTestPathForEnvironment = function(anEnvironment)
|
||||
{
|
||||
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", "MHTMLTest.txt");
|
||||
};
|
||||
BundleTask.prototype.buildProductDataURLPathForEnvironment = function(anEnvironment)
|
||||
{
|
||||
return path.join(this.buildProductPath(), anEnvironment.name() + ".environment", "dataURLs.txt");
|
||||
};
|
||||
BundleTask.prototype.defineTasks = function()
|
||||
{
|
||||
this.defineResourceTasks();
|
||||
this.defineSourceTasks();
|
||||
this.defineInfoPlistTask();
|
||||
this.defineLicenseTask();
|
||||
this.defineStaticTask();
|
||||
this.defineSpritedImagesTask();
|
||||
CLEAN.include(this.buildIntermediatesProductPath());
|
||||
CLOBBER.include(this.buildProductPath());
|
||||
};
|
||||
BundleTask.prototype.packageType = function()
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
BundleTask.prototype.infoPlist = function()
|
||||
{
|
||||
var infoPlistPath = this.infoPlistPath(),
|
||||
infoPlist;
|
||||
|
||||
if (infoPlistPath && fs.existsSync(infoPlistPath))
|
||||
infoPlist = CFPropertyList.propertyListFromString(fs.readFileSync(infoPlistPath, {encoding: "utf8"}));
|
||||
else
|
||||
infoPlist = new CFMutableDictionary();
|
||||
infoPlist.setValueForKey("CPBundleInfoDictionaryVersion", 6.0);
|
||||
infoPlist.setValueForKey("CPBundleName", this.productName());
|
||||
infoPlist.setValueForKey("CPBundleIdentifier", this.identifier());
|
||||
infoPlist.setValueForKey("CPBundleVersion", this.version());
|
||||
infoPlist.setValueForKey("CPBundlePackageType", this.packageType());
|
||||
infoPlist.setValueForKey("CPBundleEnvironments", (this.environments()).map( function(anEnvironment)
|
||||
{
|
||||
return anEnvironment.name();
|
||||
}));
|
||||
infoPlist.setValueForKey("CPBundleExecutable", this.productName() + ".sj");
|
||||
var environmentsWithImageSprites = ((this.environments()).filter( function(anEnvironment)
|
||||
{
|
||||
return anEnvironment.spritesImages() && (((task(this.buildProductDataURLPathForEnvironment(anEnvironment))).prerequisites()).filter(isImage)).length > 0;
|
||||
}, this)).map( function(anEnvironment)
|
||||
{
|
||||
return anEnvironment.name();
|
||||
});
|
||||
infoPlist.setValueForKey("CPBundleEnvironmentsWithImageSprites", environmentsWithImageSprites);
|
||||
var principalClass = this.principalClass();
|
||||
if (principalClass)
|
||||
infoPlist.setValueForKey("CPPrincipalClass", principalClass);
|
||||
return infoPlist;
|
||||
};
|
||||
BundleTask.prototype.defineInfoPlistTask = function()
|
||||
{
|
||||
var infoPlistProductPath = path.join(this.buildProductPath(), "Info.plist"),
|
||||
bundleTask = this;
|
||||
filedir(infoPlistProductPath, function()
|
||||
{
|
||||
fs.writeFileSync(infoPlistProductPath, CFPropertyList.stringFromPropertyList(bundleTask.infoPlist(), CFPropertyList.Format280North_v1_0), { encoding: "utf8"});
|
||||
});
|
||||
var infoPlistPath = this.infoPlistPath();
|
||||
if (infoPlistPath && fs.existsSync(infoPlistPath))
|
||||
filedir(infoPlistProductPath, [infoPlistPath]);
|
||||
(this.environments()).forEach( function(anEnvironment)
|
||||
{
|
||||
if (!anEnvironment.spritesImages())
|
||||
return;
|
||||
filedir(infoPlistProductPath, this.buildProductStaticPathForEnvironment(anEnvironment));
|
||||
}, this);
|
||||
this.enhance([infoPlistProductPath]);
|
||||
};
|
||||
BundleTask.License = {LGPL_v2_1: "LGPL_v2_1", MIT: "MIT"};
|
||||
|
||||
var LICENSES_PATH = path.join(path.resolve(path.extname(module.path)), "LICENSES"),
|
||||
LICENSE_PATHS = {"LGPL_v2_1": path.join(LICENSES_PATH, "LGPL-v2.1"), "MIT": path.join(LICENSES_PATH, "MIT")};
|
||||
BundleTask.prototype.defineLicenseTask = function()
|
||||
{
|
||||
var license = this.license();
|
||||
if (!license)
|
||||
return;
|
||||
var licensePath = LICENSE_PATHS[license];
|
||||
licenseProductPath = path.join(this.buildProductPath(), "LICENSE");
|
||||
filedir(licenseProductPath, [licensePath], function()
|
||||
{
|
||||
fs.copyFileSync(licensePath, licenseProductPath);
|
||||
});
|
||||
this.enhance([licenseProductPath]);
|
||||
};
|
||||
BundleTask.prototype.resourcesPath = function()
|
||||
{
|
||||
return path.join(this.buildProductPath(), "Resources", "");
|
||||
};
|
||||
BundleTask.isSpritable = function(aResourcePath) {
|
||||
return isImage(aResourcePath) && fs.lstatSync(aResourcePath).size < 32768 && ("data:" + mimeType(aResourcePath) + ";base64," + Buffer.from(fs.readFileSync(aResourcePath)).toString("base64")).length < 32768;
|
||||
};
|
||||
BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPath)
|
||||
{
|
||||
if (this.spritesResources() && BundleTask.isSpritable(aResourcePath))
|
||||
{
|
||||
(this.environments()).forEach( function(anEnvironment)
|
||||
{
|
||||
if (!anEnvironment.spritesImages())
|
||||
return;
|
||||
var folder = anEnvironment.name() + ".environment",
|
||||
spritedDestinationPath = path.join(this.buildIntermediatesProductPath(), folder, "Resources", path.relative(this.resourcesPath(), aDestinationPath));
|
||||
filedir(spritedDestinationPath, function()
|
||||
{
|
||||
fs.writeFileSync(spritedDestinationPath, Buffer.from(fs.readFileSync(aResourcePath)).toString("base64"), { encoding: "utf8" });
|
||||
});
|
||||
filedir(this.buildProductDataURLPathForEnvironment(anEnvironment), [spritedDestinationPath]);
|
||||
filedir(this.buildProductMHTMLPathForEnvironment(anEnvironment), [spritedDestinationPath]);
|
||||
filedir(this.buildProductMHTMLDataPathForEnvironment(anEnvironment), [spritedDestinationPath]);
|
||||
filedir(this.buildProductMHTMLTestPathForEnvironment(anEnvironment), [spritedDestinationPath]);
|
||||
}, this);
|
||||
} var extension = path.extname(aResourcePath),
|
||||
extensionless = aResourcePath.substr(0, aResourcePath.length - extension.length);
|
||||
if ((extension !== ".cib" || !fs.existsSync(extensionless + ".xib") && !fs.existsSync(extensionless + ".nib") || this._preventsNib2Cib) && (extension !== ".xib" && extension !== ".nib" || this.includesNibsAndXibs()))
|
||||
{
|
||||
filedir(aDestinationPath, [aResourcePath], function()
|
||||
{
|
||||
if (fs.existsSync(aDestinationPath))
|
||||
try {
|
||||
fs.rmSync(aDestinationPath, { recursive: true });
|
||||
}
|
||||
catch(anException) {
|
||||
}
|
||||
if (fs.lstatSync(aResourcePath).isDirectory())
|
||||
fs.copySync(aResourcePath, aDestinationPath, { recursive: true });
|
||||
else
|
||||
fs.copySync(aResourcePath, aDestinationPath);
|
||||
});
|
||||
this.enhance([aDestinationPath]);
|
||||
} if ((extension === ".xib" || extension === ".nib") && !this._preventsNib2Cib)
|
||||
{
|
||||
var cibDestinationPath = path.join(path.dirname(aDestinationPath), path.basename(aDestinationPath, extension)) + ".cib";
|
||||
var nib2cibFlags = this.nib2cibFlags();
|
||||
if (!nib2cibFlags)
|
||||
nib2cibFlags = "";
|
||||
else if (nib2cibFlags.join)
|
||||
nib2cibFlags = nib2cibFlags.join(" ");
|
||||
filedir(cibDestinationPath, [aResourcePath], function()
|
||||
{
|
||||
child_process.execSync("nib2cib " + aResourcePath + " " + cibDestinationPath + " " + nib2cibFlags);
|
||||
});
|
||||
this.enhance([cibDestinationPath]);
|
||||
}};
|
||||
function directoryInCommon(filenames)
|
||||
{
|
||||
var aCommonDirectory = null;
|
||||
filenames.forEach( function(aFilename)
|
||||
{
|
||||
var directory = path.dirname(aFilename);
|
||||
if (directory === ".")
|
||||
directory = "";
|
||||
if (aCommonDirectory === null)
|
||||
aCommonDirectory = directory;
|
||||
else
|
||||
{
|
||||
var index = 0,
|
||||
count = Math.min(directory.length, aFilename.length);
|
||||
for (; index < count && aCommonDirectory.charAt(index) === directory.charAt(index); ++index);
|
||||
aCommonDirectory = directory.substr(0, index);
|
||||
} });
|
||||
return aCommonDirectory;
|
||||
}
|
||||
BundleTask.prototype.defineResourceTasks = function()
|
||||
{
|
||||
if (!this._resources)
|
||||
return;
|
||||
var resources = [],
|
||||
basePath = null;
|
||||
this._resources.forEach( function(aResourcePath)
|
||||
{
|
||||
if (fs.lstatSync(aResourcePath).isDirectory())
|
||||
{
|
||||
resources = resources.concat(aResourcePath, glob.sync(aResourcePath + "/**"));
|
||||
} else
|
||||
resources.push(aResourcePath);
|
||||
});
|
||||
// TODO: too lazy to look this up, assuming it returns the array without duplicates
|
||||
// resources = UTIL.unique(resources);
|
||||
resources = [... new Set(resources)];
|
||||
if (resources.length <= 0)
|
||||
return;
|
||||
var basePathLength = (directoryInCommon(resources)).length,
|
||||
resourcesPath = this.resourcesPath();
|
||||
resources.forEach( function(aResourcePath)
|
||||
{
|
||||
this.defineResourceTask(aResourcePath, path.join(resourcesPath, aResourcePath.substring(basePathLength)));
|
||||
}, this);
|
||||
};
|
||||
var RESOURCES_PATH = path.join(path.resolve(path.dirname(module.path)), "RESOURCES"),
|
||||
MHTMLTestPath = path.join(RESOURCES_PATH, "MHTMLTest.txt");
|
||||
BundleTask.prototype.defineSpritedImagesTask = function()
|
||||
{
|
||||
(this.environments()).forEach( function(anEnvironment)
|
||||
{
|
||||
if (!anEnvironment.spritesImages())
|
||||
return;
|
||||
var folder = anEnvironment.name() + ".environment",
|
||||
resourcesPath = path.join(this.buildIntermediatesProductPath(), folder, "Resources", "");
|
||||
var productName = this.productName(),
|
||||
dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment);
|
||||
filedir(dataURLPath, function(aTask){
|
||||
var prerequisites = (aTask.prerequisites()).filter(isImage);
|
||||
if (!prerequisites.length)
|
||||
{
|
||||
if (fs.existsSync(dataURLPath))
|
||||
fs.removeSync(dataURLPath);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Creating data URLs file... \0green(" + dataURLPath + "\0)");
|
||||
var dataURLStream = fs.openSync(dataURLPath, "w+");
|
||||
fs.writeSync(dataURLStream, "@STATIC;1.0;");
|
||||
|
||||
prerequisites.forEach(function(aFilename)
|
||||
{
|
||||
var resourcePath = "Resources/" + path.relative(resourcesPath, aFilename);
|
||||
fs.writeFileSync(dataURLStream, "u;" + resourcePath.length + ";" + resourcePath, {encoding: "utf8"});
|
||||
var contents = "data:" + mimeType(aFilename) + ";base64," + fs.readFileSync(aFilename).toString("utf8");
|
||||
fs.writeFileSync(dataURLStream, contents.length + ";" + contents, { encoding: "utf8" });
|
||||
});
|
||||
|
||||
fs.writeFileSync(dataURLStream, "e;", { encoding: "utf8"});
|
||||
fs.closeSync(dataURLStream);
|
||||
});
|
||||
this.enhance([dataURLPath]);
|
||||
var MHTMLPath = this.buildProductMHTMLPathForEnvironment(anEnvironment);
|
||||
filedir(MHTMLPath, function(aTask)
|
||||
{
|
||||
var prerequisites = (aTask.prerequisites()).filter(isImage);
|
||||
if (!prerequisites.length)
|
||||
{
|
||||
if (fs.existsSync(MHTMLPath))
|
||||
fs.rmSync(MHTMLPath);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Creating MHTML paths file... \0green(" + MHTMLPath + "\0)");
|
||||
var MHTMLStream = fs.openSync(MHTMLPath, "w+");
|
||||
fs.writeSync(MHTMLStream, "@STATIC;1.0;");
|
||||
|
||||
prerequisites.forEach( function(aFilename)
|
||||
{
|
||||
var resourcePath = "Resources/" + path.relative(resourcesPath, aFilename),
|
||||
MHTMLResourcePath = "mhtml:" + path.join(folder, "MHTMLData.txt!") + resourcePath;
|
||||
MHTMLStream.write("u;" + resourcePath.length + ";" + resourcePath);
|
||||
MHTMLStream.write(MHTMLResourcePath.length + ";" + MHTMLResourcePath);
|
||||
});
|
||||
fs.closeSync(MHTMLStream);
|
||||
MHTMLStream.close();
|
||||
});
|
||||
this.enhance([MHTMLPath]);
|
||||
var MHTMLDataPath = this.buildProductMHTMLDataPathForEnvironment(anEnvironment);
|
||||
filedir(MHTMLDataPath, function(aTask)
|
||||
{
|
||||
var prerequisites = (aTask.prerequisites()).filter(isImage);
|
||||
if (!prerequisites.length)
|
||||
{
|
||||
if (fs.existsSync(MHTMLDataPath))
|
||||
fs.rmSync(MHTMLDataPath);
|
||||
return;
|
||||
}
|
||||
console.log("Creating MHTML images file... \0green(" + MHTMLDataPath + "\0)");
|
||||
//var MHTMLDataStream = FILE.open(MHTMLDataPath, "w+", {charset: "UTF-8"});
|
||||
var MHTMLDataStream = fs.openSync(MHTMLDataPath, "w+");
|
||||
MHTMLDataStream.write("/*\r\nContent-Type: multipart/related; boundary=\"_ANY_STRING_WILL_DO_AS_A_SEPARATOR\"\r\n\r\n");
|
||||
prerequisites.forEach( function(aFilename)
|
||||
{
|
||||
var resourcePath = "Resources/" + path.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(fs.readFileSync(aFilename).toString("utf8"));
|
||||
MHTMLDataStream.write("\r\n");
|
||||
});
|
||||
MHTMLDataStream.write("*/");
|
||||
MHTMLDataStream.close();
|
||||
});
|
||||
this.enhance([MHTMLDataPath]);
|
||||
var MHTMLTestDestinationPath = this.buildProductMHTMLTestPathForEnvironment(anEnvironment);
|
||||
filedir(MHTMLTestDestinationPath, function(aTask)
|
||||
{
|
||||
console.log("Copying MHTML test file... \0green(" + MHTMLTestDestinationPath + "\0)");
|
||||
fs.copyFileSync(MHTMLTestPath, MHTMLTestDestinationPath);
|
||||
});
|
||||
this.enhance([MHTMLTestDestinationPath]);
|
||||
}, this);
|
||||
};
|
||||
BundleTask.prototype.defineStaticTask = function()
|
||||
{
|
||||
(this.environments()).forEach( function(anEnvironment)
|
||||
{
|
||||
var folder = anEnvironment.name() + ".environment",
|
||||
sourcesPath = path.join(this.buildIntermediatesProductPath(), folder, "Sources", ""),
|
||||
resourcesPath = path.join(this.buildIntermediatesProductPath(), folder, "Resources", ""),
|
||||
staticPath = this.buildProductStaticPathForEnvironment(anEnvironment),
|
||||
flattensSources = this.flattensSources(),
|
||||
productName = this.productName();
|
||||
filedir(staticPath, function(aTask)
|
||||
{
|
||||
console.log("Creating static file... \0green(" + staticPath + "\0)");
|
||||
//TERM.stream.print("Creating static file... \0green(" + staticPath + "\0)");
|
||||
var fileStream = fs.openSync(staticPath, "w+");
|
||||
fileStream.write("@STATIC;1.0;");
|
||||
(aTask.prerequisites()).forEach( function(aFilename)
|
||||
{
|
||||
if (!fs.lstatSync(aFilename).isFile())
|
||||
return;
|
||||
var dirname = path.dirname(aFilename);
|
||||
if (aFilename.indexOf(sourcesPath) === 0)
|
||||
{
|
||||
var relativePath = flattensSources ? path.basename(aFilename) : path.relative(sourcesPath, aFilename);
|
||||
fileStream.write("p;" + relativePath.length + ";" + relativePath);
|
||||
var fileContents = fs.readFileSync(aFilename).toString("utf8");
|
||||
fileStream.write("t;" + fileContents.length + ";" + fileContents);
|
||||
} else if (aFilename.indexOf(resourcesPath) === 0 && !isImage(aFilename))
|
||||
{
|
||||
var resourcePath = "Resources/" + path.relative(resourcesPath, aFilename);
|
||||
fileStream.write("p;");
|
||||
contents = fs.readFileSync(aFilename).toString("utf8");
|
||||
fileStream.write(resourcePath.length + ";" + resourcePath + contents);
|
||||
} }, this);
|
||||
fileStream.write("e;");
|
||||
fileStream.close();
|
||||
ObjectiveJ.Executable.resetCachedFileExecutableSearchers();
|
||||
ObjectiveJ.StaticResource.resetRootResources();
|
||||
ObjectiveJ.FileExecutable.resetFileExecutables();
|
||||
objj_resetRegisterClasses();
|
||||
});
|
||||
this.enhance([staticPath]);
|
||||
}, this);
|
||||
};
|
||||
BundleTask.prototype.defineSourceTasks = function()
|
||||
{
|
||||
var sources = this.sources();
|
||||
if (!sources)
|
||||
return;
|
||||
var compilerFlags = this.compilerFlags(),
|
||||
flattensSources = this.flattensSources();
|
||||
if (!compilerFlags)
|
||||
compilerFlags = "";
|
||||
else if (compilerFlags.join)
|
||||
compilerFlags = compilerFlags.join(" ");
|
||||
(this.environments()).forEach( function(anEnvironment)
|
||||
{
|
||||
var environmentSources = sources,
|
||||
folder = anEnvironment.name() + ".environment",
|
||||
sourcesPath = path.join(this.buildIntermediatesProductPath(), folder, "Sources", ""),
|
||||
staticPath = this.buildProductStaticPathForEnvironment(anEnvironment);
|
||||
if (!Array.isArray(environmentSources) && environmentSources.constructor !== jake.FileList)
|
||||
{
|
||||
environmentSources = environmentSources[anEnvironment];
|
||||
if (!environmentSources)
|
||||
return;
|
||||
} var replacedFiles = [],
|
||||
environmentCompilerFlags = (anEnvironment.compilerFlags()).join(" ") + " " + compilerFlags,
|
||||
flattensSources = this.flattensSources(),
|
||||
basePath = directoryInCommon(environmentSources),
|
||||
basePathLength = basePath.length,
|
||||
translateFilenameToPath = {},
|
||||
otherwayTranslateFilenameToPath = {};
|
||||
environmentSources.forEach( function(aFilename)
|
||||
{
|
||||
translateFilenameToPath[flattensSources ? path.basename(aFilename) : aFilename] = aFilename;
|
||||
otherwayTranslateFilenameToPath[aFilename] = flattensSources ? path.basename(aFilename) : aFilename;
|
||||
}, this);
|
||||
var e = {};
|
||||
environmentSources.forEach( function(aFilename)
|
||||
{
|
||||
ObjectiveJ.Executable.resetCachedFileExecutableSearchers();
|
||||
ObjectiveJ.StaticResource.resetRootResources();
|
||||
ObjectiveJ.FileExecutable.resetFileExecutables();
|
||||
objj_resetRegisterClasses();
|
||||
if (!fs.existsSync(aFilename))
|
||||
return;
|
||||
var relativePath = aFilename.substring(basePathLength ? basePathLength + 1 : basePathLength),
|
||||
compiledEnvironmentSource = path.join(sourcesPath, relativePath);
|
||||
filedir(compiledEnvironmentSource, [aFilename], function()
|
||||
{
|
||||
var rhinoUglyFix = false;
|
||||
if (system.engine === "rhino")
|
||||
{
|
||||
if (typeof document == "undefined")
|
||||
{
|
||||
document = {createElement: function(x)
|
||||
{
|
||||
return {innerText: "", style: {}};
|
||||
}};
|
||||
rhinoUglyFix = true;
|
||||
} if (typeof navigator == "undefined")
|
||||
{
|
||||
navigator = {"userAgent": "fakenavigator"};
|
||||
rhinoUglyFix = true;
|
||||
} } var compile;
|
||||
if ((path.extname(aFilename)).toLowerCase() !== ".j")
|
||||
{
|
||||
console.log("Including [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)");
|
||||
//(TERM.stream.write("Including [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)")).flush();
|
||||
var compiled = fs.readFileSync(aFilename, { encoding: "utf8"});
|
||||
} else
|
||||
{
|
||||
var translatedFilename = translateFilenameToPath[aFilename] ? translateFilenameToPath[aFilename] : aFilename,
|
||||
otherwayTranslatedFilename = otherwayTranslateFilenameToPath[aFilename] ? otherwayTranslateFilenameToPath[aFilename] : aFilename,
|
||||
theTranslatedFilename = otherwayTranslatedFilename ? otherwayTranslatedFilename : translatedFilename,
|
||||
absolutePath = path.absolute(theTranslatedFilename),
|
||||
basePath = absolutePath.substring(0, absolutePath.length - theTranslatedFilename.length);
|
||||
ObjectiveJ.FileExecutable.setCurrentGccCompilerFlags(environmentCompilerFlags);
|
||||
CFBundle.environments = function()
|
||||
{
|
||||
return [anEnvironment.name(), "ObjJ"];
|
||||
};
|
||||
ObjectiveJ.make_narwhal_factory(absolutePath, basePath, translateFilenameToPath)(require, e, module, system, print);
|
||||
console.log("Compiling [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)");
|
||||
//(TERM.stream.write("Compiling [\0blue(" + anEnvironment + "\0)] \0purple(" + aFilename + "\0)")).flush();
|
||||
var otherwayTranslatedFilename = otherwayTranslateFilenameToPath[aFilename] ? otherwayTranslateFilenameToPath[aFilename] : aFilename,
|
||||
translatedFilename = translateFilenameToPath[aFilename] ? translateFilenameToPath[aFilename] : aFilename,
|
||||
executer = new ObjectiveJ.FileExecutable(otherwayTranslatedFilename);
|
||||
var compiled = executer.toMarkedString();
|
||||
} if (rhinoUglyFix)
|
||||
delete document;
|
||||
console.log(compiledEnvironmentSource);
|
||||
console.log((Array(Math.round(compiled.length / 1024) + 3)).join("."));
|
||||
fs.writeFileSync(compiledEnvironmentSource, compiled, { encoding: "utf8"});
|
||||
});
|
||||
filedir(staticPath, [compiledEnvironmentSource]);
|
||||
replacedFiles.push(flattensSources ? path.basename(aFilename) : relativePath);
|
||||
}, this);
|
||||
this._replacedFiles[anEnvironment] = replacedFiles;
|
||||
}, this);
|
||||
};
|
||||
exports.BundleTask = BundleTask;
|
||||
exports.bundle = function(aName, aFunction)
|
||||
{
|
||||
return BundleTask.defineTask(aName, aFunction);
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Objective-J.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2008-2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
var environments = {};
|
||||
function Environment(aName)
|
||||
{
|
||||
this._name = aName;
|
||||
this._compilerFlags = [];
|
||||
this._spritesImages = false;
|
||||
environments[aName] = this;
|
||||
}
|
||||
Environment.environmentWithName = function(aName)
|
||||
{
|
||||
return environments[aName];
|
||||
};
|
||||
Environment.prototype.name = function()
|
||||
{
|
||||
return this._name;
|
||||
};
|
||||
Environment.prototype.toString = function()
|
||||
{
|
||||
return this._name;
|
||||
};
|
||||
Environment.prototype.compilerFlags = function()
|
||||
{
|
||||
return this._compilerFlags;
|
||||
};
|
||||
Environment.prototype.setCompilerFlags = function(flags)
|
||||
{
|
||||
this._compilerFlags = flags;
|
||||
};
|
||||
Environment.prototype.setSpritesImages = function(shouldSpriteImages)
|
||||
{
|
||||
this._spritesImages = !!shouldSpriteImages;
|
||||
};
|
||||
Environment.prototype.spritesImages = function()
|
||||
{
|
||||
return this._spritesImages;
|
||||
};
|
||||
exports.Environment = Environment;
|
||||
exports.ObjJ = new Environment("ObjJ");
|
||||
var CommonJS = new Environment("CommonJS");
|
||||
CommonJS.setCompilerFlags(["-DPLATFORM_COMMONJS"]);
|
||||
exports.CommonJS = CommonJS;
|
||||
var Browser = new Environment("Browser");
|
||||
Browser.setCompilerFlags(["-DPLATFORM_BROWSER", "-DPLATFORM_DOM"]);
|
||||
Browser.setSpritesImages(true);
|
||||
exports.Browser = Browser;
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Objective-J.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2008-2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
BundleTask = (require("./bundletask")).BundleTask;
|
||||
function FrameworkTask(aName)
|
||||
{
|
||||
BundleTask.apply(this, arguments);
|
||||
}
|
||||
FrameworkTask.__proto__ = BundleTask;
|
||||
FrameworkTask.prototype.__proto__ = BundleTask.prototype;
|
||||
FrameworkTask.prototype.packageType = function()
|
||||
{
|
||||
return "FMWK";
|
||||
};
|
||||
exports.FrameworkTask = FrameworkTask;
|
||||
exports.framework = function(aName, aFunction)
|
||||
{
|
||||
return FrameworkTask.defineTask(aName, aFunction);
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Objective-J.js
|
||||
* Objective-J
|
||||
*
|
||||
* Created by Francisco Tolmasky.
|
||||
* Copyright 2008-2010, 280 North, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
function ObjectiveJLoader()
|
||||
{
|
||||
var loader = {};
|
||||
var factories = {};
|
||||
loader.reload = function(topId, path)
|
||||
{
|
||||
if (!global.ObjectiveJ)
|
||||
global.ObjectiveJ = require("objective-j");
|
||||
factories[topId] = ObjectiveJ.make_narwhal_factory(path);
|
||||
factories[topId].path = path;
|
||||
};
|
||||
loader.load = function(topId, path)
|
||||
{
|
||||
if (!factories.hasOwnProperty(topId))
|
||||
loader.reload(topId, path);
|
||||
return factories[topId];
|
||||
};
|
||||
return loader;
|
||||
}
|
||||
require.loader.loaders.unshift([".j", ObjectiveJLoader()]);
|
||||
@@ -24,7 +24,7 @@ var subprojects = ["Objective-J", "CommonJS", "Foundation", "AppKit", "Tools"];
|
||||
{
|
||||
console.log("i build task action");
|
||||
subjake(subprojects, aTaskName);
|
||||
console.log("ur ur build task action");
|
||||
console.log("ut ur build task action");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+23
-26
@@ -23,25 +23,27 @@
|
||||
console.log("i jakefilen för obj-j");
|
||||
require("../common.jake");
|
||||
|
||||
const { FileList } = require("../common.jake");
|
||||
const { task } = require("../common.jake");
|
||||
const { filedir } = require("../common.jake");
|
||||
|
||||
// Make sure we can use new functions in an in old javascript engines like Rhino
|
||||
// This is only needed if new things are introduced in OldBrowserCompatibility.js
|
||||
// as we are running in an already built Objective-J environment
|
||||
require("./OldBrowserCompatibility");
|
||||
|
||||
var FILE = require("file"),
|
||||
/* var FILE = require("file"),
|
||||
OS = require("os"),
|
||||
stream = require("narwhal/term").stream;
|
||||
|
||||
var walk = require("./acornwalk").acorn.walk;
|
||||
stream = require("narwhal/term").stream; */
|
||||
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
var terser = require("terser");
|
||||
|
||||
var walk = require("./acornwalk").acorn.walk;
|
||||
acorn = {walk: walk};
|
||||
acorn = require("./acorn").acorn;
|
||||
|
||||
var compiler = require("./ObjJAcornCompiler").ObjJCompiler;
|
||||
var compiler = require("./ObjJAcornCompiler").ObjJCompiler;
|
||||
|
||||
//$BUILD_CONFIGURATION_DIR = "../Build"
|
||||
$BROWSER_FILE = path.join("Browser", "Objective-J.js");
|
||||
@@ -51,9 +53,12 @@ $BUILD_BROWSER_FILE = path.join($BUILD_OBJECTIVE_J, "Objective-J.js");
|
||||
|
||||
$INCLUDE_FLAGS = ["'-I" + process.cwd() + "'"];
|
||||
$DEBUG_FLAGS = $CONFIGURATION === "Debug" ? ["-DDEBUG=1"] : [""];
|
||||
$OBJECTIVEJ_FILES = new FileList("*.js");
|
||||
$OBJECTIVEJ_FILES = new jake.FileList();
|
||||
$OBJECTIVEJ_FILES.include("*.js");
|
||||
|
||||
$BROWSER_FILES = new FileList($BROWSER_FILE).include($OBJECTIVEJ_FILES);
|
||||
$BROWSER_FILES = new jake.FileList();
|
||||
$BROWSER_FILES.include($BROWSER_FILE);
|
||||
$BROWSER_FILES.include($OBJECTIVEJ_FILES);
|
||||
|
||||
filedir($BUILD_BROWSER_FILE, $BROWSER_FILES, function(aTask)
|
||||
{
|
||||
@@ -62,8 +67,8 @@ filedir($BUILD_BROWSER_FILE, $BROWSER_FILES, function(aTask)
|
||||
environmentFlags("Browser", "ObjJ").concat($INCLUDE_FLAGS, $DEBUG_FLAGS, ["-Wno-unused-but-set-variable"]), $CONFIGURATION !== "Debug");
|
||||
});
|
||||
|
||||
$LICENSE = FILE.join("CommonJS", "lib", "objective-j", "jake", "LICENSES", "LGPL-v2.1");
|
||||
$BUILD_LICENSE = FILE.join($BUILD_OBJECTIVE_J, "LICENSE");
|
||||
$LICENSE = path.join("CommonJS", "lib", "objective-j", "jake", "LICENSES", "LGPL-v2.1");
|
||||
$BUILD_LICENSE = path.join($BUILD_OBJECTIVE_J, "LICENSE");
|
||||
|
||||
filedir($BUILD_LICENSE, [$LICENSE], function()
|
||||
{
|
||||
@@ -125,29 +130,20 @@ function environmentFlags()
|
||||
}).concat("-DENVIRONMENTS=" + JSON.stringify(environments));
|
||||
}
|
||||
|
||||
var SHRINKSAFE = require("minify/shrinksafe");
|
||||
|
||||
async function compressor(srcCode) {
|
||||
return terser.minify(srcCode)
|
||||
return srcCode;
|
||||
}
|
||||
|
||||
var SHRINKSAFE = require("minify/shrinksafe");
|
||||
var TERSER = require("terser");
|
||||
function compressor(code) {
|
||||
return SHRINKSAFE.compress(code, { charset : "UTF-8", useServer : true });
|
||||
return TERSER.minify(code).code;
|
||||
|
||||
var headerText = FILE.read("header.txt", { charset : "UTF-8" });
|
||||
var headerText = fs.readFileSync("header.txt", { encoding: "utf8"});
|
||||
function gcc(inputFilePath, outputFilePath, flags, compress)
|
||||
{
|
||||
stream.print("Building... \0green(" + outputFilePath +"\0)");
|
||||
|
||||
var source = FILE.read(inputFilePath, { charset : "UTF-8" });
|
||||
console.log("Building... \0green(" + outputFilePath +"\0)");
|
||||
var source = fs.readFileSync(inputFilePath, { charset : "utf8" });
|
||||
var compilerOptions = compiler.parseGccCompilerFlags(flags.join(" "));
|
||||
var acornOptions = compilerOptions.acornOptions || (compilerOptions.acornOptions = {});
|
||||
|
||||
acornOptions.preprocessGetIncludeFile = function(filePath, isQuoted) {
|
||||
var includeContent = FILE.read(filePath, { charset : "UTF-8" });
|
||||
var includeContent = fs.readFileSync(filePath, { charset : "utf8" });
|
||||
//print ("Include content for file '" + filePath + "': " + includeContent);
|
||||
//print ("Include file '" + filePath + "'");
|
||||
return {include: includeContent, sourceFile: filePath};
|
||||
@@ -172,10 +168,11 @@ function gcc(inputFilePath, outputFilePath, flags, compress)
|
||||
var code = c.code();
|
||||
var contents = headerText + code;
|
||||
|
||||
if (FILE.extension(inputFilePath) === ".js" && compress)
|
||||
|
||||
if (path.extname(inputFilePath) === ".js" && compress)
|
||||
contents = compressor(contents);
|
||||
|
||||
FILE.write(outputFilePath, contents, { charset : "UTF-8" });
|
||||
fs.writeFileSync(outputFilePath, contents, { encoding : "utf8" });
|
||||
}
|
||||
|
||||
task("build", [$BUILD_BROWSER_FILE, $BUILD_LICENSE, $BUILD_CJS_OBJECTIVE_J_FRAMEWORK]);
|
||||
|
||||
+15
-21
@@ -25,6 +25,7 @@
|
||||
// var UTIL = require("narwhal/util");
|
||||
// var stream = require("narwhal/term").stream;
|
||||
|
||||
console.log("at the top of common.jake");
|
||||
var fs = require('fs');
|
||||
var child_process = require('child_process');
|
||||
var path = require('path');
|
||||
@@ -362,7 +363,7 @@ global.subjake = function(/*Array<String>*/ directories, /*String*/ aTaskName)
|
||||
if (fs.lstatSync(aDirectory).isDirectory() && fs.lstatSync(path.join(aDirectory, "Jakefile")).isFile())
|
||||
{
|
||||
|
||||
var cmd = "cd " + enquote(aDirectory) + " && " + serializedENV() + " " + "jake"+ " " + enquote(aTaskName);
|
||||
var cmd = "cd " + enquote(aDirectory) + " && " + serializedENV() + " " + "jake" + " " + enquote(aTaskName);
|
||||
var returnCode = systemSync(cmd);
|
||||
|
||||
if (returnCode)
|
||||
@@ -402,7 +403,8 @@ global.symlink_executable = function(source)
|
||||
|
||||
global.getCappuccinoVersion = function()
|
||||
{
|
||||
var versionFile = path.join(path.dirname(module.path), "version.json");
|
||||
console.log("sahfgdkjdkjfhgskjdhfgd");
|
||||
var versionFile = path.join(module.path, "version.json");
|
||||
return JSON.parse(fs.readFileSync(versionFile, { encoding: "utf8" })).version;
|
||||
};
|
||||
|
||||
@@ -410,30 +412,22 @@ global.setPackageMetadata = function(packagePath)
|
||||
{
|
||||
var pkg = JSON.parse(fs.readFileSync(packagePath, { encoding: "utf8" } ));
|
||||
|
||||
try
|
||||
{
|
||||
var p = child_process.spawnSync("git", ["rev-parse", "--verify", "HEAD"]);
|
||||
if (p.wait() === 0) {
|
||||
var sha = p.stdout.toString().split("\n")[0];
|
||||
if (sha.length === 40)
|
||||
pkg["cappuccino-revision"] = sha;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// FIXA: vet inte vad som händer här riktigt
|
||||
p.disconnect();
|
||||
/* p.stdin.close();
|
||||
p.stdout.close();
|
||||
p.stderr.close(); */
|
||||
try {
|
||||
var output = child_process.execSync("git", ["rev-parse", "--verify", "HEAD"]);
|
||||
var sha = output.toString().split("\n")[0];
|
||||
if (sha.length === 40)
|
||||
pkg["cappuccino-revision"] = sha;
|
||||
|
||||
} catch (error) {
|
||||
console.log("setPackageMetadata error " + error.status);
|
||||
}
|
||||
|
||||
pkg["cappuccino-timestamp"] = new Date().getTime();
|
||||
pkg["version"] = getCappuccinoVersion();
|
||||
|
||||
stream.print(" Version: \0purple(" + pkg["version"] + "\0)");
|
||||
stream.print(" Revision: \0purple(" + pkg["cappuccino-revision"] + "\0)");
|
||||
stream.print(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
|
||||
console.log(" Version: \0purple(" + pkg["version"] + "\0)");
|
||||
console.log(" Revision: \0purple(" + pkg["cappuccino-revision"] + "\0)");
|
||||
console.log(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
|
||||
|
||||
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 4), 'utf8');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user