Support running w/ Sky from a local checkout through a config file.
This adds an alternative config file that one can use to run Sky apps
using sky_viewer and SDK packages from a local sky_engine checkout.
To use this you need to check out sky_engine
(https://github.com/domokit/sky_engine ) and build for Android.
Then, run the lengthy command-line:
mojo/devtools/common/mojo_run \
--android \
--config-file mojo/tools/configs/sky \
--config-alias SKY_SRC=/path_to_your_checkout/sky_engine/src \
"mojo:window_manager https://sky/examples/hello_world/lib/main.dart"
The sky apps are served from the Sky checkout, so all of
sky/packages/sky/example is available under https://sky/examples .
This replaces the old support for '--sky' flag, which was not enough to
run w/ sky after the repo split anyway.
R=qsr@chromium.org
Review URL: https://codereview.chromium.org/1268323003 .
Cr-Mirrored-From: https://github.com/domokit/mojo
Cr-Mirrored-Commit: a2bc80458262f5a9b1edabbae294ea0d8d67cdb8
diff --git a/README.md b/README.md
index eb7d5c6..5bcd6b9 100644
--- a/README.md
+++ b/README.md
@@ -50,27 +50,6 @@
By default, `mojo_run` uses `mojo:kiosk_wm` as the default window manager. It
can be changed using the `--window-manager` flag.
-#### Sky apps
-
-To run a [Sky](https://github.com/domokit/sky_engine) app, you need to build
-`sky_viewer.mojo` in a Sky checkout, and indicate the path to the binary using
-the `--map-url` parameter:
-
-```sh
-mojo_run --map-url mojo:sky_viewer=/path/to/sky/viewer "mojo:window_manager APP_URL"
-```
-
-If the app does not declare a shebang indicating that it needs to be run in
-`sky_viewer`, pass `--sky` to map `sky_viewer` as a default content handler for
-dart apps:
-
-```sh
-mojo_run --map-url mojo:sky_viewer=/path/to/sky/viewer "mojo:window_manager APP_URL" --sky
-```
-
-Note that Sky apps will need the --use-osmesa flag to run
-over [chromoting](https://support.google.com/chrome/answer/1649523?hl=en):
-
### Debugger
`mojo_debug` allows you to interactively inspect a running shell, collect
diff --git a/devtoolslib/shell_arguments.py b/devtoolslib/shell_arguments.py
index 3863935..20f512e 100644
--- a/devtoolslib/shell_arguments.py
+++ b/devtoolslib/shell_arguments.py
@@ -102,27 +102,6 @@
return args
-def _configure_sky(shell_args):
- """Maps mojo:sky_viewer as a content handler for dart applications.
- app.
-
- Args:
- shell_args: Current list of shell arguments.
-
- Returns:
- Updated list of shell arguments.
- """
- # Configure the content type mappings for the sky_viewer. This is needed
- # only for the Sky apps that do not declare mojo:sky_viewer in a shebang.
- # TODO(ppi): drop this part once we can rely on the Sky files declaring
- # correct shebang.
- shell_args = append_to_argument(shell_args, '--content-handlers=',
- 'text/sky,mojo:sky_viewer')
- shell_args = append_to_argument(shell_args, '--content-handlers=',
- 'application/dart,mojo:sky_viewer')
- return shell_args
-
-
def configure_local_origin(shell, local_dir, fixed_port=True):
"""Sets up a local http server to serve files in |local_dir| along with
device port forwarding if needed.
@@ -234,8 +213,12 @@
shell_args.extend(configure_local_origin(shell, shell_config.origin,
fixed_port=True))
- if shell_config.sky:
- shell_args = _configure_sky(shell_args)
+ if shell_config.content_handlers:
+ for (mime_type,
+ content_handler_url) in shell_config.content_handlers.iteritems():
+ shell_args = append_to_argument(shell_args, '--content-handlers=',
+ '%s,%s' % (mime_type,
+ content_handler_url))
for dev_server_config in shell_config.dev_servers:
shell_args = _configure_dev_server(shell, shell_args, dev_server_config)
diff --git a/devtoolslib/shell_config.py b/devtoolslib/shell_config.py
index 2b55d54..20d2e23 100644
--- a/devtoolslib/shell_config.py
+++ b/devtoolslib/shell_config.py
@@ -29,7 +29,7 @@
self.map_url_list = []
self.map_origin_list = []
self.dev_servers = []
- self.sky = None
+ self.content_handlers = dict()
self.verbose = None
# Android-only.
@@ -66,9 +66,6 @@
parser.add_argument('--map-origin', action='append',
help='Define a mapping for a url origin in the format '
'<origin>=<url-or-local-file-path>')
- parser.add_argument('--sky', action='store_true',
- help='Maps mojo:sky_viewer as the content handler for '
- 'dart apps.')
parser.add_argument('-v', '--verbose', action="store_true",
help="Increase output verbosity")
@@ -90,6 +87,11 @@
'file.')
config_file_group.add_argument('--config-file', type=file,
help='Path of the configuration file to use.')
+ config_file_group.add_argument('--config-alias', action='append',
+ dest='config_aliases',
+ help='Alias to substitute in the config file '
+ 'of the form ALIAS=<value>. Can be passed '
+ 'more than once.')
config_file_group.add_argument('--no-config-file', action='store_true',
help='Pass to skip automatic discovery of the '
'mojoconfig file.')
@@ -145,7 +147,6 @@
shell_config.origin = script_args.origin
shell_config.map_url_list = script_args.map_url
shell_config.map_origin_list = script_args.map_origin
- shell_config.sky = script_args.sky
shell_config.verbose = script_args.verbose
# Android-only.
@@ -168,6 +169,11 @@
if config_file:
with config_file:
config_file_aliases = []
+ if script_args.config_aliases:
+ for alias_spec in script_args.config_aliases:
+ alias_from, alias_to = alias_spec.split('=')
+ config_file_aliases.append(('@{%s}' % alias_from, alias_to))
+
if inferred_paths['build_dir_path']:
config_file_aliases.append(('@{BUILD_DIR}',
inferred_paths['build_dir_path']))
@@ -192,5 +198,14 @@
shell_config.dev_servers.append(dev_server_config)
except (ValueError, KeyError):
raise ShellConfigurationException('Failed to parse dev_servers in '
- 'the mojoconfig file.')
+ 'the config file.')
+
+ if 'content_handlers' in config:
+ try:
+ for (mime_type,
+ content_handler_url) in config['content_handlers'].iteritems():
+ shell_config.content_handlers[mime_type] = content_handler_url
+ except (ValueError, KeyError):
+ raise ShellConfigurationException('Failed to parse content_handlers in '
+ 'the config file.')
return shell_config