OLD | NEW |
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 # | 4 # |
5 # This python script creates a string literal in a C++ source file from a C++ | 5 # This python script creates a string literal in a C++ source file from a C++ |
6 # source template and text file. | 6 # source template and text file. |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 from os.path import join | 10 from os.path import join |
(...skipping 15 matching lines...) Expand all Loading... |
26 result += '\n ' | 26 result += '\n ' |
27 lineCounter = 0 | 27 lineCounter = 0 |
28 if lineCounter != 0: | 28 if lineCounter != 0: |
29 result += '\n ' | 29 result += '\n ' |
30 result += ' // Terminating null character.\n 0' | 30 result += ' // Terminating null character.\n 0' |
31 return result | 31 return result |
32 | 32 |
33 | 33 |
34 def makeFile(output_file, input_cc_file, input_files): | 34 def makeFile(output_file, input_cc_file, input_files): |
35 bootstrap_cc_text = open(input_cc_file).read() | 35 bootstrap_cc_text = open(input_cc_file).read() |
36 bootstrap_cc_text = bootstrap_cc_text % makeString(input_files) | 36 bootstrap_cc_text = bootstrap_cc_text.replace("{{DART_SOURCE}}", |
| 37 makeString(input_files)) |
37 open(output_file, 'w').write(bootstrap_cc_text) | 38 open(output_file, 'w').write(bootstrap_cc_text) |
38 return True | 39 return True |
39 | 40 |
40 | 41 |
41 def main(args): | 42 def main(args): |
42 try: | 43 try: |
43 # Parse input. | 44 # Parse input. |
44 parser = OptionParser() | 45 parser = OptionParser() |
45 parser.add_option("--output", | 46 parser.add_option("--output", |
46 action="store", type="string", | 47 action="store", type="string", |
(...skipping 22 matching lines...) Expand all Loading... |
69 | 70 |
70 return 0 | 71 return 0 |
71 except Exception, inst: | 72 except Exception, inst: |
72 sys.stderr.write('create_string_literal.py exception\n') | 73 sys.stderr.write('create_string_literal.py exception\n') |
73 sys.stderr.write(str(inst)) | 74 sys.stderr.write(str(inst)) |
74 sys.stderr.write('\n') | 75 sys.stderr.write('\n') |
75 return -1 | 76 return -1 |
76 | 77 |
77 if __name__ == '__main__': | 78 if __name__ == '__main__': |
78 sys.exit(main(sys.argv)) | 79 sys.exit(main(sys.argv)) |
OLD | NEW |