Making rake install almost work

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-09-10 13:23:13 -07:00
parent 85c37fd652
commit 6570aedbb0
5 changed files with 77 additions and 27 deletions

View File

@@ -8,6 +8,7 @@ class AtomCefClient;
BOOL handlingSendEvent_;
}
+ (NSMutableDictionary *)arguments;
+ (id)applicationWithArguments:(char **)argv count:(int)argc;
+ (CefSettings)createCefSettings;
- (void)open:(NSString *)path;

View File

@@ -3,13 +3,68 @@
#import "native/atom_application.h"
#import "native/atom_window_controller.h"
#import "native/atom_cef_app.h"
#import <getopt.h>
@implementation AtomApplication
static NSMutableDictionary *sArguments;
+ (NSMutableDictionary *)arguments {
if (!sArguments) {
sArguments = [[NSMutableDictionary alloc] init];
// Defaults
#ifdef RESOURCE_PATH
[sArguments setObject:[NSString stringWithUTF8String:RESOURCE_PATH] forKey:@"resource-path"];
#endif
}
return sArguments;
}
+ (void)parseArguments:(char **)argv count:(int)argc {
int opt;
int longindex;
if (argc > 2 && strcmp(argv[argc - 2], "-NSDocumentRevisionsDebugMode") == 0) { // Because Xcode inserts useless command-line args by default: http://trac.wxwidgets.org/ticket/13732
argc -= 2; // Ignore last two arguments
}
static struct option longopts[] = {
{ "resource-path", optional_argument, NULL, 'r' },
{ "benchmark", optional_argument, NULL, 'b' },
{ "test", optional_argument, NULL, 't' },
{ NULL, 0, NULL, 0 }
};
while ((opt = getopt_long(argc, argv, "r:bth?", longopts, &longindex)) != -1) {
switch (opt) {
case 'r':
[[self arguments] setObject:[NSString stringWithUTF8String:optarg] forKey:@"resource-path"];
break;
case 'b':
[[self arguments] setObject:[NSNumber numberWithBool:YES] forKey:@"benchmark"];
break;
case 't':
[[self arguments] setObject:[NSNumber numberWithBool:YES] forKey:@"test"];
break;
default:
printf("usage: atom [--resource-path=<path>] [<path>]");
}
}
argc -= optind;
argv += optind;
if (argc > 0) {
[[self arguments] setObject:[NSString stringWithUTF8String:argv[0]] forKey:@"path"];
}
}
+ (id)applicationWithArguments:(char **)argv count:(int)argc {
NSApplication *application = [super sharedApplication];
CefInitialize(CefMainArgs(argc, argv), [self createCefSettings], new AtomCefApp);
[self parseArguments:argv count:argc];
return application;
}
@@ -47,6 +102,7 @@
}
- (void)open:(NSString *)path {
NSLog(@"%@", path);
[[AtomWindowController alloc] initWithPath:path];
}
@@ -71,13 +127,15 @@
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
_backgroundWindowController = [[AtomWindowController alloc] initInBackground];
NSArray *processArguments = [[NSProcessInfo processInfo] arguments];
if ([processArguments containsObject:@"--benchmark"]) {
if ([[AtomApplication arguments] objectForKey:@"benchmark"]) {
[self runBenchmarksThenExit:true];
}
else if ([processArguments containsObject:@"--test"]) {
else if ([[AtomApplication arguments] objectForKey:@"test"]) {
[self runSpecsThenExit:true];
}
else {
[self open:[[AtomApplication arguments] objectForKey:@"path"]];
}
}
- (void)applicationWillTerminate:(NSNotification *)notification {

View File

@@ -2,6 +2,7 @@
#include "include/cef_client.h"
#import "native/atom_cef_client.h"
#import "native/atom_window_controller.h"
#import "native/atom_application.h"
@implementation AtomWindowController
@@ -23,13 +24,10 @@
self = [super initWithWindowNibName:@"AtomWindow"];
_bootstrapScript = [bootstrapScript retain];
#ifdef RESOURCE_PATH
_resourcePath = [[NSString alloc] initWithUTF8String:RESOURCE_PATH];
#else
_resourcePath = [[[NSBundle mainBundle] resourcePath] retain];
#endif
_resourcePath = [[[AtomApplication arguments] objectForKey:@"resource-path"] retain];
if (!_resourcePath) _resourcePath = [[[NSBundle mainBundle] resourcePath] retain];
if (!background) {
[self showWindow:self];
}