mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Resource fixes, added index.html support.
Reviewed by me.
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
|
||||
BundleTask = require("objective-j/jake/bundletask").BundleTask;
|
||||
var Jake = require("jake"),
|
||||
BundleTask = require("objective-j/jake/bundletask").BundleTask;
|
||||
|
||||
function ApplicationTask(aName)
|
||||
{
|
||||
BundleTask.apply(this, arguments);
|
||||
|
||||
if (require("file").exists("index.html"))
|
||||
this._indexFilePath = "index.html";
|
||||
else
|
||||
this._indexFilePath = null;
|
||||
}
|
||||
|
||||
ApplicationTask.__proto__ = BundleTask;
|
||||
@@ -14,6 +20,57 @@ ApplicationTask.prototype.packageType = function()
|
||||
return "APPL";
|
||||
}
|
||||
|
||||
ApplicationTask.prototype.defineTasks = function()
|
||||
{
|
||||
BundleTask.prototype.defineTasks.apply(this, arguments);
|
||||
|
||||
this.defineFrameworksTask();
|
||||
this.defineIndexFileTask();
|
||||
}
|
||||
|
||||
ApplicationTask.prototype.setIndexFilePath = function(aFilePath)
|
||||
{
|
||||
this._indexFilePath = aFilePath;
|
||||
}
|
||||
|
||||
ApplicationTask.prototype.indexFilePath = function()
|
||||
{
|
||||
return this._indexFilePath;
|
||||
}
|
||||
|
||||
ApplicationTask.prototype.defineFrameworksTask = function()
|
||||
{
|
||||
// FIXME: platform requires...
|
||||
if (this.platforms().indexOf(BundleTask.Platform.Browser) === -1)
|
||||
return;
|
||||
|
||||
var frameworks = FILE.join(this.buildProductPath(), "Frameworks"),
|
||||
thisTask = this;
|
||||
|
||||
Jake.fileCreate(frameworks, function()
|
||||
{
|
||||
OS.system("capp gen -f " + thisTask.buildProductPath());
|
||||
});
|
||||
|
||||
this.enhance([frameworks]);
|
||||
}
|
||||
|
||||
ApplicationTask.prototype.defineIndexFileTask = function()
|
||||
{
|
||||
if (!this._indexFilePath)
|
||||
return;
|
||||
|
||||
var indexFilePath = this.indexFilePath(),
|
||||
buildIndexFilePath = FILE.join(this.buildProductPath(), FILE.basename(this.indexFilePath()));
|
||||
|
||||
Jake.filedir (buildIndexFilePath, [indexFilePath], function()
|
||||
{
|
||||
cp(indexFilePath, buildIndexFilePath);
|
||||
});
|
||||
|
||||
this.enhance([buildIndexFilePath]);
|
||||
}
|
||||
|
||||
exports.ApplicationTask = ApplicationTask;
|
||||
|
||||
exports.app = function(aName, aFunction)
|
||||
@@ -21,32 +78,3 @@ exports.app = function(aName, aFunction)
|
||||
// No .apply necessary because the parameters aren't variable.
|
||||
return ApplicationTask.defineTask(aName, aFunction);
|
||||
}
|
||||
|
||||
/*
|
||||
if type == Bundle::Type::Application and index_file
|
||||
|
||||
index_file_path = File.join(build_path, File.basename(index_file))
|
||||
|
||||
file_d index_file_path => [index_file] do |t|
|
||||
cp(index_file, t.name)
|
||||
end
|
||||
|
||||
enhance([index_file_path])
|
||||
|
||||
frameworks_path = File.join(build_path, 'Frameworks')
|
||||
|
||||
file_d frameworks_path do
|
||||
IO.popen("capp gen -f " + build_path) do |capp|
|
||||
capp.sync = true
|
||||
|
||||
while str = capp.gets
|
||||
puts str
|
||||
end
|
||||
end
|
||||
rake abort if ($? != 0)
|
||||
end
|
||||
|
||||
enhance([frameworks_path])
|
||||
end
|
||||
|
||||
*/
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
var FILE = require("file"),
|
||||
OS = require("os"),
|
||||
UTIL = require("util"),
|
||||
Jake = require("jake"),
|
||||
objj_dictionary = require("objective-j").objj_dictionary,
|
||||
compiler = require("objective-j/compiler"),
|
||||
@@ -22,6 +23,7 @@ function BundleTask(aName, anApplication)
|
||||
this._platforms = [BundleTask.Platform.ObjJ];
|
||||
this._sources = null;
|
||||
this._resources = null;
|
||||
this._spritesResources = true;
|
||||
this._identifier = null;
|
||||
this._version = 0.1;
|
||||
|
||||
@@ -145,6 +147,16 @@ 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;
|
||||
@@ -157,7 +169,7 @@ BundleTask.prototype.includesNibsAndXibs = function()
|
||||
|
||||
BundleTask.prototype.setProductName = function(aProductName)
|
||||
{
|
||||
this._productName = aName;
|
||||
this._productName = aProductName;
|
||||
}
|
||||
|
||||
BundleTask.prototype.productName = function()
|
||||
@@ -347,7 +359,7 @@ BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPa
|
||||
var extension = FILE.extension(aResourcePath).toLowerCase(),
|
||||
extensionless = aResourcePath.substr(0, aResourcePath.length - extension.length);
|
||||
|
||||
if (IMAGE_EXTENSIONS.indexOf(extension) !== -1)
|
||||
if (this.spritesResources() && IMAGE_EXTENSIONS.indexOf(extension) !== -1)
|
||||
{
|
||||
aDestinationPath = FILE.join(this.buildIntermediatesProductPath(), "Browser" + ".platform", "Resources", FILE.relative(this.resourcesPath(), aDestinationPath));
|
||||
|
||||
@@ -358,7 +370,6 @@ BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPa
|
||||
});
|
||||
|
||||
filedir (this.buildProductStaticPathForPlatform("Browser"), [aDestinationPath]);
|
||||
return;
|
||||
}
|
||||
|
||||
// NOT:
|
||||
@@ -369,7 +380,7 @@ BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPa
|
||||
{
|
||||
filedir (aDestinationPath, [aResourcePath], function()
|
||||
{
|
||||
cp(aResourcePath, aDestinationPath);
|
||||
cp_r(aResourcePath, aDestinationPath);
|
||||
});
|
||||
|
||||
this.enhance([aDestinationPath]);
|
||||
@@ -396,30 +407,62 @@ BundleTask.prototype.defineResourceTask = function(aResourcePath, aDestinationPa
|
||||
}
|
||||
}
|
||||
|
||||
BundleTask.prototype.defineResourceTasks = function()
|
||||
function directoryInCommon(filenames)
|
||||
{
|
||||
if (!this.resources)
|
||||
return;
|
||||
var aCommonDirectory = null;
|
||||
|
||||
var resourcesPath = this.resourcesPath();
|
||||
|
||||
this._resources.forEach(function(aResourcePath)
|
||||
filenames.forEach(function(aFilename)
|
||||
{
|
||||
var baselength = FILE.basename(aResourcePath).length;
|
||||
var directory = FILE.dirname(aFilename);
|
||||
|
||||
if (FILE.isDirectory(aResourcePath))
|
||||
{
|
||||
FILE.glob(aResourcePath + "/**").forEach(function(aSubresourcePath)
|
||||
{
|
||||
// Is this the right way to go? Or should we include empty directories as well?
|
||||
if (!FILE.isDirectory(aSubresourcePath))
|
||||
this.defineResourceTask(aSubresourcePath, FILE.join(resourcesPath, aSubresourcePath.substring(aResourcePath.length - baselength)));
|
||||
}, this);
|
||||
}
|
||||
if (!aCommonDirectory)
|
||||
aCommonDirectory = directory;
|
||||
|
||||
else
|
||||
{
|
||||
this.defineResourceTask(aResourcePath, FILE.join(resourcesPath, FILE.basename(aResourcePath)));
|
||||
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);
|
||||
}
|
||||
});
|
||||
print("DIRECTORY IN COMMON IS " + aCommonDirectory);
|
||||
return aCommonDirectory;
|
||||
}
|
||||
|
||||
BundleTask.prototype.defineResourceTasks = function()
|
||||
{
|
||||
if (!this._resources)
|
||||
return;
|
||||
|
||||
var resources = [],
|
||||
basePath = null;
|
||||
|
||||
// Resolve resources. Consider any file passed in as a resource.
|
||||
this._resources.forEach(function(aResourcePath)
|
||||
{
|
||||
if (FILE.isDirectory(aResourcePath))
|
||||
{
|
||||
// Add the directory itself as well since it is a legitimate resource as well.
|
||||
resources = resources.concat(aResourcePath, FILE.glob(aResourcePath + "/**"));
|
||||
}
|
||||
else
|
||||
resources.push(aResourcePath);
|
||||
});
|
||||
|
||||
resources = UTIL.unique(resources);
|
||||
|
||||
if (resources.length <= 0)
|
||||
return;
|
||||
|
||||
var basePathLength = directoryInCommon(resources).length,
|
||||
resourcesPath = this.resourcesPath();
|
||||
|
||||
resources.forEach(function(aResourcePath)
|
||||
{
|
||||
this.defineResourceTask(aResourcePath, FILE.join(resourcesPath, aResourcePath.substring(basePathLength)));
|
||||
}, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
@import <Foundation/CPString.j>
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
var FILE = require("file"),
|
||||
SYSTEM = require("system"),
|
||||
plist = require("objective-j/plist");
|
||||
|
||||
|
||||
var DefaultDictionary = nil,
|
||||
DefaultConfiguration = nil,
|
||||
@@ -46,7 +50,7 @@ var DefaultDictionary = nil,
|
||||
+ (id)userConfiguration
|
||||
{
|
||||
if (!UserConfiguration)
|
||||
UserConfiguration = [[self alloc] initWithPath:String(new java.io.File(java.lang.System.getProperty("user.home") + "/.cappconfig").getCanonicalPath())];
|
||||
UserConfiguration = [[self alloc] initWithPath:FILE.join(SYSTEM.env["HOME"], ".cappconfig")];
|
||||
|
||||
return UserConfiguration;
|
||||
}
|
||||
@@ -61,23 +65,8 @@ var DefaultDictionary = nil,
|
||||
dictionary = [CPDictionary dictionary],
|
||||
temporaryDictionary = [CPDictionary dictionary];
|
||||
|
||||
if (aPath)
|
||||
{
|
||||
var file = new java.io.File([self path]);
|
||||
|
||||
if (file.canRead())
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = [CPData dataWithString:readFile(file.getCanonicalPath())],
|
||||
string = [data string];
|
||||
|
||||
if (string && string.length)
|
||||
dictionary = CPPropertyListCreateFromData(data);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
if (path && FILE.isReadable(path))
|
||||
dictionary = plist.readPlist(path);
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -131,11 +120,7 @@ var DefaultDictionary = nil,
|
||||
if (![self path])
|
||||
return;
|
||||
|
||||
var writer = new BufferedWriter(new FileWriter(new java.io.File([self path])));
|
||||
|
||||
writer.write([CPPropertyListCreate280NorthData(dictionary, kCFPropertyListXMLFormat_v1_0) string]);
|
||||
|
||||
writer.close();
|
||||
plist.writePlist([self path], dictionary);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+53
-49
@@ -1,7 +1,10 @@
|
||||
|
||||
@import "Configuration.j"
|
||||
|
||||
var File = require("file");
|
||||
var OS = require("OS"),
|
||||
SYSTEM = require("system"),
|
||||
FILE = require("file"),
|
||||
OBJJ = require("objective-j");
|
||||
|
||||
|
||||
function gen(/*va_args*/)
|
||||
@@ -49,32 +52,38 @@ function gen(/*va_args*/)
|
||||
destination = justFrameworks ? "." : "Untitled";
|
||||
|
||||
var sourceTemplate = null;
|
||||
if (File.isAbsolute(template))
|
||||
sourceTemplate = new java.io.File(template);
|
||||
|
||||
if (FILE.isAbsolute(template))
|
||||
sourceTemplate = FILE.join(template);
|
||||
else
|
||||
sourceTemplate = new java.io.File(OBJJ_HOME + "/lib/capp/Resources/Templates/" + template);
|
||||
sourceTemplate = FILE.join(OBJJ.OBJJ_HOME, "lib", "capp", "Resources", "Templates", template);
|
||||
|
||||
var configFile = File.join(sourceTemplate, "template.config"),
|
||||
var configFile = FILE.join(sourceTemplate, "template.config"),
|
||||
config = {};
|
||||
if (File.isFile(configFile))
|
||||
config = JSON.parse(File.read(configFile));
|
||||
print(config.FrameworksPath)
|
||||
var destinationProject = new java.io.File(destination),
|
||||
|
||||
if (FILE.isFile(configFile))
|
||||
config = JSON.parse(FILE.read(configFile, { charset:"UTF-8" }));
|
||||
|
||||
var destinationProject = destination,
|
||||
configuration = noConfig ? [Configuration defaultConfiguration] : [Configuration userConfiguration];
|
||||
|
||||
if (justFrameworks)
|
||||
createFrameworksInFile(destinationProject, shouldSymbolicallyLink, force);
|
||||
|
||||
else if (!destinationProject.exists())
|
||||
else if (!FILE.exists(destinationProject))
|
||||
{
|
||||
exec(["cp", "-vR", sourceTemplate.getCanonicalPath(), destinationProject.getCanonicalPath()], true);
|
||||
// FIXME???
|
||||
OS.system("cp -vR " + sourceTemplate + " " + destinationProject);
|
||||
|
||||
var files = getFiles(destinationProject),
|
||||
// FIXME: *JUST* for fixed glob
|
||||
require("jake");
|
||||
|
||||
var files = FILE.glob(FILE.join(destinationProject, "**", "*")),
|
||||
index = 0,
|
||||
count = files.length,
|
||||
name = String(destinationProject.getName()),
|
||||
name = FILE.basename(destinationProject),
|
||||
orgIdentifier = [configuration valueForKey:@"organization.identifier"] || "";
|
||||
|
||||
print("yo!"+files);
|
||||
[configuration setTemporaryValue:name forKey:@"project.name"];
|
||||
[configuration setTemporaryValue:orgIdentifier + '.' + toIdentifier(name) forKey:@"project.identifier"];
|
||||
[configuration setTemporaryValue:toIdentifier(name) forKey:@"project.nameasidentifier"];
|
||||
@@ -82,7 +91,7 @@ function gen(/*va_args*/)
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var path = files[index],
|
||||
contents = File.read(path, { charset : "UTF-8" }),
|
||||
contents = FILE.read(path, { charset : "UTF-8" }),
|
||||
key = nil,
|
||||
keyEnumerator = [configuration keyEnumerator];
|
||||
|
||||
@@ -93,12 +102,13 @@ function gen(/*va_args*/)
|
||||
while (key = [keyEnumerator nextObject])
|
||||
contents = contents.replace(new RegExp("__" + key + "__", 'g'), [configuration valueForKey:key]);
|
||||
|
||||
File.write(path, contents, { charset: "UTF-8"});
|
||||
FILE.write(path, contents, { charset: "UTF-8"});
|
||||
}
|
||||
|
||||
var frameworkDestination = destinationProject.getCanonicalPath();
|
||||
var frameworkDestination = destinationProject;
|
||||
|
||||
if (config.FrameworksPath)
|
||||
frameworkDestination = File.join(frameworkDestination, config.FrameworksPath);
|
||||
frameworkDestination = FILE.join(frameworkDestination, config.FrameworksPath);
|
||||
|
||||
createFrameworksInFile(frameworkDestination, shouldSymbolicallyLink);
|
||||
}
|
||||
@@ -109,62 +119,56 @@ function gen(/*va_args*/)
|
||||
|
||||
function createFrameworksInFile(/*String*/ aFile, /*Boolean*/ shouldSymbolicallyLink, /*Boolean*/ force)
|
||||
{
|
||||
if (!File.isDirectory(aFile))
|
||||
if (!FILE.isDirectory(aFile))
|
||||
throw new Error("Can't create Frameworks. Directory does not exist: " + aFile);
|
||||
|
||||
var destinationFrameworks = new java.io.File(aFile+ "/Frameworks"),
|
||||
destinationDebugFrameworks = new java.io.File(aFile + "/Frameworks/Debug");
|
||||
var destinationFrameworks = FILE.join(aFile, "Frameworks"),
|
||||
destinationDebugFrameworks = FILE.join(aFile, "Frameworks", "Debug");
|
||||
|
||||
if (destinationFrameworks.exists()) {
|
||||
if (force) {
|
||||
if (FILE.exists(destinationFrameworks))
|
||||
{
|
||||
if (force)
|
||||
{
|
||||
print("Updating existing Frameworks directory.");
|
||||
exec(["rm", "-rf", destinationFrameworks], true);
|
||||
|
||||
FILE.rmTree(destinationFrameworks);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
print("Frameworks directory already exists. Use --force to overwrite.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
print("Creating Frameworks directory in "+destinationFrameworks+".");
|
||||
}
|
||||
else
|
||||
print("Creating Frameworks directory in " + destinationFrameworks + ".");
|
||||
|
||||
if (!shouldSymbolicallyLink)
|
||||
{
|
||||
var sourceFrameworks = new java.io.File(OBJJ_HOME + "/lib/Frameworks");
|
||||
var sourceFrameworks = FILE.join(OBJJ.OBJJ_HOME + "lib", "Frameworks");
|
||||
|
||||
exec(["cp", "-R", sourceFrameworks.getCanonicalPath(), destinationFrameworks], true);
|
||||
FILE.copyTree(sourceFrameworks, destinationFrameworks);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var BUILD = system.env["CAPP_BUILD"] || system.env["STEAM_BUILD"];
|
||||
var BUILD = SYSTEM.env["CAPP_BUILD"] || SYSTEM.env["STEAM_BUILD"];
|
||||
|
||||
if (!BUILD)
|
||||
throw "CAPP_BUILD or STEAM_BUILD must be defined";
|
||||
|
||||
|
||||
// Release Frameworks
|
||||
new java.io.File(destinationFrameworks).mkdir();
|
||||
FILE.mkdirs(destinationFrameworks);
|
||||
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Release/Objective-J").getCanonicalPath(),
|
||||
new java.io.File(aFile + "/Frameworks/Objective-J").getCanonicalPath()], true);
|
||||
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Release/Foundation").getCanonicalPath(),
|
||||
new java.io.File(aFile + "/Frameworks/Foundation").getCanonicalPath()], true);
|
||||
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Release/AppKit").getCanonicalPath(),
|
||||
new java.io.File(aFile + "/Frameworks/AppKit").getCanonicalPath()], true);
|
||||
FILE.symlink(FILE.join(BUILD + "Release", "Objective-J"), FILE.join(destinationFrameworks, "Objective-J"));
|
||||
FILE.symlink(FILE.join(BUILD + "Release", "Foundation"), FILE.join(destinationFrameworks, "Foundation"));
|
||||
FILE.symlink(FILE.join(BUILD + "Release", "AppKit"), FILE.join(destinationFrameworks, "AppKit"));
|
||||
|
||||
// Debug Frameworks
|
||||
new java.io.File(destinationDebugFrameworks).mkdir();
|
||||
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Debug/Objective-J").getCanonicalPath(),
|
||||
new java.io.File(aFile + "/Frameworks/Debug/Objective-J").getCanonicalPath()], true);
|
||||
FILE.mkdirs(destinationDebugFrameworks);
|
||||
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Debug/Foundation").getCanonicalPath(),
|
||||
new java.io.File(aFile + "/Frameworks/Debug/Foundation").getCanonicalPath()], true);
|
||||
|
||||
exec(["ln", "-s", new java.io.File(BUILD + "/Debug/AppKit").getCanonicalPath(),
|
||||
new java.io.File(aFile + "/Frameworks/Debug/AppKit").getCanonicalPath()], true);
|
||||
FILE.symlink(FILE.join(BUILD + "Debug", "Objective-J"), FILE.join(destinationDebugFrameworks, "Objective-J"));
|
||||
FILE.symlink(FILE.join(BUILD + "Debug", "Foundation"), FILE.join(destinationDebugFrameworks, "Foundation"));
|
||||
FILE.symlink(FILE.join(BUILD + "Debug", "AppKit"), FILE.join(destinationDebugFrameworks, "AppKit"));
|
||||
}
|
||||
|
||||
function toIdentifier(/*String*/ aString)
|
||||
|
||||
+5
-3
@@ -14,10 +14,12 @@ app ("capp", function(cappTask)
|
||||
cappTask.setIdentifier("com.280n.capp");
|
||||
cappTask.setLicense(BundleTask.License.LGPL_v2_1);
|
||||
cappTask.setVersion("0.7.1");
|
||||
cappTask.setSources(FILE.glob("*.j"));
|
||||
cappTask.setResources(["Templates"]);
|
||||
cappTask.setSources(new FileList("*.j"));
|
||||
cappTask.setResources(new FileList("Resources/*"));
|
||||
cappTask.setIncludesNibsAndXibs(true);
|
||||
cappTask.setPlatforms([BundleTask.Platform.CommonJS]);
|
||||
cappTask.setFlattensSources(true);
|
||||
cappTask.setSpritesResources(false);
|
||||
|
||||
if ($CONFIGURATION === "Release")
|
||||
cappTask.setCompilerFlags("-O");
|
||||
@@ -25,7 +27,7 @@ app ("capp", function(cappTask)
|
||||
cappTask.setCompilerFlags("-DDEBUG -g");
|
||||
});
|
||||
|
||||
$COMMONJS_CAPP_BIN_PRODUCT = FILE.join($COMMONJS_PRODUCT_BIN, 'nib2cib');
|
||||
$COMMONJS_CAPP_BIN_PRODUCT = FILE.join($COMMONJS_PRODUCT_BIN, "capp");
|
||||
|
||||
// executable in environment directory
|
||||
filedir($COMMONJS_CAPP_BIN_PRODUCT, ["capp"], function()
|
||||
|
||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
+8
-54
@@ -1,22 +1,19 @@
|
||||
importClass(java.io.FileWriter);
|
||||
importClass(java.io.FileOutputStream);
|
||||
importClass(java.io.BufferedWriter);
|
||||
importClass(java.io.OutputStreamWriter);
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
|
||||
@import "Configuration.j"
|
||||
@import "Generate.j"
|
||||
|
||||
print("what?...");
|
||||
|
||||
function main()
|
||||
{
|
||||
{print("insdie?...");
|
||||
if (system.args.length < 1)
|
||||
return printUsage();
|
||||
|
||||
var index = 0,
|
||||
count = system.args.length;
|
||||
|
||||
print("p;!");
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var argument = system.args[index];
|
||||
@@ -31,7 +28,7 @@ function main()
|
||||
|
||||
case "config": return config.apply(this, system.args.slice(index + 1));
|
||||
|
||||
case "gen": return gen.apply(this, system.args.slice(index + 1));
|
||||
case "gen": print("!");return gen.apply(this, system.args.slice(index + 1));
|
||||
|
||||
default: print("unknown command " + argument);
|
||||
}
|
||||
@@ -56,49 +53,6 @@ function printUsage()
|
||||
print(" --get name Get the value for a given key");
|
||||
}
|
||||
|
||||
function writeContentsToFile(/*String*/ aString, /*File*/ aFile)
|
||||
{
|
||||
var writer = new BufferedWriter(new FileWriter(aFile));
|
||||
|
||||
writer.write(aString);
|
||||
|
||||
writer.close();
|
||||
}
|
||||
|
||||
function exec(/*Array*/ command, /*Boolean*/ showOutput)
|
||||
{
|
||||
var line = "",
|
||||
output = "",
|
||||
|
||||
process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command));
|
||||
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream()));
|
||||
|
||||
while (line = reader.readLine())
|
||||
{
|
||||
if (showOutput)
|
||||
Packages.java.lang.System.out.println(line);
|
||||
|
||||
output += line + '\n';
|
||||
}
|
||||
|
||||
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream()));
|
||||
|
||||
while (line = reader.readLine())
|
||||
Packages.java.lang.System.out.println(line);
|
||||
|
||||
try
|
||||
{
|
||||
if (process.waitFor() != 0)
|
||||
Packages.java.lang.System.err.println("exit value = " + process.exitValue());
|
||||
}
|
||||
catch (anException)
|
||||
{
|
||||
Packages.java.lang.System.err.println(anException);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
function getFiles(/*File*/ sourceDirectory, /*nil|String|Array<String>*/ extensions, /*Array*/ exclusions)
|
||||
{
|
||||
var matches = [],
|
||||
@@ -112,8 +66,8 @@ function getFiles(/*File*/ sourceDirectory, /*nil|String|Array<String>*/ extensi
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var file = files[index].getCanonicalFile(),
|
||||
name = String(file.getName()),
|
||||
var file = files[index],
|
||||
name = FILE.basename(file),
|
||||
isValidExtension = !extensions;
|
||||
|
||||
if (exclusions && fileArrayContainsFile(exclusions, file))
|
||||
@@ -135,10 +89,10 @@ function getFiles(/*File*/ sourceDirectory, /*nil|String|Array<String>*/ extensi
|
||||
else if (name.substring(name.length - extensions.length - 1) === ("." + extensions))
|
||||
isValidExtension = true;
|
||||
|
||||
if (file.isDirectory())
|
||||
if (FILE.isDirectory(file))
|
||||
matches = matches.concat(getFiles(file, extensions, exclusions));
|
||||
else if (isValidExtension)
|
||||
matches.push(String(file.getCanonicalPath()));
|
||||
matches.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user