| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Configuration for the shell abstraction. | 5 """Configuration for the shell abstraction. |
| 6 | 6 |
| 7 This module declares ShellConfig and knows how to compute it from command-line | 7 This module declares ShellConfig and knows how to compute it from command-line |
| 8 arguments, applying any default paths inferred from the checkout, configuration | 8 arguments, applying any default paths inferred from the checkout, configuration |
| 9 file, etc. | 9 file, etc. |
| 10 """ | 10 """ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 class ShellConfig(object): | 22 class ShellConfig(object): |
| 23 """Configuration for the shell abstraction.""" | 23 """Configuration for the shell abstraction.""" |
| 24 | 24 |
| 25 def __init__(self): | 25 def __init__(self): |
| 26 self.android = None | 26 self.android = None |
| 27 self.shell_path = None | 27 self.shell_path = None |
| 28 self.origin = None | 28 self.origin = None |
| 29 self.map_url_list = [] | 29 self.map_url_list = [] |
| 30 self.map_origin_list = [] | 30 self.map_origin_list = [] |
| 31 self.dev_servers = [] | 31 self.dev_servers = [] |
| 32 self.free_ports = False |
| 32 self.content_handlers = dict() | 33 self.content_handlers = dict() |
| 33 self.verbose = None | 34 self.verbose = None |
| 34 | 35 |
| 35 # Android-only. | 36 # Android-only. |
| 36 self.adb_path = None | 37 self.adb_path = None |
| 37 self.target_device = None | 38 self.target_device = None |
| 38 self.logcat_tags = None | 39 self.logcat_tags = None |
| 39 self.require_root = False | 40 self.require_root = False |
| 40 self.free_host_ports = False | 41 self.free_host_ports = False |
| 41 | 42 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 62 action='store_true') | 63 action='store_true') |
| 63 parser.add_argument('--shell-path', help='Path of the Mojo shell binary.') | 64 parser.add_argument('--shell-path', help='Path of the Mojo shell binary.') |
| 64 parser.add_argument('--origin', help='Origin for mojo: URLs. This can be a ' | 65 parser.add_argument('--origin', help='Origin for mojo: URLs. This can be a ' |
| 65 'web url or a local directory path.') | 66 'web url or a local directory path.') |
| 66 parser.add_argument('--map-url', action='append', | 67 parser.add_argument('--map-url', action='append', |
| 67 help='Define a mapping for a url in the format ' | 68 help='Define a mapping for a url in the format ' |
| 68 '<url>=<url-or-local-file-path>') | 69 '<url>=<url-or-local-file-path>') |
| 69 parser.add_argument('--map-origin', action='append', | 70 parser.add_argument('--map-origin', action='append', |
| 70 help='Define a mapping for a url origin in the format ' | 71 help='Define a mapping for a url origin in the format ' |
| 71 '<origin>=<url-or-local-file-path>') | 72 '<origin>=<url-or-local-file-path>') |
| 73 parser.add_argument('--free-ports', action='store_true', |
| 74 help='Use system-allocated ports when spawning local ' |
| 75 'servers. This defeats caching and thus hurts ' |
| 76 'performance.') |
| 72 parser.add_argument('-v', '--verbose', action="store_true", | 77 parser.add_argument('-v', '--verbose', action="store_true", |
| 73 help="Increase output verbosity") | 78 help="Increase output verbosity") |
| 74 | 79 |
| 75 android_group = parser.add_argument_group('Android-only', | 80 android_group = parser.add_argument_group('Android-only', |
| 76 'These arguments apply only when --android is passed.') | 81 'These arguments apply only when --android is passed.') |
| 77 android_group.add_argument('--adb-path', help='Path of the adb binary.') | 82 android_group.add_argument('--adb-path', help='Path of the adb binary.') |
| 78 android_group.add_argument('--target-device', help='Device to run on.') | 83 android_group.add_argument('--target-device', help='Device to run on.') |
| 79 android_group.add_argument('--logcat-tags', help='Comma-separated list of ' | 84 android_group.add_argument('--logcat-tags', help='Comma-separated list of ' |
| 80 'additional logcat tags to display.') | 85 'additional logcat tags to display.') |
| 81 android_group.add_argument('--free-host-ports', action='store_true', | 86 android_group.add_argument('--free-host-ports', action='store_true', |
| 82 help='Use system-allocated ports on the host when ' | 87 help='Use system-allocated ports on the host when ' |
| 83 'spawning local servers.') | 88 'spawning local servers. This still forwards to ' |
| 89 'fixed ports on the device, so that caching ' |
| 90 'works.') |
| 84 | 91 |
| 85 desktop_group = parser.add_argument_group('Desktop-only', | 92 desktop_group = parser.add_argument_group('Desktop-only', |
| 86 'These arguments apply only when running on desktop.') | 93 'These arguments apply only when running on desktop.') |
| 87 desktop_group.add_argument('--use-osmesa', action='store_true', | 94 desktop_group.add_argument('--use-osmesa', action='store_true', |
| 88 help='Configure the native viewport service ' | 95 help='Configure the native viewport service ' |
| 89 'for off-screen rendering.') | 96 'for off-screen rendering.') |
| 90 | 97 |
| 91 config_file_group = parser.add_argument_group('Configuration file', | 98 config_file_group = parser.add_argument_group('Configuration file', |
| 92 'These arguments allow to modify the behavior regarding the mojoconfig ' | 99 'These arguments allow to modify the behavior regarding the mojoconfig ' |
| 93 'file.') | 100 'file.') |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 inferred_paths = paths.infer_paths(script_args.android, script_args.debug, | 153 inferred_paths = paths.infer_paths(script_args.android, script_args.debug, |
| 147 script_args.target_cpu) | 154 script_args.target_cpu) |
| 148 shell_config = ShellConfig() | 155 shell_config = ShellConfig() |
| 149 | 156 |
| 150 shell_config.android = script_args.android | 157 shell_config.android = script_args.android |
| 151 shell_config.shell_path = (script_args.shell_path or | 158 shell_config.shell_path = (script_args.shell_path or |
| 152 inferred_paths['shell_path']) | 159 inferred_paths['shell_path']) |
| 153 shell_config.origin = script_args.origin | 160 shell_config.origin = script_args.origin |
| 154 shell_config.map_url_list = script_args.map_url | 161 shell_config.map_url_list = script_args.map_url |
| 155 shell_config.map_origin_list = script_args.map_origin | 162 shell_config.map_origin_list = script_args.map_origin |
| 163 shell_config.free_ports = script_args.free_ports |
| 156 shell_config.verbose = script_args.verbose | 164 shell_config.verbose = script_args.verbose |
| 157 | 165 |
| 158 # Android-only. | 166 # Android-only. |
| 159 shell_config.adb_path = (script_args.adb_path or inferred_paths['adb_path'] or | 167 shell_config.adb_path = (script_args.adb_path or inferred_paths['adb_path'] or |
| 160 'adb') | 168 'adb') |
| 161 shell_config.target_device = script_args.target_device | 169 shell_config.target_device = script_args.target_device |
| 162 shell_config.logcat_tags = script_args.logcat_tags | 170 shell_config.logcat_tags = script_args.logcat_tags |
| 163 shell_config.free_host_ports = script_args.free_host_ports | 171 shell_config.free_host_ports = script_args.free_host_ports |
| 164 | 172 |
| 165 # Desktop-only. | 173 # Desktop-only. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 219 |
| 212 if 'content_handlers' in config: | 220 if 'content_handlers' in config: |
| 213 try: | 221 try: |
| 214 for (mime_type, | 222 for (mime_type, |
| 215 content_handler_url) in config['content_handlers'].iteritems(): | 223 content_handler_url) in config['content_handlers'].iteritems(): |
| 216 shell_config.content_handlers[mime_type] = content_handler_url | 224 shell_config.content_handlers[mime_type] = content_handler_url |
| 217 except (ValueError, KeyError): | 225 except (ValueError, KeyError): |
| 218 raise ShellConfigurationException('Failed to parse content_handlers in ' | 226 raise ShellConfigurationException('Failed to parse content_handlers in ' |
| 219 'the config file.') | 227 'the config file.') |
| 220 return shell_config | 228 return shell_config |
| OLD | NEW |