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

@ -14,7 +14,7 @@ end
desc "Build Atom via `xcodebuild`"
task :build => ["create-project", "verify-prerequisites"] do
command = "xcodebuild -target Atom -configuration Release SYMROOT=#{BUILD_DIR}"
command = "xcodebuild -target Atom -configuration Debug SYMROOT=#{BUILD_DIR}"
output = `#{command}`
if $?.exitstatus != 0
$stderr.puts "Error #{$?.exitstatus}:\n#{output}"
@ -40,10 +40,10 @@ task :package => :build do
end
end
desc "Installs symlink from `application_path() to /Applications directory"
desc "Creates symlink from `application_path() to /Applications/Atom and creates a CLI at /usr/local/bin/atom"
task :install => :build do
if path = application_path()
FileUtils.ln_sf File.expand_path(path), "/Applications/Desktop"
FileUtils.ln_sf File.expand_path(path), "/Applications"
usr_bin = "/usr/local/bin"
usr_bin_exists = ENV["PATH"].split(":").include?(usr_bin)
if usr_bin_exists
@ -90,19 +90,12 @@ task :"copy-files-to-bundle" => :"verify-prerequisites" do
mkdir_p "#{dest}/v8_extensions"
cp Dir.glob("#{project_dir}/native/v8_extensions/*.js"), "#{dest}/v8_extensions/"
if resource_path = ENV['RESOURCE_PATH']
# CoffeeScript can't deal with unescaped whitespace in 'Atom Helper.app' path
escaped_dest = dest.gsub("Atom Helper.app", "Atom\\ Helper.app")
`coffee -c -o \"#{escaped_dest}/src/stdlib\" \"#{resource_path}/src/stdlib/require.coffee\"`
cp_r "#{resource_path}/static", dest
else
# TODO: Restore this list when we add in all of atoms source
%w(src static vendor spec benchmark bundles themes).each do |dir|
dest_path = File.join(dest, dir)
rm_rf dest_path
cp_r dir, dest_path
`coffee -c '#{dest_path}'`
end
%w(src static vendor spec benchmark bundles themes).each do |dir|
dest_path = File.join(dest, dir)
rm_rf dest_path
cp_r dir, dest_path
`coffee -c '#{dest_path}'`
end
end

View File

@ -25,7 +25,7 @@
'configurations': {
'Debug': {
'xcode_config_file': 'native/mac/debug.xcconfig',
'defines': ['RESOURCE_PATH="$RESOURCE_PATH"'],
'defines': ['DEBUG=1', 'RESOURCE_PATH=\"$RESOURCE_PATH\"'],
},
'Release': {
},

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];
}