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('--origin', help='Origin for mojo: URLs.',
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
)
45 shell
.StartActivity('MojoShellActivity', args
, sys
.stdout
, p
.terminate
)
49 if __name__
== '__main__':