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

Side by Side Diff: tools/dom/dom.py

Issue 14732003: Implement Model-Driven-Views spec for Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: small fix Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 # A script which makes it easy to execute common DOM-related tasks 7 # A script which makes it easy to execute common DOM-related tasks
8 8
9 import os 9 import os
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 from sys import argv 12 from sys import argv
13 13
14 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 14 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
15 import utils 15 import utils
16 16
17 dart_out_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32') 17 dart_out_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32')
18 if utils.IsWindows(): 18 if utils.IsWindows():
19 dart_bin = os.path.join(dart_out_dir, 'dart.exe') 19 dart_bin = os.path.join(dart_out_dir, 'dart.exe')
20 else: 20 else:
21 dart_bin = os.path.join(dart_out_dir, 'dart') 21 dart_bin = os.path.join(dart_out_dir, 'dart')
22 22
23 dart_dir = os.path.abspath(os.path.join(
24 os.path.dirname(os.path.realpath(__file__)),
25 os.path.pardir, os.path.pardir))
26
23 def help(): 27 def help():
24 print('Helper script to make it easy to perform common tasks encountered ' 28 print('Helper script to make it easy to perform common tasks encountered '
25 'during the life of a Dart DOM developer.\n' 29 'during the life of a Dart DOM developer.\n'
26 '\n' 30 '\n'
27 'For example, to re-generate DOM classes then run a specific test:\n' 31 'For example, to re-generate DOM classes then run a specific test:\n'
28 ' dom.py gen test_drt html/element_test\n' 32 ' dom.py gen test_drt html/element_test\n'
29 '\n' 33 '\n'
30 'Or re-generate DOM classes and run the Dart analyzer:\n' 34 'Or re-generate DOM classes and run the Dart analyzer:\n'
31 ' dom.py gen analyze\n') 35 ' dom.py gen analyze\n')
32 print('Commands: ') 36 print('Commands: ')
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 '-o%s' % out_file 95 '-o%s' % out_file
92 ] 96 ]
93 if checked: 97 if checked:
94 args.append('--checked') 98 args.append('--checked')
95 99
96 call(args) 100 call(args)
97 return out_file 101 return out_file
98 102
99 def gen(): 103 def gen():
100 os.chdir(os.path.join('tools', 'dom', 'scripts')) 104 os.chdir(os.path.join('tools', 'dom', 'scripts'))
101 return call([os.path.join(os.getcwd(), 'dartdomgenerator.py'), 105 result = call([os.path.join(os.getcwd(), 'dartdomgenerator.py'),
102 '--rebuild', '--parallel', '--systems=htmldart2js,htmldartium']) 106 '--rebuild', '--parallel', '--systems=htmldart2js,htmldartium'])
107 os.chdir(os.path.join('..', '..', '..'))
108 return result
103 109
104 def http_server(): 110 def http_server():
105 print('Browse tests at ' 111 print('Browse tests at '
106 '\033[94mhttp://localhost:5400/root_build/generated_tests/\033[0m') 112 '\033[94mhttp://localhost:5400/root_build/generated_tests/\033[0m')
107 return call([ 113 return call([
108 utils.DartBinary(), 114 utils.DartBinary(),
109 os.path.join('tools', 'testing', 'dart', 'http_server.dart'), 115 os.path.join('tools', 'testing', 'dart', 'http_server.dart'),
110 '--port=5400', 116 '--port=5400',
111 '--crossOriginPort=5401', 117 '--crossOriginPort=5401',
112 '--network=0.0.0.0', 118 '--network=0.0.0.0',
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 def call(args): 165 def call(args):
160 print ' '.join(args) 166 print ' '.join(args)
161 pipe = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 167 pipe = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
162 output, error = pipe.communicate() 168 output, error = pipe.communicate()
163 if output: 169 if output:
164 print output 170 print output
165 if error: 171 if error:
166 print error 172 print error
167 return pipe.returncode 173 return pipe.returncode
168 174
169 def init_dir():
170 ''' Makes sure that we're always rooted in the dart root folder.'''
171 dart_dir = os.path.abspath(os.path.join(
172 os.path.dirname(os.path.realpath(__file__)),
173 os.path.pardir, os.path.pardir))
174 os.chdir(dart_dir)
175
176 commands = { 175 commands = {
177 'analyze': [analyze, 'Run the dart analyzer'], 176 'analyze': [analyze, 'Run the dart analyzer'],
178 'build': [build, 'Build dart in release mode'], 177 'build': [build, 'Build dart in release mode'],
179 'dart2js': [dart2js, 'Run dart2js on the .dart file specified'], 178 'dart2js': [dart2js, 'Run dart2js on the .dart file specified'],
180 'dartc': [dartc, 'Runs dartc in release mode'], 179 'dartc': [dartc, 'Runs dartc in release mode'],
181 'docs': [docs, 'Generates docs.json'], 180 'docs': [docs, 'Generates docs.json'],
182 'gen': [gen, 'Re-generate DOM generated files (run go.sh)'], 181 'gen': [gen, 'Re-generate DOM generated files (run go.sh)'],
183 'size_check': [size_check, 'Check the size of dart2js compiled Swarm'], 182 'size_check': [size_check, 'Check the size of dart2js compiled Swarm'],
184 'test_docs': [test_docs, 'Tests docs.dart'], 183 'test_docs': [test_docs, 'Tests docs.dart'],
185 'test_chrome': [test_chrome, 'Run tests in checked mode in Chrome.\n' 184 'test_chrome': [test_chrome, 'Run tests in checked mode in Chrome.\n'
186 '\t\tOptionally provide name of test to run.'], 185 '\t\tOptionally provide name of test to run.'],
187 'test_drt': [test_drt, 'Run tests in checked mode in DumpRenderTree.\n' 186 'test_drt': [test_drt, 'Run tests in checked mode in DumpRenderTree.\n'
188 '\t\tOptionally provide name of test to run.'], 187 '\t\tOptionally provide name of test to run.'],
189 'test_ff': [test_ff, 'Run tests in checked mode in Firefox.\n' 188 'test_ff': [test_ff, 'Run tests in checked mode in Firefox.\n'
190 '\t\tOptionally provide name of test to run.'], 189 '\t\tOptionally provide name of test to run.'],
191 'http_server': [http_server, 'Starts the testing server for manually ' 190 'http_server': [http_server, 'Starts the testing server for manually '
192 'running browser tests.'], 191 'running browser tests.'],
193 } 192 }
194 193
195 def main(): 194 def main():
196 success = True 195 success = True
197 argv.pop(0) 196 argv.pop(0)
198 197
199 if not argv: 198 if not argv:
200 help() 199 help()
201 success = False 200 success = False
202 201
203 while (argv): 202 while (argv):
204 init_dir() 203 # Make sure that we're always rooted in the dart root folder.
204 os.chdir(dart_dir)
205 command = argv.pop(0) 205 command = argv.pop(0)
206 206
207 if not command in commands: 207 if not command in commands:
208 help(); 208 help();
209 success = False 209 success = False
210 break 210 break
211 returncode = commands[command][0]() 211 returncode = commands[command][0]()
212 success = success and not bool(returncode) 212 success = success and not bool(returncode)
213 213
214 sys.exit(not success) 214 sys.exit(not success)
215 215
216 if __name__ == '__main__': 216 if __name__ == '__main__':
217 main() 217 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698