OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 from mopy.config import Config |
| 7 import argparse |
| 8 import mopy.paths |
| 9 import os |
| 10 import pipes |
| 11 import subprocess |
| 12 import sys |
| 13 |
| 14 # FIXME: We need to merge the mojo/tools and sky/tools directories |
| 15 sys.path.append(os.path.join(mopy.paths.Paths().src_root, 'sky', 'tools')) |
| 16 from skypy.skyserver import SkyServer |
| 17 import skypy.paths |
| 18 |
| 19 |
| 20 def main(): |
| 21 parser = argparse.ArgumentParser(description='Helper to launch mojo demos') |
| 22 parser.add_argument('-d', dest='build_dir', type=str) |
| 23 parser.add_argument('--browser', action='store_const', const='browser', |
| 24 dest='demo', help='Use the browser demo') |
| 25 parser.add_argument('--wm_flow', action='store_const', const='wm_flow', |
| 26 dest='demo', help='Use the wm_flow demo') |
| 27 |
| 28 args = parser.parse_args() |
| 29 |
| 30 config = Config(target_os=Config.OS_LINUX, is_debug=True) |
| 31 paths = mopy.paths.Paths(config, build_dir=args.build_dir) |
| 32 mojo_shell = paths.mojo_shell_path |
| 33 |
| 34 cmd = [mojo_shell] |
| 35 cmd.append('--v=1') |
| 36 |
| 37 HTTP_PORT = 9999 |
| 38 sky_paths = skypy.paths.Paths(paths.build_dir) |
| 39 configuration = 'Debug' if config.is_debug else 'Release' |
| 40 server = SkyServer(sky_paths, HTTP_PORT, configuration, paths.src_root) |
| 41 |
| 42 if args.demo == 'browser': |
| 43 cmd.append('--url-mappings=mojo:window_manager=mojo:example_window_manager') |
| 44 cmd.append('mojo:window_manager') |
| 45 elif args.demo == 'wm_flow': |
| 46 base_url = server.path_as_url(paths.build_dir) |
| 47 wm_url = os.path.join(base_url, 'wm_flow_wm.mojo') |
| 48 app_url = os.path.join(base_url, 'wm_flow_app.mojo') |
| 49 cmd.append('--url-mappings=mojo:window_manager=' + wm_url) |
| 50 # Mojo apps don't know their own URL yet: |
| 51 # https://docs.google.com/a/chromium.org/document/d/1AQ2y6ekzvbdaMF5WrUQmney
XJnke-MnYYL4Gz1AKDos |
| 52 cmd.append('--args-for=%s %s' % (app_url, app_url)) |
| 53 cmd.append('--args-for=mojo:window_manager %s' % (wm_url)) |
| 54 cmd.append(app_url) |
| 55 else: |
| 56 parser.print_usage() |
| 57 print "--browser or --wm_flow is required" |
| 58 return 1 |
| 59 |
| 60 # http://stackoverflow.com/questions/4748344/whats-the-reverse-of-shlex-split |
| 61 # shlex.quote doesn't exist until 3.3 |
| 62 # This doesn't print exactly what we want, but it's better than nothing: |
| 63 print " ".join(map(pipes.quote, cmd)) |
| 64 with server: |
| 65 return subprocess.call(cmd) |
| 66 |
| 67 if __name__ == '__main__': |
| 68 sys.exit(main()) |
OLD | NEW |