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

Side by Side Diff: samples/third_party/dromaeo/generate_frog_tests.py

Issue 10407099: Generate dart2js versions of Dromaeo (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 8 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
(Empty)
1 #!/usr/bin/python
2
3 import glob
4 import os
5 import os.path
6 import platform
7 import re
8 import subprocess
9 import sys
10
11 SAMPLES_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(_ _file__))))
12 DART_PATH = os.path.dirname(SAMPLES_PATH)
13 TOOLS_PATH = os.path.join(DART_PATH, 'tools')
14
15 sys.path.append(TOOLS_PATH)
16 import utils
17
18 def Compile(source, target):
19 binary = os.path.abspath(os.path.join(DART_PATH,
20 utils.GetBuildRoot(utils.GuessOS(),
21 'release', 'ia32'),
22 'dart-sdk', 'bin', 'frogc'))
23
24 cmd = [binary, '--compile-only',
25 '--out=' + target]
26 cmd.append(source)
27 print 'Executing: ' + ' '.join(cmd)
28 if platform.system() == "Windows":
29 subprocess.call(cmd, shell=True)
30 else:
31 subprocess.call(cmd)
32
33 def HtmlConvert(infile):
34 (head, tail) = os.path.split(infile)
35
36 if head == 'tests':
37 outdir = 'frog'
38 os.chdir('tests')
39 if not os.path.exists(outdir):
40 os.makedirs(outdir)
41 elif head == '':
42 outdir = '.'
43 else:
44 raise 'Illegal input: ' + infile
45
46 pattern = r'<script type="application/dart" src="([\w-]+).dart">'
47 infile = open(tail, 'r')
48 outfilename = os.path.join(outdir, tail.replace('.html', '-js.html'))
49 outfile = open(outfilename, 'w')
50
51 print 'Converting %s to %s' % (tail, outfilename)
52 for line in infile:
53 result = re.search(pattern, line)
54 if result:
55 dartname = result.group(1) + '.dart'
56 jsname = os.path.join(outdir, dartname + '.js')
57 Compile(dartname, jsname)
58 script = '<script type="text/javascript" src="%s">' % (dartname + '.js')
59 outfile.write(re.sub(pattern, script, line))
60 else:
61 outfile.write(line)
62
63 if head == 'tests':
64 os.chdir('..')
65
66 # Frog compile individual dom and html tests into tests/frog.
67 tests = glob.glob('tests/dom-*-*.html')
68
69 for test in tests:
70 HtmlConvert(test)
71
72 # Frog compile driver to index-js.html.
73 HtmlConvert('index.html')
OLDNEW
« no previous file with comments | « samples/third_party/dromaeo/generate_dart2js_tests.py ('k') | tools/testing/perf_testing/run_perf_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698