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

Unified Diff: tools/dom/dom.py

Issue 12211019: Adding helper script to make it easy to run common DOM tasks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/dom.py
diff --git a/tools/dom/dom.py b/tools/dom/dom.py
new file mode 100755
index 0000000000000000000000000000000000000000..847c399dd0795a5794ab88668bca5a050e93a376
--- /dev/null
+++ b/tools/dom/dom.py
@@ -0,0 +1,136 @@
+#!/usr/bin/python
+
+# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
vsm 2013/02/05 20:29:24 2013 :-)
blois 2013/02/06 22:36:27 Done.
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+# A script which makes it easy to execute common DOM-related tasks
+
+import subprocess
+import sys
+import re
+import os
+import glob
vsm 2013/02/05 20:29:24 nit: alphabetize imports
blois 2013/02/06 22:36:27 Done.
+
+dart_out_dir = 'out/ReleaseIA32/'
vsm 2013/02/05 20:29:24 'out' is 'xcodebuild' on the Mac. I think most of
Emily Fortuna 2013/02/06 18:36:14 and 'out' is called 'build' on Windows. the file i
blois 2013/02/06 22:36:27 Done.
+dart_bin = os.path.join(dart_out_dir, 'dart')
Emily Fortuna 2013/02/06 18:36:14 same here ... on Windows it's dart.exe see the fun
blois 2013/02/06 22:36:27 Done.
+
+class Processor:
+ argv = []
Anton Muhin 2013/02/06 11:52:28 this is not necessary and does slightly different
blois 2013/02/06 22:36:27 Done.
+
+ def process(self, argv):
vsm 2013/02/05 20:29:24 You might consider the optparse python module for
Emily Fortuna 2013/02/06 18:36:14 +1 Then you won't need to to add the logic for hel
blois 2013/02/06 22:36:27 From what I can tell, opt parse primarily handles
Emily Fortuna 2013/02/06 22:52:39 Gotcha. Argparse is just what you want then, but i
+ self.argv = argv
+
+ if not argv:
+ self.help()
+
+ while (len(argv) > 0):
+ init_dir()
+ command = argv.pop(0)
+
+ if not hasattr(self, command):
Anton Muhin 2013/02/06 11:52:28 I'd rather have an explicit map 'command name' : f
blois 2013/02/06 22:36:27 Done.
+ self.help()
+ return
+ getattr(self, command)()
+
+ def help(self):
+ print('Commands: ')
+ privates = ['argv', 'process']
+ for attr in dir(self):
+ if not attr in privates and not attr.startswith('__'):
Anton Muhin 2013/02/06 11:52:28 map will help here too
blois 2013/02/06 22:36:27 Done.
+ print('\t%s' % attr)
+
+ def analyze(self):
+ ''' Runs the dart analyzer. '''
+ call([
+ './out/ReleaseIA32/dart-sdk/bin/dart_analyzer',
+ './tests/html/element_test.dart',
+ '--dart-sdk', 'sdk/',
+ '--show-sdk-warnings',
+ ])
+
+ def build(self):
+ ''' Builds the SDK '''
+ call([
+ './tools/build.py',
+ '--mode=release',
+ '--arch=ia32',
+ ])
+
+ def gen(self):
+ os.chdir('tools/dom/scripts/')
+ call([
+ './go.sh',
+ ])
+
+ def size_check(self):
+ ''' Displays the dart2js size of swarm. '''
+ dartfile = 'samples/swarm/swarm.dart'
+ dartfile = os.path.abspath(dartfile)
+ outfile = dartfile + '.js'
+
+ dart2js_path = os.path.join(dart_out_dir, 'dart-sdk', 'bin', 'dart2js')
+
+ call([
+ dart2js_path,
+ dartfile,
+ '--library-root=sdk/',
+ '-o%s' % outfile
+ ])
+ subprocess.call([
+ 'du',
+ '-kh',
+ '--apparent-size',
+ outfile,
+ ])
+
+ os.remove(outfile)
+ os.remove(outfile + '.deps')
+ os.remove(outfile + '.map')
+
+ def test_ff(self):
+ test_dart2js('ff', self.argv)
+
+ def test_drt(self):
+ test_dart2js('drt', self.argv)
+
+ def test_chrome(self):
+ test_dart2js('chrome', self.argv)
+
+
+def call(args):
+ print (' '.join(args))
+ subprocess.call(args)
+
+def init_dir():
+ ''' Makes sure that we're always rooted in the dart root folder.'''
+ dart_dir = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ os.path.pardir, os.path.pardir))
+ os.chdir(dart_dir)
+
+def test_dart2js(browser, argv):
+ cmd = [
+ './tools/test.py',
+ '-c', 'dart2js',
+ '-r', browser,
+ '--mode=release',
+ '--checked',
+ '--arch=ia32',
+ '-v',
+ ]
+ if argv:
+ cmd.append(self.argv.pop(0))
+ else:
+ print(
+ 'Test commands should be followed by tests to run. Defaulting to html')
+ cmd.append('html')
+ call(cmd)
+
+def main(argv):
+ argv.pop(0)
+ Processor().process(argv)
+
+
+if __name__ == '__main__':
+ main(sys.argv)
« 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