add a feature which passing the arguments on launching app

This commit is contained in:
Watson
2013-05-28 09:29:14 +09:00
parent c29b494de2
commit 3e075d47c5
4 changed files with 10 additions and 6 deletions

View File

@@ -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.

View File

@@ -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,

View File

@@ -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"

View File

@@ -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"