mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-26 05:27:03 +00:00
Fixed: some error handling needed improving.
- Added ~/narwhal/bin to executable paths. - Hopefully clearer error message when an executable is missing. - Log PATH when executable is missing. - Catch parse exceptions when parsing parser.j errors, log the returned text.
This commit is contained in:
@@ -91,9 +91,20 @@ AppController *SharedAppControllerInstance = nil;
|
||||
|
||||
if (![self.xcc executablesAreAccessible])
|
||||
{
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
|
||||
NSRunAlertPanel(@"Executables are missing.", @"Please make sure that python, jsc, objj and nib2cib (or symlinks to them) are somewhere within one of these directories:\n\n/bin\n/usr/bin\n/usr/local/bin\n/usr/local/narwhal/bin\n~/bin\n\nThen launch XcodeCapp again.", @"Quit", nil, nil);
|
||||
NSRunAlertPanel(
|
||||
@"Executables are missing.",
|
||||
@"Please make sure that each one of these executables:\n\n"
|
||||
@"%@\n\n"
|
||||
@"(or a symlink to it) is within one these directories:\n\n"
|
||||
@"%@\n\n"
|
||||
@"They do not all have to be in the same directory.",
|
||||
@"Quit",
|
||||
nil,
|
||||
nil,
|
||||
[self.xcc.executables componentsJoinedByString:@"\n"],
|
||||
[self.xcc.environmentPaths componentsJoinedByString:@"\n"]);
|
||||
|
||||
[[NSApplication sharedApplication] terminate:self];
|
||||
return;
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.0.3</string>
|
||||
<string>3.0.4</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>3.0.3</string>
|
||||
<string>3.0.4</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSUIElement</key>
|
||||
@@ -32,12 +32,5 @@
|
||||
<string>NSApplication</string>
|
||||
<key>XCCCompatibilityVersion</key>
|
||||
<real>3</real>
|
||||
<key>XCCMandatoryExecutables</key>
|
||||
<array>
|
||||
<string>python</string>
|
||||
<string>narwhal-jsc</string>
|
||||
<string>objj</string>
|
||||
<string>nib2cib</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -138,19 +138,26 @@
|
||||
{
|
||||
notificationTitle = [(status == XCCStatusCodeError ? @"Error" : @"Warning") stringByAppendingString:@" parsing Objective-J source"];
|
||||
|
||||
NSArray *errors = [response propertyList];
|
||||
|
||||
for (NSDictionary *error in errors)
|
||||
@try
|
||||
{
|
||||
NSMutableDictionary *info = [error mutableCopy];
|
||||
info[@"projectId"] = self.projectId;
|
||||
info[@"message"] = [NSString stringWithFormat:@"%@, line %d\n%@", [error[@"path"] lastPathComponent], [error[@"line"] intValue], error[@"message"]];
|
||||
info[@"status"] = taskResult[@"status"];
|
||||
NSArray *errors = [response propertyList];
|
||||
|
||||
if (self.isCancelled)
|
||||
return;
|
||||
|
||||
[center postNotificationName:XCCConversionDidGenerateErrorNotification object:self userInfo:info];
|
||||
for (NSDictionary *error in errors)
|
||||
{
|
||||
NSMutableDictionary *info = [error mutableCopy];
|
||||
info[@"projectId"] = self.projectId;
|
||||
info[@"message"] = [NSString stringWithFormat:@"%@, line %d\n%@", [error[@"path"] lastPathComponent], [error[@"line"] intValue], error[@"message"]];
|
||||
info[@"status"] = taskResult[@"status"];
|
||||
|
||||
if (self.isCancelled)
|
||||
return;
|
||||
|
||||
[center postNotificationName:XCCConversionDidGenerateErrorNotification object:self userInfo:info];
|
||||
}
|
||||
}
|
||||
@catch (NSException *exception)
|
||||
{
|
||||
DDLogError(@"%@\n%@", exception.reason, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,12 @@ extern NSString * const XCCProjectDidFinishLoadingNotification;
|
||||
*/
|
||||
@property NSInteger projectId;
|
||||
|
||||
// An array of paths we add to the NSTask environment
|
||||
@property NSArray *environmentPaths;
|
||||
|
||||
// An array of executable names we need to have available
|
||||
@property NSArray *executables;
|
||||
|
||||
// Full path to .XcodeSupport
|
||||
@property NSString *supportPath;
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ static NSPredicate * XCCDirectoriesToIgnorePredicate = nil;
|
||||
// An array of the default predicates used to ignore paths.
|
||||
static NSArray *XCCDefaultIgnoredPathPredicates = nil;
|
||||
|
||||
|
||||
@interface XcodeCapp ()
|
||||
|
||||
// Only used with 10.6 when we don't have file-level FSEvents
|
||||
@@ -175,7 +176,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
@"*/AppKit/",
|
||||
@"*/Foundation/",
|
||||
@"*/Objective-J/",
|
||||
@"*/*.environment/",
|
||||
@"*/*.environment/",
|
||||
@"*/Build/",
|
||||
@"*/*.xcodeproj/",
|
||||
@"*/.*/",
|
||||
@@ -240,11 +241,25 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
// Add possible executable paths to PATH
|
||||
self.environment = [NSProcessInfo processInfo].environment.mutableCopy;
|
||||
|
||||
NSArray *paths = @[@"/usr/local/bin", @"/usr/local/narwhal/bin", @"~/bin".stringByExpandingTildeInPath];
|
||||
self.environmentPaths =
|
||||
@[
|
||||
@"/usr/local/bin",
|
||||
@"/usr/local/narwhal/bin",
|
||||
@"~/narwhal/bin",
|
||||
@"~/bin"
|
||||
];
|
||||
|
||||
NSMutableArray *paths = [self.environmentPaths mutableCopy];
|
||||
|
||||
for (NSInteger i = 0; i < paths.count; ++i)
|
||||
paths[i] = [paths[i] stringByExpandingTildeInPath];
|
||||
|
||||
self.environment[@"PATH"] = [[paths componentsJoinedByString:@":"] stringByAppendingFormat:@":%@", self.environment[@"PATH"]];
|
||||
|
||||
// Make sure we are using jsc as the narwhal engine!
|
||||
self.environment[@"NARWHAL_ENGINE"] = @"jsc";
|
||||
|
||||
self.executables = @[@"python", @"narwhal-jsc", @"objj", @"nib2cib"];
|
||||
}
|
||||
|
||||
- (void)initObservers
|
||||
@@ -1225,9 +1240,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
|
||||
- (BOOL)executablesAreAccessible
|
||||
{
|
||||
NSArray *executables = [[NSBundle mainBundle] objectForInfoDictionaryKey:XCCMandatoryExecutablesKey];
|
||||
|
||||
for (NSString *executable in executables)
|
||||
for (NSString *executable in self.executables)
|
||||
{
|
||||
NSDictionary *response = [self runTaskWithLaunchPath:@"/usr/bin/which"
|
||||
arguments:@[executable]
|
||||
@@ -1239,7 +1252,7 @@ void fsevents_callback(ConstFSEventStreamRef streamRef,
|
||||
self.executablePaths[executable] = path;
|
||||
else
|
||||
{
|
||||
DDLogError(@"Could not find executable '%@' in PATH", executable);
|
||||
DDLogError(@"Could not find executable '%@' in PATH: %@", executable, self.environment[@"PATH"]);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user