OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 import glob | 3 import glob |
4 import os | 4 import os |
5 import os.path | 5 import os.path |
6 import platform | 6 import platform |
7 import re | 7 import re |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... | |
41 if head == 'tests': | 41 if head == 'tests': |
42 outdir = compiler | 42 outdir = compiler |
43 os.chdir('tests') | 43 os.chdir('tests') |
44 if not os.path.exists(outdir): | 44 if not os.path.exists(outdir): |
45 os.makedirs(outdir) | 45 os.makedirs(outdir) |
46 elif head == '': | 46 elif head == '': |
47 outdir = '.' | 47 outdir = '.' |
48 else: | 48 else: |
49 raise 'Illegal input: ' + infile | 49 raise 'Illegal input: ' + infile |
50 | 50 |
51 pattern = r'<script type="application/dart" src="([\w-]+).dart">' | 51 pattern = r'<script type="application/dart" src="([\w-]+).dart" defer>' |
52 infile = open(tail, 'r') | 52 infile = open(tail, 'r') |
53 outfilename = os.path.join(outdir, tail.replace('.html', '-js.html')) | 53 outfilename = os.path.join(outdir, tail.replace('.html', '-js.html')) |
54 outfile = open(outfilename, 'w') | 54 outfile = open(outfilename, 'w') |
55 | 55 |
56 print 'Converting %s to %s' % (tail, outfilename) | 56 print 'Converting %s to %s' % (tail, outfilename) |
57 for line in infile: | 57 for line in infile: |
58 result = re.search(pattern, line) | 58 result = re.search(pattern, line) |
59 if result: | 59 if result: |
60 testname = result.group(1) | 60 testname = result.group(1) |
61 dartname = testname + '.dart' | 61 dartname = testname + '.dart' |
62 jsname = '%s.%s.js' % (testname, compiler) | 62 jsname = '%s.%s.js' % (testname, compiler) |
63 outname = os.path.join(outdir, jsname) | 63 outname = os.path.join(outdir, jsname) |
64 Compile(dartname, outname, compiler) | 64 Compile(dartname, outname, compiler) |
65 script = '<script type="text/javascript" src="%s">' % jsname | 65 script = '<script type="text/javascript" src="%s">' % jsname |
sra1
2013/08/12 21:22:26
Does this want to be deferred too?
blois
2013/08/14 20:44:39
D'oh! That's the correct location for this change.
| |
66 outfile.write(re.sub(pattern, script, line)) | 66 outfile.write(re.sub(pattern, script, line)) |
67 else: | 67 else: |
68 outfile.write(line) | 68 outfile.write(line) |
69 | 69 |
70 if head == 'tests': | 70 if head == 'tests': |
71 os.chdir('..') | 71 os.chdir('..') |
72 | 72 |
73 # Compile individual html tests. | 73 # Compile individual html tests. |
74 tests = glob.glob('tests/dom-*-html.html') | 74 tests = glob.glob('tests/dom-*-html.html') |
75 | 75 |
76 for test in tests: | 76 for test in tests: |
77 HtmlConvert(test, 'dart2js') | 77 HtmlConvert(test, 'dart2js') |
78 | 78 |
79 # Compile driver to index-js.html. | 79 # Compile driver to index-js.html. |
80 HtmlConvert('index.html', 'dart2js') | 80 HtmlConvert('index.html', 'dart2js') |
OLD | NEW |