OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
3 # for details. All rights reserved. Use of this source code is governed by a | |
4 # BSD-style license that can be found in the LICENSE file. | |
5 | |
6 # This script builds and then uploads the Dart client sample app to AppEngine, | |
7 # where it is accessible by visiting http://dart.googleplex.com. | |
8 import os | |
9 import subprocess | |
10 import sys | |
11 | |
12 from os.path import abspath, basename, dirname, exists, join, split, relpath | |
13 import base64, re, os, shutil, subprocess, sys, tempfile, optparse | |
14 | |
15 APP_PATH = os.getcwd() | |
16 CLIENT_TOOLS_PATH = dirname(abspath(__file__)) | |
17 CLIENT_PATH = dirname(CLIENT_TOOLS_PATH) | |
18 | |
19 # Add the client tools directory so we can find htmlconverter.py. | |
20 sys.path.append(CLIENT_TOOLS_PATH) | |
21 import htmlconverter | |
22 | |
23 def convertOne(infile, options): | |
24 outDirBase = 'outcode' | |
25 outfile = join(outDirBase, infile) | |
26 print 'converting %s to %s' % (infile, outfile) | |
27 | |
28 if 'dart' in options.target: | |
29 htmlconverter.convertForDartium( | |
30 infile, | |
31 outDirBase, | |
32 outfile.replace('.html', '-dart.html'), | |
33 options.verbose) | |
34 if 'js' in options.target: | |
35 htmlconverter.convertForChromium( | |
36 infile, options.dartc_extra_flags, | |
37 outfile.replace('.html', '-js.html'), | |
38 options.verbose) | |
39 | |
40 | |
41 def Flags(): | |
42 """ Consturcts a parser for extracting flags from the command line. """ | |
43 result = optparse.OptionParser() | |
44 result.add_option("-t", "--target", | |
45 help="The target html to generate", | |
46 metavar="[js,dart]", | |
47 default='js,dart') | |
48 result.add_option("--verbose", | |
49 help="Print verbose output", | |
50 default=False, | |
51 action="store_true") | |
52 result.add_option("--dartc_extra_flags", | |
53 help="Additional flag text to pass to dartc", | |
54 default="", | |
55 action="store") | |
56 #result.set_usage("update.py input.html -o OUTDIR -t chromium,dartium") | |
57 return result | |
58 | |
59 def getAllHtmlFiles(): | |
60 htmlFiles = [] | |
61 for filename in os.listdir(APP_PATH): | |
62 fName, fExt = os.path.splitext(filename) | |
63 if fExt.lower() == '.html': | |
64 htmlFiles.append(filename) | |
65 | |
66 return htmlFiles | |
67 | |
68 def main(): | |
69 os.chdir(CLIENT_PATH) # TODO(jimhug): I don't like chdir's in scripts... | |
70 | |
71 parser = Flags() | |
72 options, args = parser.parse_args() | |
73 #if len(args) < 1 or not options.out or not options.target: | |
74 # parser.print_help() | |
75 # return 1 | |
76 | |
77 REL_APP_PATH = relpath(APP_PATH) | |
78 for file in getAllHtmlFiles(): | |
79 infile = join(REL_APP_PATH, file) | |
80 convertOne(infile, options) | |
81 | |
82 if __name__ == '__main__': | |
83 main() | |
OLD | NEW |