Chromium Code Reviews

Unified Diff: mojo/devtools/common/devtoolslib/shell_arguments.py

Issue 1259793008: Support dev servers defined in a mojoconfig file. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: mojo/devtools/common/devtoolslib/shell_arguments.py
diff --git a/mojo/devtools/common/devtoolslib/shell_arguments.py b/mojo/devtools/common/devtoolslib/shell_arguments.py
index f8db0537cd669a0e20f9316f95d01e2365c9b686..16bff74d276fffc9ffd633faa76e363dc0af2c91 100644
--- a/mojo/devtools/common/devtoolslib/shell_arguments.py
+++ b/mojo/devtools/common/devtoolslib/shell_arguments.py
@@ -14,6 +14,7 @@ import urlparse
from devtoolslib.android_shell import AndroidShell
from devtoolslib.linux_shell import LinuxShell
+from devtoolslib.shell_config import ShellConfigurationException
# When spinning up servers for local origins, we want to use predictable ports
# so that caching works between subsequent runs with the same command line.
@@ -21,11 +22,6 @@ _LOCAL_ORIGIN_PORT = 31840
_MAPPINGS_BASE_PORT = 31841
-class ShellConfigurationException(Exception):
- """Represents an error preventing creating a functional shell abstraction."""
- pass
-
-
def _is_web_url(dest):
return True if urlparse.urlparse(dest).scheme else False
@@ -170,6 +166,26 @@ def append_to_argument(arguments, key, value, delimiter=","):
return arguments
+def _configure_dev_server(shell, shell_args, dev_server_config):
+ """Sets up a dev server on the host according to |dev_server_config|.
+
+ Args:
+ shell: The shell that is being configured.
+ shell_arguments: Current list of shell arguments.
+ dev_server_config: Instance of shell_config.DevServerConfig describing the
+ dev server to be set up.
+
+ Returns:
+ The updated argument list.
+ """
+ server_url = shell.ServeLocalDirectories(dev_server_config.mappings)
+ shell_args.append('--map-origin=%s=%s' % (dev_server_config.host, server_url))
+ print "Configured %s locally as %s" % (dev_server_config.host, server_url)
+ for mapping_prefix, mapping_path in dev_server_config.mappings:
+ print " /%s -> %s" % (mapping_prefix, mapping_path)
+ return shell_args
+
+
def get_shell(shell_config, shell_args):
"""
Produces a shell abstraction configured according to |shell_config|.
@@ -221,4 +237,7 @@ def get_shell(shell_config, shell_args):
if shell_config.sky:
shell_args = _configure_sky(shell_args)
+ for dev_server_config in shell_config.dev_servers:
+ shell_args = _configure_dev_server(shell, shell_args, dev_server_config)
+
return shell, shell_args

Powered by Google App Engine