Extension syncing: Introduce a NeedsSync pref
[chromium-blink-merge.git] / mojo / tools / android_mojo_shell.py
blobcf80f02f12906266a346733be21c45cf555f7611
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
6 import argparse
7 import logging
8 import sys
10 from mopy.android import AndroidShell
11 from mopy.config import Config
13 USAGE = ('android_mojo_shell.py [<shell-and-app-args>] [<mojo-app>]')
15 def main():
16 logging.basicConfig()
18 parser = argparse.ArgumentParser(usage=USAGE)
20 debug_group = parser.add_mutually_exclusive_group()
21 debug_group.add_argument('--debug', help='Debug build (default)',
22 default=True, action='store_true')
23 debug_group.add_argument('--release', help='Release build', default=False,
24 dest='debug', action='store_false')
25 parser.add_argument('--target-cpu', help='CPU architecture to run for.',
26 choices=['x64', 'x86', 'arm'], default='arm')
27 parser.add_argument('--origin', help='Origin for mojo: URLs.',
28 default='localhost')
29 parser.add_argument('--device', help='Serial number of the target device.')
30 parser.add_argument('--verbose', default=False, action='store_true')
31 runner_args, args = parser.parse_known_args()
33 logger = logging.getLogger()
34 logging.basicConfig(stream=sys.stdout, format='%(levelname)s:%(message)s')
35 logger.setLevel(logging.DEBUG if runner_args.verbose else logging.WARNING)
36 logger.debug('Initialized logging: level=%s' % logger.level)
38 config = Config(target_os=Config.OS_ANDROID,
39 target_cpu=runner_args.target_cpu,
40 is_debug=runner_args.debug,
41 apk_name='MojoRunner.apk')
42 shell = AndroidShell(config)
43 shell.InitShell(runner_args.origin, runner_args.device)
44 p = shell.ShowLogs()
45 shell.StartActivity('MojoShellActivity', args, sys.stdout, p.terminate)
46 return 0
49 if __name__ == '__main__':
50 sys.exit(main())