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 parser
.add_argument('--apk', help='Name of the APK to run.',
32 default
='MojoRunner.apk')
33 runner_args
, args
= parser
.parse_known_args()
35 logger
= logging
.getLogger()
36 logging
.basicConfig(stream
=sys
.stdout
, format
='%(levelname)s:%(message)s')
37 logger
.setLevel(logging
.DEBUG
if runner_args
.verbose
else logging
.WARNING
)
38 logger
.debug('Initialized logging: level=%s' % logger
.level
)
40 config
= Config(target_os
=Config
.OS_ANDROID
,
41 target_cpu
=runner_args
.target_cpu
,
42 is_debug
=runner_args
.debug
,
43 apk_name
=runner_args
.apk
)
44 shell
= AndroidShell(config
)
45 shell
.InitShell(runner_args
.origin
, runner_args
.device
)
47 shell
.StartActivity('MojoShellActivity', args
, sys
.stdout
, p
.terminate
)
51 if __name__
== '__main__':