From fec985a126cce0743096949e88611ab84ae4eddb Mon Sep 17 00:00:00 2001 From: Laurent Sansonetti Date: Thu, 11 Sep 2014 16:17:16 +0200 Subject: [PATCH] =?UTF-8?q?launch=20the=20REPL=20upon=20=E2=80=9Crake=20de?= =?UTF-8?q?vice=E2=80=9D=20(or=20=E2=80=9Crake=20emulator=E2=80=9D=20?= =?UTF-8?q?=E2=80=94=20haven=E2=80=99t=20tried=20that=20one=20thought)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/motion/project/template/android.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/motion/project/template/android.rb b/lib/motion/project/template/android.rb index b6062e68..5ef40873 100644 --- a/lib/motion/project/template/android.rb +++ b/lib/motion/project/template/android.rb @@ -457,15 +457,13 @@ def run_apk(mode) line = "\"#{adb_path}\" #{adb_mode_flag(mode)} shell am start -a android.intent.action.MAIN -n #{activity_path}" line << " > /dev/null" unless Rake.application.options.trace sh line - Signal.trap('INT') do - # Kill the app on ^C. - if `\"#{adb_path}\" -d shell ps`.include?(App.config.package) - sh "\"#{adb_path}\" #{adb_mode_flag(mode)} shell am force-stop #{App.config.package}" - end - exit 0 - end - # Show logs. - sh "\"#{adb_path}\" #{adb_mode_flag(mode)} logcat -s #{App.config.logs_components.join(' ')}" + # Show logs in a child process. + adb_logs_pid = spawn "\"#{adb_path}\" #{adb_mode_flag(mode)} logcat -s #{App.config.logs_components.join(' ')}" + at_exit { Process.kill('KILL', adb_logs_pid) } + # Enable port forwarding for the REPL socket. + sh "\"#{adb_path}\" #{adb_mode_flag(mode)} forward tcp:33333 tcp:33333" + # Launch the REPL. + sh "\"#{App.config.bin_exec('android/repl')}\" 0.0.0.0 33333" end end