mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Cleanup press and flatten arguments.
This commit is contained in:
+47
-3
@@ -14,6 +14,26 @@ var parser = new (require("args").Parser)();
|
||||
parser.usage("INPUT_PROJECT OUTPUT_PROJECT");
|
||||
parser.help("Combine a Cappuccino application into a single JavaScript file.");
|
||||
|
||||
parser.option("-m", "--main", "main")
|
||||
.def("main.j")
|
||||
.set()
|
||||
.help("The relative path (from INPUT_PROJECT) to the main file (default: 'main.j')");
|
||||
|
||||
parser.option("-F", "--framework", "frameworks")
|
||||
.def(["Frameworks"])
|
||||
.push()
|
||||
.help("Add a frameworks directory, relative to INPUT_PROJECT (default: ['Frameworks'])");
|
||||
|
||||
parser.option("-f", "--force", "force")
|
||||
.def(false)
|
||||
.set(true)
|
||||
.help("Force overwriting OUTPUT_PROJECT if it exists");
|
||||
|
||||
parser.option("-v", "--verbose", "verbose")
|
||||
.def(false)
|
||||
.set(true)
|
||||
.help("Verbose logging");
|
||||
|
||||
parser.helpful();
|
||||
|
||||
function main(args)
|
||||
@@ -28,12 +48,36 @@ function main(args)
|
||||
var rootPath = FILE.path(options.args[0]).join("").absolute();
|
||||
var outputPath = FILE.path(options.args[1]).join("").absolute();
|
||||
|
||||
if (outputPath.exists()) {
|
||||
if (options.force) {
|
||||
// FIXME: why doesn't this work?!
|
||||
//outputPath.rmtree();
|
||||
OS.system(["rm", "-rf", outputPath]);
|
||||
} else {
|
||||
CPLog.error("OUTPUT_PROJECT " + outputPath + " exists. Use -f to overwrite.");
|
||||
OS.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
var mainPath = String(rootPath.join(options.main));
|
||||
var frameworks = options.frameworks.map(function(framework) { return rootPath.join(framework); });
|
||||
var environment = "Browser";
|
||||
|
||||
stream.print("\0yellow("+Array(81).join("=")+"\0)");
|
||||
stream.print("Application root: \0green(" + rootPath + "\0)");
|
||||
stream.print("Output directory: \0green(" + outputPath + "\0)");
|
||||
|
||||
stream.print("\0yellow("+Array(81).join("=")+"\0)");
|
||||
stream.print("Main file: \0green(" + mainPath + "\0)");
|
||||
stream.print("Frameworks: \0green(" + frameworks + "\0)");
|
||||
stream.print("Environment: \0green(" + environment + "\0)");
|
||||
|
||||
var flattener = new ObjectiveJFlattener(rootPath);
|
||||
|
||||
flattener.setIncludePaths([rootPath.join("Frameworks")]);
|
||||
flattener.setEnvironments(["Browser", "ObjJ"]);
|
||||
flattener.setIncludePaths(frameworks);
|
||||
flattener.setEnvironments([environment, "ObjJ"]);
|
||||
|
||||
flattener.load(rootPath.join("main.j"));
|
||||
flattener.load(mainPath);
|
||||
flattener.finishLoading();
|
||||
|
||||
var root = flattener.require("objective-j").StaticResource.root;
|
||||
|
||||
+5
-13
@@ -26,11 +26,6 @@ parser.option("-F", "--framework", "frameworks")
|
||||
.push()
|
||||
.help("Add a frameworks directory, relative to INPUT_PROJECT (default: ['Frameworks'])");
|
||||
|
||||
parser.option("-E", "--environment", "environments")
|
||||
.def(['Browser'])
|
||||
.push()
|
||||
.help("Add a platform name (default: ['Browser'])");
|
||||
|
||||
parser.option("-f", "--force", "force")
|
||||
.def(false)
|
||||
.set(true)
|
||||
@@ -85,13 +80,12 @@ function press(rootPath, outputPath, options) {
|
||||
var outputFiles = {},
|
||||
totalBytes = {executable:0, data:0, mhtml:0};
|
||||
|
||||
var environment = "Browser";
|
||||
// analyze and gather files for each environment:
|
||||
options.environments.forEach(function(environment) {
|
||||
var returnedBytes = pressEnvironment(rootPath, outputFiles, environment, options);
|
||||
var returnedBytes = pressEnvironment(rootPath, outputFiles, environment, options);
|
||||
|
||||
for (var i in returnedBytes)
|
||||
totalBytes[i] += returnedBytes[i];
|
||||
});
|
||||
for (var i in returnedBytes)
|
||||
totalBytes[i] += returnedBytes[i];
|
||||
|
||||
// phase 4: copy everything and write out the new files
|
||||
stream.print("\0red(PHASE 4:\0) copy to output \0green(" + rootPath + "\0) => \0green(" + outputPath + "\0)");
|
||||
@@ -129,7 +123,7 @@ function press(rootPath, outputPath, options) {
|
||||
|
||||
if (FILE.exists(themePath))
|
||||
{
|
||||
var themeEnvPath = FILE.join(themePath, options.environments[0] + ".environment"),
|
||||
var themeEnvPath = FILE.join(themePath, environment + ".environment"),
|
||||
themeExecutablePath = FILE.join(themeEnvPath, themeName+".blend.sj"),
|
||||
themeDataPath = FILE.join(themeEnvPath, "dataURLs.txt"),
|
||||
themeMHTMLPath = FILE.join(themeEnvPath, "MHTMLPaths.txt");
|
||||
@@ -168,9 +162,7 @@ function pressEnvironment(rootPath, outputFiles, environment, options) {
|
||||
|
||||
var _OBJJ = analyzer.require("objective-j");
|
||||
|
||||
// include paths:
|
||||
analyzer.setIncludePaths(frameworks);
|
||||
// environments:
|
||||
analyzer.setEnvironments([environment, "ObjJ"]);
|
||||
|
||||
// build list of cibs to inspect for dependent classes
|
||||
|
||||
Reference in New Issue
Block a user