OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 4 # BSD-style license that can be found in the LICENSE file. |
5 """Used to merge and copy dart source files for deployment to AppEngine""" | 5 """Used to merge and copy dart source files for deployment to AppEngine""" |
6 | 6 |
7 import fileinput | 7 import fileinput |
8 import sys | 8 import sys |
9 import shutil | 9 import shutil |
10 import os | 10 import os |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 def normjoin(*args): | 58 def normjoin(*args): |
59 return os.path.normpath(os.path.join(*args)) | 59 return os.path.normpath(os.path.join(*args)) |
60 | 60 |
61 def mergefiles(srcs, dstfile): | 61 def mergefiles(srcs, dstfile): |
62 for src in srcs: | 62 for src in srcs: |
63 with open(src, 'r') as s: | 63 with open(src, 'r') as s: |
64 for line in s: | 64 for line in s: |
65 if not line.startswith('part of '): | 65 if not line.startswith('part of '): |
66 dstfile.write(line) | 66 dstfile.write(line) |
67 | 67 |
68 def copyfile(src, dst): | |
69 if not exists(dirname(dst)): | |
70 os.makedirs(dirname(dst)) | |
71 with open(src, 'r') as s: | |
72 with open(dst, 'w') as d: | |
73 d.write(s.read()) | |
74 | |
75 def main(outdir = None, *inputs): | 68 def main(outdir = None, *inputs): |
76 if not outdir or not inputs: | 69 if not outdir or not inputs: |
77 print "Usage: %s OUTDIR INPUTS" % args[0] | 70 print "Usage: %s OUTDIR INPUTS" % args[0] |
78 print " OUTDIR is the war directory to copy to" | 71 print " OUTDIR is the war directory to copy to" |
79 print " INPUTS is a list of files or patterns used to specify the input" | 72 print " INPUTS is a list of files or patterns used to specify the input" |
80 print " .dart files" | 73 print " .dart files" |
81 print "This script should be run from the client root directory." | 74 print "This script should be run from the client root directory." |
82 print "Files will be merged and copied to: OUTDIR/relative-path-of-file," | 75 print "Files will be merged and copied to: OUTDIR/relative-path-of-file," |
83 print "except for dart files with absolute paths, which will be copied to" | 76 print "except for dart files with absolute paths, which will be copied to" |
84 print " OUTDIR/absolute-path-as-directories" | 77 print " OUTDIR/absolute-path-as-directories" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 for suffix in library.imports: | 128 for suffix in library.imports: |
136 m = re.match(r'[\'"]([^\'"]+)[\'"](\s+as\s+\w+)?$', suffix) | 129 m = re.match(r'[\'"]([^\'"]+)[\'"](\s+as\s+\w+)?$', suffix) |
137 uri = m.group(0) | 130 uri = m.group(0) |
138 if not uri.startswith('dart:'): | 131 if not uri.startswith('dart:'): |
139 worklist.append(normjoin(dirname(lib), uri)); | 132 worklist.append(normjoin(dirname(lib), uri)); |
140 | 133 |
141 return 0 | 134 return 0 |
142 | 135 |
143 if __name__ == '__main__': | 136 if __name__ == '__main__': |
144 sys.exit(main(*sys.argv[1:])) | 137 sys.exit(main(*sys.argv[1:])) |
OLD | NEW |