| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 from skypy.skyserver import SkyServer | 6 from skypy.skyserver import SkyServer |
| 7 import argparse | 7 import argparse |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 pm_command = [ADB_PATH, 'shell', 'pm', 'path', package] | 168 pm_command = [ADB_PATH, 'shell', 'pm', 'path', package] |
| 169 pm_output = subprocess.check_output(pm_command) | 169 pm_output = subprocess.check_output(pm_command) |
| 170 # e.g. package:/data/app/org.chromium.mojo.shell-1/base.apk | 170 # e.g. package:/data/app/org.chromium.mojo.shell-1/base.apk |
| 171 return pm_output.split(':')[-1] | 171 return pm_output.split(':')[-1] |
| 172 | 172 |
| 173 def start_command(self, args): | 173 def start_command(self, args): |
| 174 # FIXME: Lame that we use self for a command-specific variable. | 174 # FIXME: Lame that we use self for a command-specific variable. |
| 175 self.paths = self._create_paths_for_build_dir(args.build_dir) | 175 self.paths = self._create_paths_for_build_dir(args.build_dir) |
| 176 self.stop_command(None) # Quit any existing process. | 176 self.stop_command(None) # Quit any existing process. |
| 177 | 177 |
| 178 if not os.path.exists(self.paths.mojo_shell_path): | |
| 179 print "mojo_shell not found in build_dir '%s'" % args.build_dir | |
| 180 print "Are you sure you sure that's a valid build_dir location?" | |
| 181 print "See skydb start --help for more info" | |
| 182 sys.exit(2) | |
| 183 | |
| 184 # FIXME: This is probably not the right way to compute is_android | 178 # FIXME: This is probably not the right way to compute is_android |
| 185 # from the build directory? | 179 # from the build directory? |
| 186 gn_args = gn_args_from_build_dir(self.paths.build_dir) | 180 gn_args = gn_args_from_build_dir(self.paths.build_dir) |
| 187 is_android = 'android_sdk_version' in gn_args | 181 is_android = 'android_sdk_version' in gn_args |
| 188 | 182 |
| 183 shell_found = True |
| 184 if is_android: |
| 185 apk_path = os.path.join(self.paths.build_dir, 'apks', ANDROID_APK_NA
ME) |
| 186 if not os.path.exists(apk_path): |
| 187 print "%s not found in build_dir '%s'" % \ |
| 188 (ANDROID_APK_NAME, os.path.join(args.build_dir, 'apks')) |
| 189 shell_found = False |
| 190 elif not os.path.exists(self.paths.mojo_shell_path): |
| 191 print "mojo_shell not found in build_dir '%s'" % args.build_dir |
| 192 shell_found = False |
| 193 |
| 194 if not shell_found: |
| 195 print "Are you sure you sure that's a valid build_dir location?" |
| 196 print "See skydb start --help for more info" |
| 197 sys.exit(2) |
| 198 |
| 189 if is_android and args.gdb and not 'is_debug' in gn_args: | 199 if is_android and args.gdb and not 'is_debug' in gn_args: |
| 190 # FIXME: We don't include gdbserver in the release APK... | 200 # FIXME: We don't include gdbserver in the release APK... |
| 191 print "Cannot debug Release builds on Android" | 201 print "Cannot debug Release builds on Android" |
| 192 sys.exit(2) | 202 sys.exit(2) |
| 193 | 203 |
| 194 sdk_root = os.path.join(self.paths.build_dir, 'gen', 'sky_sdk') | 204 sdk_root = os.path.join(self.paths.build_dir, 'gen', 'sky_sdk') |
| 195 packages_root = os.path.join(sdk_root, 'packages_root') | 205 packages_root = os.path.join(sdk_root, 'packages_root') |
| 196 subprocess.check_call([ | 206 subprocess.check_call([ |
| 197 os.path.join(self.paths.sky_tools_directory, 'deploy_sdk.py'), | 207 os.path.join(self.paths.sky_tools_directory, 'deploy_sdk.py'), |
| 198 '--build-dir', self.paths.build_dir, | 208 '--build-dir', self.paths.build_dir, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 209 | 219 |
| 210 self.pids['build_dir'] = self.paths.build_dir | 220 self.pids['build_dir'] = self.paths.build_dir |
| 211 self.pids['sky_command_port'] = args.command_port | 221 self.pids['sky_command_port'] = args.command_port |
| 212 | 222 |
| 213 if is_android: | 223 if is_android: |
| 214 # TODO(eseidel): This should move into a helper method and handle | 224 # TODO(eseidel): This should move into a helper method and handle |
| 215 # failures with nice messages explaining how to get root. | 225 # failures with nice messages explaining how to get root. |
| 216 subprocess.check_call([ADB_PATH, 'root']) | 226 subprocess.check_call([ADB_PATH, 'root']) |
| 217 | 227 |
| 218 # We could make installing conditional on an argument. | 228 # We could make installing conditional on an argument. |
| 219 apk_path = os.path.join(self.paths.build_dir, 'apks', | |
| 220 ANDROID_APK_NAME) | |
| 221 subprocess.check_call([ADB_PATH, 'install', '-r', apk_path]) | 229 subprocess.check_call([ADB_PATH, 'install', '-r', apk_path]) |
| 222 | 230 |
| 223 port_string = 'tcp:%s' % sky_server.port | 231 port_string = 'tcp:%s' % sky_server.port |
| 224 subprocess.check_call([ | 232 subprocess.check_call([ |
| 225 ADB_PATH, 'reverse', port_string, port_string | 233 ADB_PATH, 'reverse', port_string, port_string |
| 226 ]) | 234 ]) |
| 227 self.pids['remote_sky_server_port'] = sky_server.port | 235 self.pids['remote_sky_server_port'] = sky_server.port |
| 228 | 236 |
| 229 port_string = 'tcp:%s' % args.command_port | 237 port_string = 'tcp:%s' % args.command_port |
| 230 subprocess.check_call([ | 238 subprocess.check_call([ |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 load_parser.set_defaults(func=self.load_command) | 624 load_parser.set_defaults(func=self.load_command) |
| 617 | 625 |
| 618 args = parser.parse_args() | 626 args = parser.parse_args() |
| 619 args.func(args) | 627 args.func(args) |
| 620 | 628 |
| 621 self._write_pid_file(PID_FILE_PATH, self.pids) | 629 self._write_pid_file(PID_FILE_PATH, self.pids) |
| 622 | 630 |
| 623 | 631 |
| 624 if __name__ == '__main__': | 632 if __name__ == '__main__': |
| 625 SkyDebugger().main() | 633 SkyDebugger().main() |
| OLD | NEW |