Don't emulate Sky server when --sky is passed.

The support for running Sky apps within a Mojo checkout broke when
sky_engine moved out - as sky SDK packages are no longer built in Mojo
checkout, we are not in position to emulate Sky server as we used to do.

Running Sky apps is still possible, but one needs to indicate where
sky_viewer is and run Sky server themselves.

This patch updates the documentation and removes broken support.

Fixes domokit/devtools#24.

R=qsr@chromium.org

Review URL: https://codereview.chromium.org/1264763003 .

Cr-Mirrored-From: https://github.com/domokit/mojo
Cr-Mirrored-Commit: 11e4fcd71e3283ec4c28e91aca581b03bef24327
diff --git a/README.md b/README.md
index 7a2745b..4536ea5 100644
--- a/README.md
+++ b/README.md
@@ -21,10 +21,48 @@
 machine to communicate with a device attached to a local machine, forwarding the
 ports used by `mojo_run`.
 
+### Runner
+
+`mojo_run` allows you to run a Mojo shell either on the host, or on an attached
+Android device.
+
+```sh
+mojo_run APP_URL  # Run on the host.
+mojo_run APP_URL --android  # Run on Android device.
+```
+
+Unless running within a Mojo checkout, we need to indicate the path to the shell
+binary:
+
+```sh
+mojo_run --shell-path path/to/shell/binary APP_URL
+```
+
+#### 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 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 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
 
-The `mojo_debug` script allows you to interactively inspect a running shell,
-collect performance traces and attach a gdb debugger.
+`mojo_debug` allows you to interactively inspect a running shell, collect
+performance traces and attach a gdb debugger.
 
 #### Tracing
 To collect [performance
diff --git a/devtoolslib/paths.py b/devtoolslib/paths.py
index 073783d..3347c75 100644
--- a/devtoolslib/paths.py
+++ b/devtoolslib/paths.py
@@ -53,9 +53,6 @@
                                 'sdk', 'platform-tools', 'adb')
   else:
     paths['shell'] = os.path.join(build_dir_path, 'mojo_shell')
-
-  paths['sky_packages'] = os.path.join(build_dir_path, 'gen', 'dart-pkg',
-                                       'packages')
   return paths, None
 
 
diff --git a/devtoolslib/shell_arguments.py b/devtoolslib/shell_arguments.py
index 1f2a97f..bd818e8 100644
--- a/devtoolslib/shell_arguments.py
+++ b/devtoolslib/shell_arguments.py
@@ -100,45 +100,25 @@
   return args
 
 
-def _configure_sky(shell, root_path, sky_packages_path, sky_target):
-  """Configures additional mappings and a server needed to run the given Sky
+def _configure_sky(shell_args):
+  """Maps mojo:sky_viewer as a content handler for dart applications.
   app.
 
   Args:
-    root_path: Local path to the root from which Sky apps will be served.
-    sky_packages_path: Local path to the root from which Sky packages will be
-        served.
-    sky_target: Path to the Sky app to be run, relative to |root_path|.
+    shell_args: Current list of shell arguments.
 
   Returns:
-    Arguments that need to be appended to the shell argument list.
+    Updated list of shell arguments.
   """
-  # Configure a server to serve the checkout root at / (so that Sky examples
-  # are accessible using a root-relative path) and Sky packages at /packages.
-  # This is independent from the server that potentially serves the origin
-  # directory containing the mojo: apps.
-  additional_mappings = [
-      ('packages/', sky_packages_path),
-  ]
-  server_url = shell.ServeLocalDirectory(root_path, port=_SKY_SERVER_PORT,
-      additional_mappings=additional_mappings)
-
-  args = []
   # 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,
-  # and it is unfortunate as it configures the shell to map all items of the
-  # application/dart content-type as Sky apps.
+  # 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.
-  args = append_to_argument(args, '--content-handlers=',
+  shell_args = append_to_argument(shell_args, '--content-handlers=',
                                             'text/sky,mojo:sky_viewer')
-  args = append_to_argument(args, '--content-handlers=',
+  shell_args = append_to_argument(shell_args, '--content-handlers=',
                                             'application/dart,mojo:sky_viewer')
-
-  # Configure the window manager to embed the sky_viewer.
-  sky_url = server_url + sky_target
-  args.append('mojo:window_manager %s' % sky_url)
-  return args
+  return shell_args
 
 
 def configure_local_origin(shell, local_dir, fixed_port=True):
@@ -200,6 +180,9 @@
   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")
 
@@ -269,4 +252,7 @@
       shell_args.extend(configure_local_origin(shell, config_args.origin,
                                              fixed_port=True))
 
+  if config_args.sky:
+    shell_args = _configure_sky(shell_args)
+
   return shell, shell_args
diff --git a/mojo_run b/mojo_run
index 778dd70..0adba39 100755
--- a/mojo_run
+++ b/mojo_run
@@ -77,8 +77,6 @@
                       help='Window manager app to be mapped as '
                       'mojo:window_manager. By default it is ' +
                       _DEFAULT_WINDOW_MANAGER)
-  parser.add_argument('--sky',
-                      help='Loads the given Sky file.')
 
   script_args, shell_args = parser.parse_known_args()
 
@@ -121,15 +119,6 @@
                                                   'mojo:window_manager=%s' %
                                                   script_args.window_manager)
 
-  if script_args.sky:
-    if not mojo_paths:
-      print 'Running with --sky is not supported outside of the Mojo checkout.'
-      # See https://github.com/domokit/devtools/issues/27.
-      return 1
-    shell_args.extend(shell_arguments._configure_sky(shell, mojo_paths['root'],
-                                                     mojo_paths['sky_packages'],
-                                                     script_args.sky))
-
   if script_args.verbose:
     print "Shell arguments: " + str(shell_args)