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

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..0941aed0d4e7ea62f4dfbe263a95e041b2e32edb
--- /dev/null
+++ b/tools/dom/dom.py
@@ -0,0 +1,151 @@
+#!/usr/bin/python
+
+# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+# 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
Emily Fortuna 2013/02/06 22:52:40 Can you write a few brief usage examples here like
+
+import os
+import subprocess
+import sys
+
+sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
+import utils
+
+dart_out_dir = utils.GetBuildRoot(utils.GuessOS(), 'release', 'ia32')
+if utils.IsWindows():
+ dart_bin = os.path.join(dart_out_dir, 'dart.exe')
+else:
+ dart_bin = os.path.join(dart_out_dir, 'dart')
+
+def help():
+ print('Commands: ')
+ for cmd in sorted(commands.keys()):
+ print('\t%s - %s' % (cmd, commands[cmd][1]))
+
+def analyze():
+ ''' Runs the dart analyzer. '''
+ call([
+ os.path.join(dart_out_dir, 'dart-sdk', 'bin', 'dart_analyzer'),
+ os.path.join('tests', 'html', 'element_test.dart'),
+ '--dart-sdk', 'sdk',
+ '--show-sdk-warnings',
+ ])
+
+def build():
+ ''' Builds the SDK '''
+ call([
+ os.path.join('tools', 'build.py'),
+ '--mode=release',
+ '--arch=ia32',
+ ])
+
+def dart2js():
+ compile_dart2js(argv.pop(0))
+
+def compile_dart2js(dart_file):
+ out_file = dart_file + '.js'
+ dart2js_path = os.path.join(dart_out_dir, 'dart-sdk', 'bin', 'dart2js')
+
+ call([
+ dart2js_path,
+ dart_file,
+ '--checked',
+ '--library-root=sdk/',
+ '--disallow-unsafe-eval',
+ '-o%s' % out_file
+ ])
+ return out_file
+
+def gen():
+ os.chdir(os.path.join('tools', 'dom', 'scripts'))
+ call([
+ 'go.sh',
+ ])
+
+def size_check():
+ ''' Displays the dart2js size of swarm. '''
+ dart_file = os.path.join('samples', 'swarm', 'swarm.dart')
+ out_file = compile_dart2js(dart_file)
+
+ subprocess.call([
+ 'du',
+ '-kh',
+ '--apparent-size',
+ out_file,
+ ])
+
+ os.remove(out_file)
+ os.remove(out_file + '.deps')
+ os.remove(out_file + '.map')
+
+def test_ff():
+ test_dart2js('ff', argv)
+
+def test_drt():
+ test_dart2js('drt', argv)
+
+def test_chrome():
+ test_dart2js('chrome', argv)
+
+def test_dart2js(browser, argv):
+ cmd = [
+ os.path.join('tools', 'test.py'),
+ '-c', 'dart2js',
+ '-r', browser,
+ '--mode=release',
+ '--checked',
+ '--arch=ia32',
+ '-v',
+ ]
+ if argv:
+ cmd.append(argv.pop(0))
+ else:
+ print(
+ 'Test commands should be followed by tests to run. Defaulting to html')
+ cmd.append('html')
+ call(cmd)
+
+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)
+
+commands = {
+ 'analyze': [analyze, 'Run the dart analyzer'],
+ 'build': [build, 'Build dart in release mode'],
+ 'dart2js': [dart2js, 'Run dart2js on the .dart file specified'],
+ 'gen': [gen, 'Re-generate DOM generated files (run go.sh)'],
+ 'size_check': [size_check, 'Check the size of dart2js compiled Swarm'],
+ 'test_chrome': [test_chrome, 'Run tests in checked mode in Chrome.\n'
+ '\t\tOptionally provide name of test to run.'],
+ 'test_drt': [test_drt, 'Run tests in checked mode in DumpRenderTree.\n'
+ '\t\tOptionally provide name of test to run.'],
+ 'test_ff': [test_ff, 'Run tests in checked mode in Firefox.\n'
+ '\t\tOptionally provide name of test to run.'],
+}
+
+def main(argv):
+ argv.pop(0)
+
+ if not argv:
+ help()
+
+ while (argv):
+ init_dir()
+ command = argv.pop(0)
+
+ if not command in commands:
+ help();
+ return
+ commands[command][0]()
+
+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