| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import logging | 7 import logging |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 from devtoolslib import paths | |
| 11 from devtoolslib import shell_arguments | 10 from devtoolslib import shell_arguments |
| 11 from devtoolslib import shell_config |
| 12 | 12 |
| 13 _USAGE = ("mojo_run " | 13 _USAGE = ("mojo_run " |
| 14 "[--args-for=<mojo-app>] " | 14 "[--args-for=<mojo-app>] " |
| 15 "[--content-handlers=<handlers>] " | 15 "[--content-handlers=<handlers>] " |
| 16 "[--enable-external-applications] " | 16 "[--enable-external-applications] " |
| 17 "[--disable-cache] " | 17 "[--disable-cache] " |
| 18 "[--enable-multiprocess] " | 18 "[--enable-multiprocess] " |
| 19 "[--wait-for-debugger] " | 19 "[--wait-for-debugger] " |
| 20 "[--sky <mojo-app>|<mojo-app>] " | 20 "[--sky <mojo-app>|<mojo-app>] " |
| 21 """ | 21 """ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 run with the debugger. | 48 run with the debugger. |
| 49 """ | 49 """ |
| 50 shell.ForwardHostPortToShell(_MOJO_DEBUGGER_PORT) | 50 shell.ForwardHostPortToShell(_MOJO_DEBUGGER_PORT) |
| 51 return ['mojo:debugger %d' % _MOJO_DEBUGGER_PORT] | 51 return ['mojo:debugger %d' % _MOJO_DEBUGGER_PORT] |
| 52 | 52 |
| 53 | 53 |
| 54 def main(): | 54 def main(): |
| 55 logging.basicConfig() | 55 logging.basicConfig() |
| 56 | 56 |
| 57 parser = argparse.ArgumentParser(usage=_USAGE, description=_DESCRIPTION) | 57 parser = argparse.ArgumentParser(usage=_USAGE, description=_DESCRIPTION) |
| 58 shell_config.add_shell_arguments(parser) |
| 58 | 59 |
| 59 # Arguments allowing to indicate the configuration we are targeting when | |
| 60 # running within a Chromium-like checkout. These will go away once we have | |
| 61 # devtools config files, see https://github.com/domokit/devtools/issues/28. | |
| 62 chromium_config_group = parser.add_argument_group('Chromium configuration', | |
| 63 'These arguments allow to infer paths to tools and build results ' | |
| 64 'when running withing a Chromium-like checkout') | |
| 65 debug_group = chromium_config_group.add_mutually_exclusive_group() | |
| 66 debug_group.add_argument('--debug', help='Debug build (default)', | |
| 67 default=True, action='store_true') | |
| 68 debug_group.add_argument('--release', help='Release build', default=False, | |
| 69 dest='debug', action='store_false') | |
| 70 chromium_config_group.add_argument('--target-cpu', | |
| 71 help='CPU architecture to run for.', | |
| 72 choices=['x64', 'x86', 'arm']) | |
| 73 | |
| 74 shell_arguments.add_shell_arguments(parser) | |
| 75 parser.add_argument('--no-debugger', action="store_true", | 60 parser.add_argument('--no-debugger', action="store_true", |
| 76 help='Do not spawn mojo:debugger.') | 61 help='Do not spawn mojo:debugger.') |
| 77 parser.add_argument('--window-manager', default=_DEFAULT_WINDOW_MANAGER, | 62 parser.add_argument('--window-manager', default=_DEFAULT_WINDOW_MANAGER, |
| 78 help='Window manager app to be mapped as ' | 63 help='Window manager app to be mapped as ' |
| 79 'mojo:window_manager. By default it is ' + | 64 'mojo:window_manager. By default it is ' + |
| 80 _DEFAULT_WINDOW_MANAGER) | 65 _DEFAULT_WINDOW_MANAGER) |
| 81 | 66 |
| 82 script_args, shell_args = parser.parse_known_args() | 67 script_args, shell_args = parser.parse_known_args() |
| 83 | 68 config = shell_config.get_shell_config(script_args) |
| 84 # Infer paths based on the config if running within a Chromium-like checkout. | |
| 85 mojo_paths, _ = paths.infer_mojo_paths(script_args.android, | |
| 86 script_args.debug, | |
| 87 script_args.target_cpu) | |
| 88 if mojo_paths: | |
| 89 if script_args.android and not script_args.adb_path: | |
| 90 script_args.adb_path = mojo_paths['adb'] | |
| 91 if script_args.android and not script_args.origin: | |
| 92 script_args.origin = mojo_paths['build'] | |
| 93 if not script_args.shell_path: | |
| 94 script_args.shell_path = mojo_paths['shell'] | |
| 95 | |
| 96 if script_args.verbose: | |
| 97 print 'Running within a Chromium-style checkout.' | |
| 98 print ' - using the locally built shell at: ' + script_args.shell_path | |
| 99 if script_args.origin: | |
| 100 print ' - using the origin: ' + script_args.origin | |
| 101 if script_args.android: | |
| 102 print ' - using the adb path: ' + script_args.adb_path | |
| 103 elif script_args.verbose: | |
| 104 print 'Running outside a Chromium-style checkout.' | |
| 105 | 69 |
| 106 try: | 70 try: |
| 107 shell, shell_args = shell_arguments.configure_shell(script_args, shell_args) | 71 shell, shell_args = shell_arguments.get_shell(config, shell_args) |
| 108 except shell_arguments.ShellConfigurationException as e: | 72 except shell_arguments.ShellConfigurationException as e: |
| 109 print e | 73 print e |
| 110 return 1 | 74 return 1 |
| 111 | 75 |
| 112 if not script_args.no_debugger: | 76 if not script_args.no_debugger: |
| 113 if script_args.verbose: | 77 if script_args.verbose: |
| 114 print 'Spawning mojo:debugger, use `mojo_debug` to inspect the shell.' | 78 print 'Spawning mojo:debugger, use `mojo_debug` to inspect the shell.' |
| 115 print 'Note that mojo:debugger will prevent the shell from terminating,' | 79 print 'Note that mojo:debugger will prevent the shell from terminating,' |
| 116 print ' pass --no-debugger to skip spawning mojo:debugger.' | 80 print ' pass --no-debugger to skip spawning mojo:debugger.' |
| 117 shell_args.extend(_configure_debugger(shell)) | 81 shell_args.extend(_configure_debugger(shell)) |
| 118 | 82 |
| 119 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=', | 83 shell_args = shell_arguments.append_to_argument(shell_args, '--url-mappings=', |
| 120 'mojo:window_manager=%s' % | 84 'mojo:window_manager=%s' % |
| 121 script_args.window_manager) | 85 script_args.window_manager) |
| 122 | 86 |
| 123 if script_args.verbose: | 87 if script_args.verbose: |
| 124 print "Shell arguments: " + str(shell_args) | 88 print "Shell arguments: " + str(shell_args) |
| 125 | 89 |
| 126 shell.Run(shell_args) | 90 shell.Run(shell_args) |
| 127 return 0 | 91 return 0 |
| 128 | 92 |
| 129 | 93 |
| 130 if __name__ == "__main__": | 94 if __name__ == "__main__": |
| 131 sys.exit(main()) | 95 sys.exit(main()) |
| OLD | NEW |