| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if is_android and args.gdb: | 132 if is_android and args.gdb: |
| 133 shell_args.append('--wait-for-debugger') | 133 shell_args.append('--wait-for-debugger') |
| 134 | 134 |
| 135 if 'remote_sky_server_port' in self.pids: | 135 if 'remote_sky_server_port' in self.pids: |
| 136 shell_command = self._wrap_for_android(shell_args) | 136 shell_command = self._wrap_for_android(shell_args) |
| 137 else: | 137 else: |
| 138 shell_command = [self.paths.mojo_shell_path] + shell_args | 138 shell_command = [self.paths.mojo_shell_path] + shell_args |
| 139 | 139 |
| 140 return shell_command | 140 return shell_command |
| 141 | 141 |
| 142 def sky_server_for_args(self, args): | 142 def sky_server_for_args(self, args, packages_root): |
| 143 # FIXME: This is a hack. sky_server should just take a build_dir | 143 # FIXME: This is a hack. sky_server should just take a build_dir |
| 144 # not a magical "configuration" name. | 144 # not a magical "configuration" name. |
| 145 configuration = os.path.basename(os.path.normpath(self.paths.build_dir)) | 145 configuration = os.path.basename(os.path.normpath(self.paths.build_dir)) |
| 146 server_root = self._server_root_for_url(args.url_or_path) | 146 server_root = self._server_root_for_url(args.url_or_path) |
| 147 sky_server = SkyServer(SKY_SERVER_PORT, configuration, server_root) | 147 return SkyServer(SKY_SERVER_PORT, configuration, server_root, packages_r
oot) |
| 148 return sky_server | |
| 149 | 148 |
| 150 def _create_paths_for_build_dir(self, build_dir): | 149 def _create_paths_for_build_dir(self, build_dir): |
| 151 # skypy.paths.Paths takes a root-relative build_dir argument. :( | 150 # skypy.paths.Paths takes a root-relative build_dir argument. :( |
| 152 abs_build_dir = os.path.abspath(build_dir) | 151 abs_build_dir = os.path.abspath(build_dir) |
| 153 root_relative_build_dir = os.path.relpath(abs_build_dir, SRC_ROOT) | 152 root_relative_build_dir = os.path.relpath(abs_build_dir, SRC_ROOT) |
| 154 return skypy.paths.Paths(root_relative_build_dir) | 153 return skypy.paths.Paths(root_relative_build_dir) |
| 155 | 154 |
| 156 def _find_remote_pid_for_package(self, package): | 155 def _find_remote_pid_for_package(self, package): |
| 157 ps_output = subprocess.check_output([ADB_PATH, 'shell', 'ps']) | 156 ps_output = subprocess.check_output([ADB_PATH, 'shell', 'ps']) |
| 158 for line in ps_output.split('\n'): | 157 for line in ps_output.split('\n'): |
| (...skipping 22 matching lines...) Expand all Loading... |
| 181 # FIXME: This is probably not the right way to compute is_android | 180 # FIXME: This is probably not the right way to compute is_android |
| 182 # from the build directory? | 181 # from the build directory? |
| 183 gn_args = gn_args_from_build_dir(self.paths.build_dir) | 182 gn_args = gn_args_from_build_dir(self.paths.build_dir) |
| 184 is_android = 'android_sdk_version' in gn_args | 183 is_android = 'android_sdk_version' in gn_args |
| 185 | 184 |
| 186 if is_android and args.gdb and not 'is_debug' in gn_args: | 185 if is_android and args.gdb and not 'is_debug' in gn_args: |
| 187 # FIXME: We don't include gdbserver in the release APK... | 186 # FIXME: We don't include gdbserver in the release APK... |
| 188 print "Cannot debug Release builds on Android" | 187 print "Cannot debug Release builds on Android" |
| 189 sys.exit(2) | 188 sys.exit(2) |
| 190 | 189 |
| 191 sky_server = self.sky_server_for_args(args) | 190 sdk_root = os.path.join(self.paths.build_dir, 'gen', 'sky_sdk') |
| 191 packages_root = os.path.join(sdk_root, 'packages_root') |
| 192 subprocess.check_call([ |
| 193 os.path.join(self.paths.sky_tools_directory, 'deploy_sdk.py'), |
| 194 '--build-dir', self.paths.build_dir, |
| 195 '--force', |
| 196 '--dev-environment', |
| 197 '--fake-pub-get-into', packages_root, |
| 198 sdk_root, |
| 199 ]) |
| 200 |
| 201 sky_server = self.sky_server_for_args(args, packages_root) |
| 192 self.pids['sky_server_pid'] = sky_server.start() | 202 self.pids['sky_server_pid'] = sky_server.start() |
| 193 self.pids['sky_server_port'] = sky_server.port | 203 self.pids['sky_server_port'] = sky_server.port |
| 194 self.pids['sky_server_root'] = sky_server.root | 204 self.pids['sky_server_root'] = sky_server.root |
| 195 | 205 |
| 196 self.pids['build_dir'] = self.paths.build_dir | 206 self.pids['build_dir'] = self.paths.build_dir |
| 197 self.pids['sky_command_port'] = args.command_port | 207 self.pids['sky_command_port'] = args.command_port |
| 198 | 208 |
| 199 if is_android: | 209 if is_android: |
| 200 # TODO(eseidel): This should move into a helper method and handle | 210 # TODO(eseidel): This should move into a helper method and handle |
| 201 # failures with nice messages explaining how to get root. | 211 # failures with nice messages explaining how to get root. |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 load_parser.set_defaults(func=self.load_command) | 609 load_parser.set_defaults(func=self.load_command) |
| 600 | 610 |
| 601 args = parser.parse_args() | 611 args = parser.parse_args() |
| 602 args.func(args) | 612 args.func(args) |
| 603 | 613 |
| 604 self._write_pid_file(PID_FILE_PATH, self.pids) | 614 self._write_pid_file(PID_FILE_PATH, self.pids) |
| 605 | 615 |
| 606 | 616 |
| 607 if __name__ == '__main__': | 617 if __name__ == '__main__': |
| 608 SkyDebugger().main() | 618 SkyDebugger().main() |
| OLD | NEW |