Chromium Code Reviews| 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 if is_android: | |
|
eseidel
2015/04/21 17:18:28
I would have moved this into a helper function and
| |
| 184 apk_path = os.path.join(self.paths.build_dir, 'apks', | |
| 185 ANDROID_APK_NAME) | |
| 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 print "Are you sure you sure that's a valid build_dir location?" | |
| 190 print "See skydb start --help for more info" | |
| 191 sys.exit(2) | |
| 192 elif not os.path.exists(self.paths.mojo_shell_path): | |
| 193 print "mojo_shell not found in build_dir '%s'" % args.build_dir | |
| 194 print "Are you sure you sure that's a valid build_dir location?" | |
| 195 print "See skydb start --help for more info" | |
| 196 sys.exit(2) | |
| 197 | |
| 189 if is_android and args.gdb and not 'is_debug' in gn_args: | 198 if is_android and args.gdb and not 'is_debug' in gn_args: |
| 190 # FIXME: We don't include gdbserver in the release APK... | 199 # FIXME: We don't include gdbserver in the release APK... |
| 191 print "Cannot debug Release builds on Android" | 200 print "Cannot debug Release builds on Android" |
| 192 sys.exit(2) | 201 sys.exit(2) |
| 193 | 202 |
| 194 sdk_root = os.path.join(self.paths.build_dir, 'gen', 'sky_sdk') | 203 sdk_root = os.path.join(self.paths.build_dir, 'gen', 'sky_sdk') |
| 195 packages_root = os.path.join(sdk_root, 'packages_root') | 204 packages_root = os.path.join(sdk_root, 'packages_root') |
| 196 subprocess.check_call([ | 205 subprocess.check_call([ |
| 197 os.path.join(self.paths.sky_tools_directory, 'deploy_sdk.py'), | 206 os.path.join(self.paths.sky_tools_directory, 'deploy_sdk.py'), |
| 198 '--build-dir', self.paths.build_dir, | 207 '--build-dir', self.paths.build_dir, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 209 | 218 |
| 210 self.pids['build_dir'] = self.paths.build_dir | 219 self.pids['build_dir'] = self.paths.build_dir |
| 211 self.pids['sky_command_port'] = args.command_port | 220 self.pids['sky_command_port'] = args.command_port |
| 212 | 221 |
| 213 if is_android: | 222 if is_android: |
| 214 # TODO(eseidel): This should move into a helper method and handle | 223 # TODO(eseidel): This should move into a helper method and handle |
| 215 # failures with nice messages explaining how to get root. | 224 # failures with nice messages explaining how to get root. |
| 216 subprocess.check_call([ADB_PATH, 'root']) | 225 subprocess.check_call([ADB_PATH, 'root']) |
| 217 | 226 |
| 218 # We could make installing conditional on an argument. | 227 # 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]) | 228 subprocess.check_call([ADB_PATH, 'install', '-r', apk_path]) |
| 222 | 229 |
| 223 port_string = 'tcp:%s' % sky_server.port | 230 port_string = 'tcp:%s' % sky_server.port |
| 224 subprocess.check_call([ | 231 subprocess.check_call([ |
| 225 ADB_PATH, 'reverse', port_string, port_string | 232 ADB_PATH, 'reverse', port_string, port_string |
| 226 ]) | 233 ]) |
| 227 self.pids['remote_sky_server_port'] = sky_server.port | 234 self.pids['remote_sky_server_port'] = sky_server.port |
| 228 | 235 |
| 229 port_string = 'tcp:%s' % args.command_port | 236 port_string = 'tcp:%s' % args.command_port |
| 230 subprocess.check_call([ | 237 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) | 623 load_parser.set_defaults(func=self.load_command) |
| 617 | 624 |
| 618 args = parser.parse_args() | 625 args = parser.parse_args() |
| 619 args.func(args) | 626 args.func(args) |
| 620 | 627 |
| 621 self._write_pid_file(PID_FILE_PATH, self.pids) | 628 self._write_pid_file(PID_FILE_PATH, self.pids) |
| 622 | 629 |
| 623 | 630 |
| 624 if __name__ == '__main__': | 631 if __name__ == '__main__': |
| 625 SkyDebugger().main() | 632 SkyDebugger().main() |
| OLD | NEW |