mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-04 18:03:41 +00:00
Merge pull request #2248 from Dogild/OBJJEnhancement
New: new options for the command objj
This commit is contained in:
@@ -68,6 +68,8 @@ with (window)
|
||||
// runs the objj repl or file provided in args
|
||||
exports.run = function(args)
|
||||
{
|
||||
var multipleFiles = false;
|
||||
|
||||
if (args)
|
||||
{
|
||||
// we expect args to be in the format:
|
||||
@@ -79,27 +81,82 @@ exports.run = function(args)
|
||||
// copy the args since we're going to modify them
|
||||
var argv = args.slice(1);
|
||||
|
||||
if (argv[0] === "--version")
|
||||
if (argv[0] === "--version" || argv[0] === "-v")
|
||||
{
|
||||
print(exports.fullVersionString());
|
||||
return;
|
||||
}
|
||||
|
||||
while (argv.length && argv[0].indexOf('-I') === 0)
|
||||
OBJJ_INCLUDE_PATHS.unshift.apply(OBJJ_INCLUDE_PATHS, argv.shift().substr(2).split(':'));
|
||||
if (argv[0] === "--help" || argv[0] === "-h")
|
||||
{
|
||||
print("Usage (objj): " + args[0] + " [options] [--] files...");
|
||||
print(" -v, --version print the current version of objj");
|
||||
print(" -I, --objj-include-paths include a specific framework paths")
|
||||
print(" -h, --help print this help");
|
||||
print(" -m, --multifiles launch objj on several files")
|
||||
return;
|
||||
}
|
||||
|
||||
while (argv.length && argv[0].indexOf('-') === 0)
|
||||
{
|
||||
switch (argv[0])
|
||||
{
|
||||
case "-I":
|
||||
argv.shift();
|
||||
OBJJ_INCLUDE_PATHS.unshift.apply(OBJJ_INCLUDE_PATHS, argv.shift().split(":"));
|
||||
break;
|
||||
|
||||
case "-m":
|
||||
argv.shift();
|
||||
multipleFiles = true;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argv && argv.length > 0)
|
||||
{
|
||||
var arg0 = argv.shift();
|
||||
var mainFilePath = FILE.canonical(arg0);
|
||||
var endCommand = false;
|
||||
|
||||
exports.make_narwhal_factory(mainFilePath)(require, { }, module, system, print);
|
||||
while (argv.length > 0)
|
||||
{
|
||||
var arg0 = argv.shift();
|
||||
var mainFilePath = FILE.canonical(arg0);
|
||||
|
||||
if (typeof main === "function")
|
||||
main([arg0].concat(argv));
|
||||
if (multipleFiles)
|
||||
{
|
||||
// This is needed to process every files passed in args
|
||||
// Otherwise it would stop when an error is raised or we would like to objj the other given files
|
||||
try
|
||||
{
|
||||
exports.make_narwhal_factory(mainFilePath)(require, { }, module, system, print);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
print("\n" + e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exports.make_narwhal_factory(mainFilePath)(require, { }, module, system, print);
|
||||
}
|
||||
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
if (typeof main === "function")
|
||||
{
|
||||
main([arg0].concat(argv));
|
||||
endCommand = true;
|
||||
}
|
||||
|
||||
require("browser/timeout").serviceTimeouts();
|
||||
|
||||
if (!multipleFiles || endCommand)
|
||||
break;
|
||||
|
||||
ObjectiveJ.Executable.resetCachedFileExecutableSearchers();
|
||||
ObjectiveJ.StaticResource.resetRootResources();
|
||||
ObjectiveJ.FileExecutable.resetFileExecutables();
|
||||
objj_resetRegisterClasses();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -29,6 +29,15 @@ function cleanup() {
|
||||
|
||||
status = OS.system(["flatten", "-f", "ToolsTestApp", "FlattenTestApp"].map(OS.enquote).join(" ") + " > /dev/null");
|
||||
[self assert:0 equals:status message:"flatten failed"];
|
||||
|
||||
status = OS.system(["objj", "ToolsTestApp/AppController.j"]);
|
||||
[self assert:0 equals:status message:"objj failed"];
|
||||
|
||||
status = OS.system(["objj", "-m", "ToolsTestApp/AppController.j", "ToolsTestApp/AppController.j"]);
|
||||
[self assert:0 equals:status message:"objj failed with several files"];
|
||||
|
||||
status = OS.system(["objj", "-I", "ToolsTestApp/Frameworks", "ToolsTestApp/AppController.j"]);
|
||||
[self assert:0 equals:status message:"objj failed with options -I"];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
return;
|
||||
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
|
||||
|
||||
NSDictionary *info = @{ @"projectId":self.projectId, @"path":self.sourcePath };
|
||||
[center postNotificationName:XCCConversionDidStartNotification object:self userInfo:info];
|
||||
|
||||
@@ -84,21 +84,21 @@
|
||||
return;
|
||||
|
||||
[self.xcc performSelectorOnMainThread:@selector(computeIgnoredPaths) withObject:nil waitUntilDone:NO];
|
||||
|
||||
|
||||
notificationTitle = @"Parsed .xcodecapp-ignore";
|
||||
notificationMessage = @"Ignored paths updated";
|
||||
}
|
||||
|
||||
// Run the task and get the response if needed
|
||||
NSInteger status = 0;
|
||||
|
||||
|
||||
if (arguments)
|
||||
{
|
||||
if (self.isCancelled)
|
||||
return;
|
||||
|
||||
DDLogVerbose(@"Running processing task: %@", launchPath);
|
||||
|
||||
|
||||
NSDictionary *taskResult = [self.xcc runTaskWithLaunchPath:launchPath
|
||||
arguments:arguments
|
||||
returnType:kTaskReturnTypeAny];
|
||||
@@ -120,7 +120,7 @@
|
||||
|
||||
notificationTitle = @"Error converting xib";
|
||||
NSString *message = [NSString stringWithFormat:@"%@\n%@", self.sourcePath.lastPathComponent, response];
|
||||
|
||||
|
||||
NSDictionary *info =
|
||||
@{
|
||||
@"projectId":self.projectId,
|
||||
@@ -131,7 +131,7 @@
|
||||
|
||||
if (self.isCancelled)
|
||||
return;
|
||||
|
||||
|
||||
[center postNotificationName:XCCConversionDidGenerateErrorNotification object:self userInfo:info];
|
||||
}
|
||||
else
|
||||
@@ -152,14 +152,14 @@
|
||||
[self postErrorNotificationForPath:self.sourcePath line:0 message:response status:status];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([self.xcc shouldShowErrorNotification])
|
||||
[self notifyUserWithTitle:notificationTitle message:notificationMessage];
|
||||
}
|
||||
else if (!self.xcc.isLoadingProject)
|
||||
{
|
||||
BOOL showFinalNotification = YES;
|
||||
|
||||
|
||||
if ([self.xcc shouldProcessWithCappLint])
|
||||
{
|
||||
showFinalNotification = [self.xcc checkCappLintForPath:[NSArray arrayWithObject:self.sourcePath]];
|
||||
@@ -167,7 +167,7 @@
|
||||
if (!showFinalNotification)
|
||||
[self.xcc showCappLintErrors];
|
||||
}
|
||||
|
||||
|
||||
if (showFinalNotification)
|
||||
[self notifyUserWithTitle:notificationTitle message:notificationMessage];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user