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.
10 from mopy
.android
import AndroidShell
11 from mopy
.config
import Config
13 USAGE
= ('android_mojo_shell.py [<shell-and-app-args>] [<mojo-app>]')
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('--device', help='Serial number of the target device.')
28 parser
.add_argument('--verbose', default
=False, action
='store_true')
29 parser
.add_argument('--apk', help='Name of the APK to run.',
30 default
='MojoRunner.apk')
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 is_verbose
=runner_args
.verbose
,
42 apk_name
=runner_args
.apk
)
43 shell
= AndroidShell(config
)
44 shell
.InitShell(runner_args
.device
)
46 shell
.StartActivity('MojoShellActivity', args
, sys
.stdout
, p
.terminate
)
50 if __name__
== '__main__':