From 3e075d47c54d9bf18eacfa0ca58a628174cb1beb Mon Sep 17 00:00:00 2001 From: Watson Date: Tue, 28 May 2013 09:29:14 +0900 Subject: [PATCH] add a feature which passing the arguments on launching app --- bin/sim.m | 8 +++++--- lib/motion/project/config.rb | 2 +- lib/motion/project/template/ios.rb | 3 ++- lib/motion/project/template/osx.rb | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/sim.m b/bin/sim.m index ed519ae5..02fa4220 100644 --- a/bin/sim.m +++ b/bin/sim.m @@ -1003,9 +1003,9 @@ main(int argc, char **argv) [[NSAutoreleasePool alloc] init]; #if defined(SIMULATOR_IOS) - if (argc != 6) { + if (argc != 7) { #else - if (argc != 4) { + if (argc != 5) { #endif usage(); } @@ -1023,6 +1023,7 @@ main(int argc, char **argv) NSString *app_path = [NSString stringWithUTF8String:realpath(argv[argv_n++], NULL)]; + NSArray *app_args = [[NSString stringWithUTF8String:argv[argv_n++]] componentsSeparatedByString:@" "]; #if defined(SIMULATOR_IOS) // Load the framework. @@ -1107,7 +1108,7 @@ main(int argc, char **argv) ((void (*)(id, SEL, id))objc_msgSend)(config, @selector(setApplicationToSimulateOnStart:), app_spec); ((void (*)(id, SEL, id))objc_msgSend)(config, - @selector(setSimulatedApplicationLaunchArgs:), [NSArray array]); + @selector(setSimulatedApplicationLaunchArgs:), app_args); ((void (*)(id, SEL, id))objc_msgSend)(config, @selector(setSimulatedApplicationLaunchEnvironment:), appEnvironment); @@ -1195,6 +1196,7 @@ main(int argc, char **argv) osx_task = [[NSTask alloc] init]; [osx_task setEnvironment:appEnvironment]; [osx_task setLaunchPath:app_path]; + [osx_task setArguments:app_args]; [osx_task launch]; // move to the foreground. diff --git a/lib/motion/project/config.rb b/lib/motion/project/config.rb index f49de294..f8c99d17 100644 --- a/lib/motion/project/config.rb +++ b/lib/motion/project/config.rb @@ -47,7 +47,7 @@ module Motion; module Project end end - variable :name, :files, :build_dir, :specs_dir, :version, :motiondir + variable :name, :files, :build_dir, :specs_dir, :version, :motiondir, :arguments_passed_on_launch # Internal only. attr_accessor :build_mode, :spec_mode, :distribution_mode, :dependencies, diff --git a/lib/motion/project/template/ios.rb b/lib/motion/project/template/ios.rb index a39a779a..5399b914 100644 --- a/lib/motion/project/template/ios.rb +++ b/lib/motion/project/template/ios.rb @@ -88,9 +88,10 @@ task :simulator => ['build:simulator'] do env << ' SIM_SPEC_MODE=1' if App.config.spec_mode sim = File.join(App.config.bindir, 'ios/sim') debug = (ENV['debug'] ? 1 : (App.config.spec_mode ? '0' : '2')) + app_args = App.config.arguments_passed_on_launch || "" App.info 'Simulate', app at_exit { system("stty echo") } if $stdout.tty? # Just in case the simulator launcher crashes and leaves the terminal without echo. - sh "#{env} #{sim} #{debug} #{family_int} #{target} \"#{xcode}\" \"#{app}\"" + sh "#{env} #{sim} #{debug} #{family_int} #{target} \"#{xcode}\" \"#{app}\" \"#{app_args}\"" end desc "Create an .ipa archive" diff --git a/lib/motion/project/template/osx.rb b/lib/motion/project/template/osx.rb index 23b328b9..ca42a80f 100644 --- a/lib/motion/project/template/osx.rb +++ b/lib/motion/project/template/osx.rb @@ -54,9 +54,10 @@ task :run => 'build:development' do sim = File.join(App.config.bindir, 'osx/sim') debug = (ENV['debug'] ? 1 : (App.config.spec_mode ? '0' : '2')) target = App.config.sdk_version + app_args = App.config.arguments_passed_on_launch || "" App.info 'Run', exec at_exit { system("stty echo") } if $stdout.tty? # Just in case the process crashes and leaves the terminal without echo. - sh "#{env} #{sim} #{debug} #{target} \"#{exec}\"" + sh "#{env} #{sim} #{debug} #{target} \"#{exec}\" \"#{app_args}\"" end desc "Run the test/spec suite"