| 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 """Functions that configure the shell before it is run manipulating its argument | 5 """Functions that configure the shell before it is run manipulating its argument | 
| 6 list. | 6 list. | 
| 7 """ | 7 """ | 
| 8 | 8 | 
| 9 import os.path | 9 import os.path | 
| 10 import sys | 10 import sys | 
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 181   else: | 181   else: | 
| 182     arguments.append(key + value) | 182     arguments.append(key + value) | 
| 183 | 183 | 
| 184   return arguments | 184   return arguments | 
| 185 | 185 | 
| 186 | 186 | 
| 187 def add_shell_arguments(parser): | 187 def add_shell_arguments(parser): | 
| 188   """Adds argparse arguments allowing to configure shell abstraction using | 188   """Adds argparse arguments allowing to configure shell abstraction using | 
| 189   configure_shell() below. | 189   configure_shell() below. | 
| 190   """ | 190   """ | 
| 191   # Arguments indicating paths to binaries and tools. | 191   # Arguments configuring the shell run. | 
| 192   parser.add_argument('--adb-path', help='Path of the adb binary.') |  | 
| 193   parser.add_argument('--shell-path', help='Path of the Mojo shell binary.') | 192   parser.add_argument('--shell-path', help='Path of the Mojo shell binary.') | 
| 194 |  | 
| 195   # Arguments configuring the shell run. |  | 
| 196   parser.add_argument('--android', help='Run on Android', | 193   parser.add_argument('--android', help='Run on Android', | 
| 197                       action='store_true') | 194                       action='store_true') | 
| 198   parser.add_argument('--origin', help='Origin for mojo: URLs. This can be a ' | 195   parser.add_argument('--origin', help='Origin for mojo: URLs. This can be a ' | 
| 199                       'web url or a local directory path.') | 196                       'web url or a local directory path.') | 
| 200   parser.add_argument('--map-url', action='append', | 197   parser.add_argument('--map-url', action='append', | 
| 201                       help='Define a mapping for a url in the format ' | 198                       help='Define a mapping for a url in the format ' | 
| 202                       '<url>=<url-or-local-file-path>') | 199                       '<url>=<url-or-local-file-path>') | 
| 203   parser.add_argument('--map-origin', action='append', | 200   parser.add_argument('--map-origin', action='append', | 
| 204                       help='Define a mapping for a url origin in the format ' | 201                       help='Define a mapping for a url origin in the format ' | 
| 205                       '<origin>=<url-or-local-file-path>') | 202                       '<origin>=<url-or-local-file-path>') | 
| 206 |  | 
| 207   # Android-only arguments. |  | 
| 208   parser.add_argument('--target-device', |  | 
| 209                       help='(android-only) Device to run on.') |  | 
| 210   parser.add_argument('--logcat-tags', |  | 
| 211                       help='(android-only) Comma-separated list of additional ' |  | 
| 212                       'logcat tags to display on the console.') |  | 
| 213 |  | 
| 214   # Desktop-only arguments. |  | 
| 215   parser.add_argument('--use-osmesa', action='store_true', |  | 
| 216                       help='(linux-only) Configure the native viewport service ' |  | 
| 217                       'for off-screen rendering.') |  | 
| 218 |  | 
| 219   # Other configuration. |  | 
| 220   parser.add_argument('-v', '--verbose', action="store_true", | 203   parser.add_argument('-v', '--verbose', action="store_true", | 
| 221                       help="Increase output verbosity") | 204                       help="Increase output verbosity") | 
| 222 | 205 | 
|  | 206   android_group = parser.add_argument_group('Android-only', | 
|  | 207       'These arguments apply only when --android is passed.') | 
|  | 208   android_group.add_argument('--adb-path', help='Path of the adb binary.') | 
|  | 209   android_group.add_argument('--target-device', help='Device to run on.') | 
|  | 210   android_group.add_argument('--logcat-tags', help='Comma-separated list of ' | 
|  | 211                              'additional logcat tags to display.') | 
|  | 212 | 
|  | 213   desktop_group = parser.add_argument_group('Desktop-only', | 
|  | 214       'These arguments apply only when running on desktop.') | 
|  | 215   desktop_group.add_argument('--use-osmesa', action='store_true', | 
|  | 216                              help='Configure the native viewport service ' | 
|  | 217                              'for off-screen rendering.') | 
|  | 218 | 
| 223 | 219 | 
| 224 class ShellConfigurationException(Exception): | 220 class ShellConfigurationException(Exception): | 
| 225   """Represents an error preventing creating a functional shell abstraction.""" | 221   """Represents an error preventing creating a functional shell abstraction.""" | 
| 226   pass | 222   pass | 
| 227 | 223 | 
| 228 | 224 | 
| 229 def configure_shell(config_args, shell_args): | 225 def configure_shell(config_args, shell_args): | 
| 230   """ | 226   """ | 
| 231   Produces a shell abstraction configured using the parsed arguments defined in | 227   Produces a shell abstraction configured using the parsed arguments defined in | 
| 232   add_shell_arguments(). | 228   add_shell_arguments(). | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 267                                config_args.map_origin) | 263                                config_args.map_origin) | 
| 268 | 264 | 
| 269   if config_args.origin: | 265   if config_args.origin: | 
| 270     if _is_web_url(config_args.origin): | 266     if _is_web_url(config_args.origin): | 
| 271       shell_args.append('--origin=' + config_args.origin) | 267       shell_args.append('--origin=' + config_args.origin) | 
| 272     else: | 268     else: | 
| 273       shell_args.extend(configure_local_origin(shell, config_args.origin, | 269       shell_args.extend(configure_local_origin(shell, config_args.origin, | 
| 274                                              fixed_port=True)) | 270                                              fixed_port=True)) | 
| 275 | 271 | 
| 276   return shell, shell_args | 272   return shell, shell_args | 
| OLD | NEW | 
|---|