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 import argparse | 6 import argparse |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 | 10 |
11 sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), | 11 sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), |
12 '../../mojo/tools')) | 12 os.pardir, os.pardir, 'mojo', 'tools')) |
13 | 13 |
14 from mopy.android import AndroidShell | 14 from mopy.android import AndroidShell |
15 from mopy.config import Config | 15 from mopy.config import Config |
16 | 16 |
17 USAGE = ("android_run_mandoline.py [<shell-and-app-args>] [<mojo-app>]") | 17 USAGE = ("android_run_mandoline.py [<shell-and-app-args>] [<mojo-app>]") |
18 | 18 |
19 def main(): | 19 def main(): |
20 logging.basicConfig() | 20 logging.basicConfig() |
21 | 21 |
22 parser = argparse.ArgumentParser(usage=USAGE) | 22 parser = argparse.ArgumentParser(usage=USAGE) |
23 | 23 |
24 debug_group = parser.add_mutually_exclusive_group() | 24 debug_group = parser.add_mutually_exclusive_group() |
25 debug_group.add_argument('--debug', help='Debug build (default)', | 25 debug_group.add_argument('--debug', help='Debug build (default)', |
26 default=True, action='store_true') | 26 default=True, action='store_true') |
27 debug_group.add_argument('--release', help='Release build', default=False, | 27 debug_group.add_argument('--release', help='Release build', default=False, |
28 dest='debug', action='store_false') | 28 dest='debug', action='store_false') |
29 parser.add_argument('--target-cpu', help='CPU architecture to run for.', | 29 parser.add_argument('--target-cpu', help='CPU architecture to run for.', |
30 choices=['x64', 'x86', 'arm'], default='arm') | 30 choices=['x64', 'x86', 'arm'], default='arm') |
31 parser.add_argument('--device', help='Serial number of the target device.') | 31 parser.add_argument('--device', help='Serial number of the target device.') |
32 parser.add_argument('--gdb', help='Run gdb', | 32 parser.add_argument('--gdb', help='Run gdb', |
33 default=False, action='store_true') | 33 default=False, action='store_true') |
34 runner_args, args = parser.parse_known_args() | 34 runner_args, args = parser.parse_known_args() |
35 | 35 |
36 config = Config(target_os=Config.OS_ANDROID, | 36 config = Config(target_os=Config.OS_ANDROID, |
37 target_cpu=runner_args.target_cpu, | 37 target_cpu=runner_args.target_cpu, |
38 is_debug=runner_args.debug, | 38 is_debug=runner_args.debug, |
39 apk_name="Mandoline.apk") | 39 apk_name="Mandoline.apk") |
40 shell = AndroidShell(config) | 40 shell = AndroidShell(config) |
41 args.extend(shell.PrepareShellRun(None, runner_args.device, runner_args.gdb)) | 41 shell.InitShell(None, runner_args.device) |
42 | |
43 shell.CleanLogs() | |
44 p = shell.ShowLogs() | 42 p = shell.ShowLogs() |
45 shell.StartShell(args, sys.stdout, p.terminate, runner_args.gdb) | 43 shell.StartShell(args, sys.stdout, p.terminate, runner_args.gdb) |
46 return 0 | 44 return 0 |
47 | 45 |
48 | 46 |
49 if __name__ == "__main__": | 47 if __name__ == "__main__": |
50 sys.exit(main()) | 48 sys.exit(main()) |
OLD | NEW |