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

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

Issue 14791007: fix dom.py -- initdir was not right if running from a relative path (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« 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/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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 def call(args): 163 def call(args):
160 print ' '.join(args) 164 print ' '.join(args)
161 pipe = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 165 pipe = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
162 output, error = pipe.communicate() 166 output, error = pipe.communicate()
163 if output: 167 if output:
164 print output 168 print output
165 if error: 169 if error:
166 print error 170 print error
167 return pipe.returncode 171 return pipe.returncode
168 172
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 = { 173 commands = {
177 'analyze': [analyze, 'Run the dart analyzer'], 174 'analyze': [analyze, 'Run the dart analyzer'],
178 'build': [build, 'Build dart in release mode'], 175 'build': [build, 'Build dart in release mode'],
179 'dart2js': [dart2js, 'Run dart2js on the .dart file specified'], 176 'dart2js': [dart2js, 'Run dart2js on the .dart file specified'],
180 'dartc': [dartc, 'Runs dartc in release mode'], 177 'dartc': [dartc, 'Runs dartc in release mode'],
181 'docs': [docs, 'Generates docs.json'], 178 'docs': [docs, 'Generates docs.json'],
182 'gen': [gen, 'Re-generate DOM generated files (run go.sh)'], 179 'gen': [gen, 'Re-generate DOM generated files (run go.sh)'],
183 'size_check': [size_check, 'Check the size of dart2js compiled Swarm'], 180 'size_check': [size_check, 'Check the size of dart2js compiled Swarm'],
184 'test_docs': [test_docs, 'Tests docs.dart'], 181 'test_docs': [test_docs, 'Tests docs.dart'],
185 'test_chrome': [test_chrome, 'Run tests in checked mode in Chrome.\n' 182 'test_chrome': [test_chrome, 'Run tests in checked mode in Chrome.\n'
186 '\t\tOptionally provide name of test to run.'], 183 '\t\tOptionally provide name of test to run.'],
187 'test_drt': [test_drt, 'Run tests in checked mode in DumpRenderTree.\n' 184 'test_drt': [test_drt, 'Run tests in checked mode in DumpRenderTree.\n'
188 '\t\tOptionally provide name of test to run.'], 185 '\t\tOptionally provide name of test to run.'],
189 'test_ff': [test_ff, 'Run tests in checked mode in Firefox.\n' 186 'test_ff': [test_ff, 'Run tests in checked mode in Firefox.\n'
190 '\t\tOptionally provide name of test to run.'], 187 '\t\tOptionally provide name of test to run.'],
191 'http_server': [http_server, 'Starts the testing server for manually ' 188 'http_server': [http_server, 'Starts the testing server for manually '
192 'running browser tests.'], 189 'running browser tests.'],
193 } 190 }
194 191
195 def main(): 192 def main():
196 success = True 193 success = True
197 argv.pop(0) 194 argv.pop(0)
198 195
199 if not argv: 196 if not argv:
200 help() 197 help()
201 success = False 198 success = False
202 199
203 while (argv): 200 while (argv):
204 init_dir() 201 # Make sure that we're always rooted in the dart root folder.
202 os.chdir(dart_dir)
205 command = argv.pop(0) 203 command = argv.pop(0)
206 204
207 if not command in commands: 205 if not command in commands:
208 help(); 206 help();
209 success = False 207 success = False
210 break 208 break
211 returncode = commands[command][0]() 209 returncode = commands[command][0]()
212 success = success and not bool(returncode) 210 success = success and not bool(returncode)
213 211
214 sys.exit(not success) 212 sys.exit(not success)
215 213
216 if __name__ == '__main__': 214 if __name__ == '__main__':
217 main() 215 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