| 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 re | 6 import re |
| 7 import subprocess | 7 import subprocess |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 SAMPLES_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(_
_file__)))) | 10 SAMPLES_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(_
_file__)))) |
| 11 DART_PATH = os.path.dirname(SAMPLES_PATH) | 11 DART_PATH = os.path.dirname(SAMPLES_PATH) |
| 12 TOOLS_PATH = os.path.join(DART_PATH, 'tools') | 12 TOOLS_PATH = os.path.join(DART_PATH, 'tools') |
| 13 | 13 |
| 14 sys.path.append(TOOLS_PATH) | 14 sys.path.append(TOOLS_PATH) |
| 15 import utils | 15 import utils |
| 16 | 16 |
| 17 def Compile(source, target): | 17 def Compile(source, target): |
| 18 binary = os.path.abspath(os.path.join(DART_PATH, | 18 binary = os.path.abspath(os.path.join(DART_PATH, |
| 19 utils.GetBuildRoot(utils.GuessOS(), | 19 utils.GetBuildRoot(utils.GuessOS(), |
| 20 'release', 'ia32'), | 20 'release', 'ia32'), |
| 21 'frog', 'bin', 'frogsh')) | 21 'dart-sdk', 'bin', 'frogc')) |
| 22 | 22 |
| 23 cmd = [binary, '--compile-only', | 23 cmd = [binary, '--compile-only', |
| 24 '--libdir=' + os.path.join(DART_PATH, 'frog', 'lib'), | |
| 25 '--out=' + target] | 24 '--out=' + target] |
| 26 cmd.append(source) | 25 cmd.append(source) |
| 27 print 'Executing: ' + ' '.join(cmd) | 26 print 'Executing: ' + ' '.join(cmd) |
| 28 subprocess.call(cmd) | 27 subprocess.call(cmd) |
| 29 | 28 |
| 30 def HtmlConvert(infile): | 29 def HtmlConvert(infile): |
| 31 (head, tail) = os.path.split(infile) | 30 (head, tail) = os.path.split(infile) |
| 32 | 31 |
| 33 if head == 'tests': | 32 if head == 'tests': |
| 34 outdir = 'frog' | 33 outdir = 'frog' |
| 35 os.chdir('tests') | 34 os.chdir('tests') |
| 35 if not os.path.exists(outdir): |
| 36 os.makedirs(outdir) |
| 36 elif head == '': | 37 elif head == '': |
| 37 outdir = '.' | 38 outdir = '.' |
| 38 else: | 39 else: |
| 39 raise 'Illegal input: ' + infile | 40 raise 'Illegal input: ' + infile |
| 40 | 41 |
| 41 pattern = r'<script type="application/dart" src="([\w-]+).dart">' | 42 pattern = r'<script type="application/dart" src="([\w-]+).dart">' |
| 42 infile = open(tail, 'r') | 43 infile = open(tail, 'r') |
| 43 outfilename = os.path.join(outdir, tail.replace('.html', '-js.html')) | 44 outfilename = os.path.join(outdir, tail.replace('.html', '-js.html')) |
| 44 outfile = open(outfilename, 'w') | 45 outfile = open(outfilename, 'w') |
| 45 | 46 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 os.chdir('..') | 60 os.chdir('..') |
| 60 | 61 |
| 61 # Frog compile individual dom and html tests into tests/frog. | 62 # Frog compile individual dom and html tests into tests/frog. |
| 62 tests = glob.glob('tests/dom-*-*.html') | 63 tests = glob.glob('tests/dom-*-*.html') |
| 63 | 64 |
| 64 for test in tests: | 65 for test in tests: |
| 65 HtmlConvert(test) | 66 HtmlConvert(test) |
| 66 | 67 |
| 67 # Frog compile driver to index-js.html. | 68 # Frog compile driver to index-js.html. |
| 68 HtmlConvert('index.html') | 69 HtmlConvert('index.html') |
| OLD | NEW |