Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / mojo / tools / android_mojo_shell.py
blobd731afe9ef7b41a7521e3bb8ca7901879d586484
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.config import Config
11 from mopy import android
13 USAGE = ("android_mojo_shell.py "
14 "[--args-for=<mojo-app>] "
15 "[--content-handlers=<handlers>] "
16 "[--enable-external-applications] "
17 "[--disable-cache] "
18 "[--enable-multiprocess] "
19 "[--url-mappings=from1=to1,from2=to2] "
20 "[<mojo-app>] "
21 """
23 A <mojo-app> is a Mojo URL or a Mojo URL and arguments within quotes.
24 Example: mojo_shell "mojo:js_standalone test.js".
25 <url-lib-path> is searched for shared libraries named by mojo URLs.
26 The value of <handlers> is a comma separated list like:
27 text/html,mojo:html_viewer,application/javascript,mojo:js_content_handler
28 """)
31 def main():
32 logging.basicConfig()
34 parser = argparse.ArgumentParser(usage=USAGE)
36 debug_group = parser.add_mutually_exclusive_group()
37 debug_group.add_argument('--debug', help='Debug build (default)',
38 default=True, action='store_true')
39 debug_group.add_argument('--release', help='Release build', default=False,
40 dest='debug', action='store_false')
41 parser.add_argument('--target-cpu', help='CPU architecture to run for.',
42 choices=['x64', 'x86', 'arm'])
43 parser.add_argument('--origin', help='Origin for mojo: URLs.')
44 launcher_args, args = parser.parse_known_args()
46 config = Config(target_os=Config.OS_ANDROID,
47 target_cpu=launcher_args.target_cpu,
48 is_debug=launcher_args.debug)
50 extra_shell_args = android.PrepareShellRun(config, launcher_args.origin)
51 args.extend(extra_shell_args)
53 android.CleanLogs()
54 p = android.ShowLogs()
55 android.StartShell(args, sys.stdout, p.terminate)
56 return 0
59 if __name__ == "__main__":
60 sys.exit(main())