Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: mojo/tools/mojo_shell.py

Issue 1157993010: Add --sky support in mojo_shell.py. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix the port for Sky packages. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import logging 7 import logging
8 import sys 8 import sys
9 import os.path
9 10
10 import devtools 11 import devtools
11 devtools.add_lib_to_path() 12 devtools.add_lib_to_path()
12 from devtoolslib.android_shell import AndroidShell 13 from devtoolslib.android_shell import AndroidShell
13 from devtoolslib.linux_shell import LinuxShell 14 from devtoolslib.linux_shell import LinuxShell
14 from devtoolslib import shell_arguments 15 from devtoolslib import shell_arguments
15 16
16 from mopy.config import Config 17 from mopy.config import Config
17 from mopy.paths import Paths 18 from mopy.paths import Paths
18 19
19 USAGE = ("mojo_shell.py " 20 USAGE = ("mojo_shell.py "
20 "[--args-for=<mojo-app>] " 21 "[--args-for=<mojo-app>] "
21 "[--content-handlers=<handlers>] " 22 "[--content-handlers=<handlers>] "
22 "[--enable-external-applications] " 23 "[--enable-external-applications] "
23 "[--disable-cache] " 24 "[--disable-cache] "
24 "[--enable-multiprocess] " 25 "[--enable-multiprocess] "
25 "[--url-mappings=from1=to1,from2=to2] " 26 "[--url-mappings=from1=to1,from2=to2] "
26 "[<mojo-app>] " 27 "[<mojo-app>] "
27 """ 28 """
28 29
29 A <mojo-app> is a Mojo URL or a Mojo URL and arguments within quotes. 30 A <mojo-app> is a Mojo URL or a Mojo URL and arguments within quotes.
30 Example: mojo_shell "mojo:js_standalone test.js". 31 Example: mojo_shell "mojo:js_standalone test.js".
31 <url-lib-path> is searched for shared libraries named by mojo URLs. 32 <url-lib-path> is searched for shared libraries named by mojo URLs.
32 The value of <handlers> is a comma separated list like: 33 The value of <handlers> is a comma separated list like:
33 text/html,mojo:html_viewer,application/javascript,mojo:js_content_handler 34 text/html,mojo:html_viewer,application/javascript,mojo:js_content_handler
34 """) 35 """)
35 36
36 _DEFAULT_WINDOW_MANAGER = "mojo:kiosk_wm" 37 _DEFAULT_WINDOW_MANAGER = "mojo:kiosk_wm"
38 _SKY_SERVER_PORT = 9998
37 39
38 40
39 def main(): 41 def main():
40 logging.basicConfig() 42 logging.basicConfig()
41 43
42 parser = argparse.ArgumentParser(usage=USAGE) 44 parser = argparse.ArgumentParser(usage=USAGE)
43 45
44 # Arguments indicating the configuration we are targeting. 46 # Arguments indicating the configuration we are targeting.
45 parser.add_argument('--android', help='Run on Android', 47 parser.add_argument('--android', help='Run on Android',
46 action='store_true') 48 action='store_true')
47 debug_group = parser.add_mutually_exclusive_group() 49 debug_group = parser.add_mutually_exclusive_group()
48 debug_group.add_argument('--debug', help='Debug build (default)', 50 debug_group.add_argument('--debug', help='Debug build (default)',
49 default=True, action='store_true') 51 default=True, action='store_true')
50 debug_group.add_argument('--release', help='Release build', default=False, 52 debug_group.add_argument('--release', help='Release build', default=False,
51 dest='debug', action='store_false') 53 dest='debug', action='store_false')
52 parser.add_argument('--target-cpu', help='CPU architecture to run for.', 54 parser.add_argument('--target-cpu', help='CPU architecture to run for.',
53 choices=['x64', 'x86', 'arm']) 55 choices=['x64', 'x86', 'arm'])
54 56
55 # Arguments configuring the shell run. 57 # Arguments configuring the shell run.
56 parser.add_argument('--origin', help='Origin for mojo: URLs.') 58 parser.add_argument('--origin', help='Origin for mojo: URLs.')
57 parser.add_argument('--window-manager', default=_DEFAULT_WINDOW_MANAGER, 59 parser.add_argument('--window-manager', default=_DEFAULT_WINDOW_MANAGER,
58 help='Window manager app to be mapped as ' 60 help='Window manager app to be mapped as '
59 'mojo:window_manager. By default it is ' + 61 'mojo:window_manager. By default it is ' +
60 _DEFAULT_WINDOW_MANAGER) 62 _DEFAULT_WINDOW_MANAGER)
61 parser.add_argument('--no-debugger', action="store_true", 63 parser.add_argument('--no-debugger', action="store_true",
62 help='Do not spawn mojo:debugger.') 64 help='Do not spawn mojo:debugger.')
65 parser.add_argument('--sky',
66 help='Loads the given Sky file.')
63 parser.add_argument('-v', '--verbose', action="store_true", 67 parser.add_argument('-v', '--verbose', action="store_true",
64 help="Increase output verbosity") 68 help="Increase output verbosity")
65 69
66 # Android-only arguments. 70 # Android-only arguments.
67 parser.add_argument('--target-device', help='Device to run on.') 71 parser.add_argument('--target-device', help='Device to run on.')
68 parser.add_argument('--logcat-tags', help='Comma-separated list of ' 72 parser.add_argument('--logcat-tags', help='Comma-separated list of '
69 'additional logcat tags to display on the console.') 73 'additional logcat tags to display on the console.')
70 74
71 launcher_args, args = parser.parse_known_args() 75 launcher_args, args = parser.parse_known_args()
72 if launcher_args.android: 76 if launcher_args.android:
(...skipping 18 matching lines...) Expand all
91 shell = LinuxShell(paths.mojo_shell_path) 95 shell = LinuxShell(paths.mojo_shell_path)
92 96
93 if launcher_args.origin: 97 if launcher_args.origin:
94 args.append('--origin=' + launcher_args.origin) 98 args.append('--origin=' + launcher_args.origin)
95 args = shell_arguments.AppendToArgument(args, '--url-mappings=', 99 args = shell_arguments.AppendToArgument(args, '--url-mappings=',
96 'mojo:window_manager=%s' % 100 'mojo:window_manager=%s' %
97 launcher_args.window_manager) 101 launcher_args.window_manager)
98 if not launcher_args.no_debugger: 102 if not launcher_args.no_debugger:
99 args.extend(shell_arguments.ConfigureDebugger(shell)) 103 args.extend(shell_arguments.ConfigureDebugger(shell))
100 104
105 if launcher_args.sky:
106 packages_local_path = os.path.join(paths.build_dir, 'gen', 'dart-pkg',
107 'packages')
108 additional_mappings = [
109 ('packages/', packages_local_path),
110 ]
111 server_url = shell.ServeLocalDirectory(paths.src_root,
112 port=_SKY_SERVER_PORT, additional_mappings=additional_mappings)
113 sky_url = server_url + launcher_args.sky
114
115 args.append('mojo:window_manager %s' % sky_url)
116
117 if launcher_args.verbose:
118 print "Shell arguments: " + str(args)
119
101 shell.Run(args) 120 shell.Run(args)
102 return 0 121 return 0
103 122
104 123
105 if __name__ == "__main__": 124 if __name__ == "__main__":
106 sys.exit(main()) 125 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698