| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 path = os.path.abspath(url_or_path) | 117 path = os.path.abspath(url_or_path) |
| 118 if os.path.commonprefix([path, SRC_ROOT]) == SRC_ROOT: | 118 if os.path.commonprefix([path, SRC_ROOT]) == SRC_ROOT: |
| 119 server_root = SRC_ROOT | 119 server_root = SRC_ROOT |
| 120 else: | 120 else: |
| 121 server_root = os.path.dirname(path) | 121 server_root = os.path.dirname(path) |
| 122 logging.warn( | 122 logging.warn( |
| 123 '%s is outside of mojo root, using %s as server root' % | 123 '%s is outside of mojo root, using %s as server root' % |
| 124 (path, server_root)) | 124 (path, server_root)) |
| 125 return server_root | 125 return server_root |
| 126 | 126 |
| 127 def _sky_server_for_args(self, args): | 127 def _sky_server_for_args(self, args, packages_root): |
| 128 # FIXME: This is a hack. sky_server should just take a build_dir | 128 # FIXME: This is a hack. sky_server should just take a build_dir |
| 129 # not a magical "configuration" name. | 129 # not a magical "configuration" name. |
| 130 configuration = os.path.basename(os.path.normpath(args.build_dir)) | 130 configuration = os.path.basename(os.path.normpath(args.build_dir)) |
| 131 server_root = self._server_root_for_url(args.url_or_path) | 131 server_root = self._server_root_for_url(args.url_or_path) |
| 132 sky_server = SkyServer(SKY_SERVER_PORT, configuration, server_root) | 132 sky_server = SkyServer(SKY_SERVER_PORT, configuration, server_root, pack
ages_root) |
| 133 return sky_server | 133 return sky_server |
| 134 | 134 |
| 135 def run(self, args, pids): | 135 def run(self, args, pids): |
| 136 apk_path = os.path.join(args.build_dir, 'apks', APK_NAME) | 136 apk_path = os.path.join(args.build_dir, 'apks', APK_NAME) |
| 137 if not os.path.exists(apk_path): | 137 if not os.path.exists(apk_path): |
| 138 print "'%s' does not exist?" % apk_path | 138 print "'%s' does not exist?" % apk_path |
| 139 return 2 | 139 return 2 |
| 140 | 140 |
| 141 sky_server = self._sky_server_for_args(args) | 141 sdk_root = os.path.join(args.build_dir, 'gen', 'sky_sdk') |
| 142 packages_root = os.path.join(sdk_root, 'packages_root') |
| 143 sky_tools_directory = os.path.join(SRC_ROOT, 'sky/tools') |
| 144 subprocess.check_call([ |
| 145 os.path.join(sky_tools_directory, 'deploy_sdk.py'), |
| 146 '--build-dir', args.build_dir, |
| 147 '--non-interactive', |
| 148 '--dev-environment', |
| 149 '--fake-pub-get-into', packages_root, |
| 150 sdk_root, |
| 151 ]) |
| 152 |
| 153 sky_server = self._sky_server_for_args(args, packages_root) |
| 142 pids['sky_server_pid'] = sky_server.start() | 154 pids['sky_server_pid'] = sky_server.start() |
| 143 pids['sky_server_port'] = sky_server.port | 155 pids['sky_server_port'] = sky_server.port |
| 144 pids['sky_server_root'] = sky_server.root | 156 pids['sky_server_root'] = sky_server.root |
| 145 | 157 |
| 146 pids['build_dir'] = os.path.abspath(args.build_dir) | 158 pids['build_dir'] = os.path.abspath(args.build_dir) |
| 147 | 159 |
| 148 subprocess.check_call([ADB_PATH, 'install', '-r', apk_path]) | 160 subprocess.check_call([ADB_PATH, 'install', '-r', apk_path]) |
| 149 | 161 |
| 150 port_string = 'tcp:%s' % sky_server.port | 162 port_string = 'tcp:%s' % sky_server.port |
| 151 subprocess.check_call([ | 163 subprocess.check_call([ |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 args = parser.parse_args() | 242 args = parser.parse_args() |
| 231 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) | 243 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) |
| 232 exit_code = args.func(args, pids) | 244 exit_code = args.func(args, pids) |
| 233 # We could do this with an at-exit handler instead? | 245 # We could do this with an at-exit handler instead? |
| 234 pids.write_to(PID_FILE_PATH) | 246 pids.write_to(PID_FILE_PATH) |
| 235 sys.exit(exit_code) | 247 sys.exit(exit_code) |
| 236 | 248 |
| 237 | 249 |
| 238 if __name__ == '__main__': | 250 if __name__ == '__main__': |
| 239 SkyShellRunner().main() | 251 SkyShellRunner().main() |
| OLD | NEW |