Add ianwen to watch list for related projects
[chromium-blink-merge.git] / mandoline / tools / android / run_mandoline.py
blob78a3d90527e442b116887ec80435b52aca4a4e2b
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 os
9 import sys
11 sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)),
12 os.pardir, os.pardir, os.pardir, 'mojo',
13 'tools'))
15 from mopy.android import AndroidShell
16 from mopy.config import Config
18 USAGE = ("run_mandoline.py [<shell-and-app-args>] [<start-page-url>]")
20 def main():
21 logging.basicConfig()
23 parser = argparse.ArgumentParser(usage=USAGE)
25 debug_group = parser.add_mutually_exclusive_group()
26 debug_group.add_argument('--debug', help='Debug build (default)',
27 default=True, action='store_true')
28 debug_group.add_argument('--release', help='Release build', default=False,
29 dest='debug', action='store_false')
30 parser.add_argument('--target-cpu', help='CPU architecture to run for.',
31 choices=['x64', 'x86', 'arm'], default='arm')
32 parser.add_argument('--device', help='Serial number of the target device.')
33 parser.add_argument('--gdb', help='Run gdb',
34 default=False, action='store_true')
35 runner_args, args = parser.parse_known_args()
37 config = Config(target_os=Config.OS_ANDROID,
38 target_cpu=runner_args.target_cpu,
39 is_debug=runner_args.debug,
40 apk_name="Mandoline.apk")
41 shell = AndroidShell(config)
42 shell.InitShell(None, runner_args.device)
43 p = shell.ShowLogs()
44 shell.StartActivity('MandolineActivity',
45 args,
46 sys.stdout,
47 p.terminate,
48 runner_args.gdb)
49 return 0
52 if __name__ == "__main__":
53 sys.exit(main())