Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
update.py
Go to the documentation of this file.
1#!/usr/bin/env python3
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.
8import os
9import subprocess
10import sys
11
12from os.path import abspath, basename, dirname, exists, join, split, relpath
13import base64, re, os, shutil, subprocess, sys, tempfile, optparse
14
15APP_PATH = os.getcwd()
16CLIENT_TOOLS_PATH = dirname(abspath(__file__))
17CLIENT_PATH = dirname(CLIENT_TOOLS_PATH)
18
19# Add the client tools directory so we can find htmlconverter.py.
20sys.path.append(CLIENT_TOOLS_PATH)
21import htmlconverter
22
23
24def convertOne(infile, options):
25 outDirBase = 'outcode'
26 outfile = join(outDirBase, infile)
27 print('converting %s to %s' % (infile, outfile))
28
29 if 'dart' in options.target:
30 htmlconverter.convertForDartium(infile, outDirBase,
31 outfile.replace('.html', '-dart.html'),
32 options.verbose)
33 if 'js' in options.target:
34 htmlconverter.convertForChromium(infile, options.dartc_extra_flags,
35 outfile.replace('.html', '-js.html'),
36 options.verbose)
37
38
39def Flags():
40 """ Constructs a parser for extracting flags from the command line. """
41 result = optparse.OptionParser()
42 result.add_option("-t",
43 "--target",
44 help="The target html to generate",
45 metavar="[js,dart]",
46 default='js,dart')
47 result.add_option("--verbose",
48 help="Print verbose output",
49 default=False,
50 action="store_true")
51 result.add_option("--dartc_extra_flags",
52 help="Additional flag text to pass to dartc",
53 default="",
54 action="store")
55 #result.set_usage("update.py input.html -o OUTDIR -t chromium,dartium")
56 return result
57
58
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
69def main():
70 os.chdir(CLIENT_PATH) # TODO(jimhug): I don't like chdir's in scripts...
71
72 parser = Flags()
73 options, args = parser.parse_args()
74 #if len(args) < 1 or not options.out or not options.target:
75 # parser.print_help()
76 # return 1
77
78 REL_APP_PATH = relpath(APP_PATH)
79 for file in getAllHtmlFiles():
80 infile = join(REL_APP_PATH, file)
81 convertOne(infile, options)
82
83
84if __name__ == '__main__':
85 main()
void print(void *str)
Definition bridge.cpp:126
Definition main.py:1
getAllHtmlFiles()
Definition update.py:59
main()
Definition update.py:69
Flags()
Definition update.py:39
convertOne(infile, options)
Definition update.py:24