Chromium Code Reviews| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 sky_server = self._sky_server_for_args(args) |
| 142 pids['sky_server_pid'] = sky_server.start() | 142 pids['sky_server_pid'] = sky_server.start() |
| 143 pids['sky_server_port'] = sky_server.port | 143 pids['sky_server_port'] = sky_server.port |
| 144 pids['sky_server_root'] = sky_server.root | 144 pids['sky_server_root'] = sky_server.root |
| 145 | 145 |
| 146 pids['build_dir'] = args.build_dir | 146 pids['build_dir'] = os.path.abspath(args.build_dir) |
| 147 | 147 |
| 148 subprocess.check_call([ADB_PATH, 'install', '-r', apk_path]) | 148 subprocess.check_call([ADB_PATH, 'install', '-r', apk_path]) |
| 149 | 149 |
| 150 port_string = 'tcp:%s' % sky_server.port | 150 port_string = 'tcp:%s' % sky_server.port |
| 151 subprocess.check_call([ | 151 subprocess.check_call([ |
| 152 ADB_PATH, 'reverse', port_string, port_string | 152 ADB_PATH, 'reverse', port_string, port_string |
| 153 ]) | 153 ]) |
| 154 pids['remote_sky_server_port'] = sky_server.port | 154 pids['remote_sky_server_port'] = sky_server.port |
| 155 | 155 |
| 156 subprocess.check_call([ADB_PATH, 'shell', | 156 subprocess.check_call([ADB_PATH, 'shell', |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 182 if 'remote_sky_server_port' in self.pids: | 182 if 'remote_sky_server_port' in self.pids: |
| 183 port_string = 'tcp:%s' % self.pids['remote_sky_server_port'] | 183 port_string = 'tcp:%s' % self.pids['remote_sky_server_port'] |
| 184 subprocess.call([ADB_PATH, 'reverse', '--remove', port_string]) | 184 subprocess.call([ADB_PATH, 'reverse', '--remove', port_string]) |
| 185 | 185 |
| 186 subprocess.call([ | 186 subprocess.call([ |
| 187 ADB_PATH, 'shell', 'am', 'force-stop', ANDROID_PACKAGE]) | 187 ADB_PATH, 'shell', 'am', 'force-stop', ANDROID_PACKAGE]) |
| 188 | 188 |
| 189 pids.clear() | 189 pids.clear() |
| 190 | 190 |
| 191 | 191 |
| 192 class Analyze(object): | |
| 193 def add_subparser(self, subparsers): | |
| 194 analyze_parser = subparsers.add_parser('analyze', | |
| 195 help=('run the dart analyzer with sky url mappings')) | |
| 196 analyze_parser.add_argument('app_path', type=str) | |
| 197 analyze_parser.set_defaults(func=self.run) | |
| 198 | |
| 199 def run(self, args, pids): | |
| 200 ANALYZER_PATH = 'third_party/dart-sdk/dart-sdk/bin/dartanalyzer' | |
| 201 | |
| 202 build_dir = os.path.abspath(pids['build_dir']) | |
| 203 bindings_path = os.path.join(build_dir, 'gen/sky/bindings') | |
| 204 sky_builtin_path = \ | |
| 205 os.path.join(SRC_ROOT, 'sky/engine/bindings/builtin.dart') | |
| 206 sky_core_path = os.path.join(bindings_path, 'sky_core.dart') | |
| 207 mojo_bindings_path = \ | |
| 208 os.path.join(SRC_ROOT, 'mojo/public/dart/bindings.dart') | |
| 209 mojo_core_path = os.path.join(SRC_ROOT, 'mojo/public/dart/core.dart') | |
| 210 analyzer_args = [ANALYZER_PATH, | |
| 211 # sky_core.dart does not compile cleanly yet. :( | |
| 212 # "--url-mapping=dart:sky,%s" % sky_core_path, | |
| 213 "--url-mapping=dart:sky_builtin,%s" % sky_builtin_path, | |
| 214 "--url-mapping=mojo:bindings,%s" % mojo_bindings_path, | |
| 215 "--url-mapping=mojo:core,%s" % mojo_core_path, | |
| 216 args.app_path | |
| 217 ] | |
| 218 print " ".join(analyzer_args) | |
|
abarth-chromium
2015/03/05 19:28:06
Remove?
| |
| 219 subprocess.call(analyzer_args) | |
| 220 | |
| 221 | |
| 192 class SkyShellRunner(object): | 222 class SkyShellRunner(object): |
| 193 def main(self): | 223 def main(self): |
| 194 logging.basicConfig(level=logging.WARNING) | 224 logging.basicConfig(level=logging.WARNING) |
| 195 | 225 |
| 196 parser = argparse.ArgumentParser(description='Sky Shell Runner') | 226 parser = argparse.ArgumentParser(description='Sky Shell Runner') |
| 197 subparsers = parser.add_subparsers(help='sub-command help') | 227 subparsers = parser.add_subparsers(help='sub-command help') |
| 198 | 228 |
| 199 for command in [StartSky(), StopSky()]: | 229 for command in [StartSky(), StopSky(), Analyze()]: |
| 200 command.add_subparser(subparsers) | 230 command.add_subparser(subparsers) |
| 201 | 231 |
| 202 args = parser.parse_args() | 232 args = parser.parse_args() |
| 203 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) | 233 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) |
| 204 exit_code = args.func(args, pids) | 234 exit_code = args.func(args, pids) |
| 205 # We could do this with an at-exit handler instead? | 235 # We could do this with an at-exit handler instead? |
| 206 pids.write_to(PID_FILE_PATH) | 236 pids.write_to(PID_FILE_PATH) |
| 207 sys.exit(exit_code) | 237 sys.exit(exit_code) |
| 208 | 238 |
| 209 | 239 |
| 210 if __name__ == '__main__': | 240 if __name__ == '__main__': |
| 211 SkyShellRunner().main() | 241 SkyShellRunner().main() |
| OLD | NEW |