| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2013, 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 # | 5 # |
| 6 # This python script creates a source path mapping in a C++ source file from | 6 # This python script creates a source path mapping in a C++ source file from |
| 7 # a C++ source template and list of dart library files. | 7 # a C++ source template and list of dart library files. |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 if string_file.endswith('.dart'): | 51 if string_file.endswith('.dart'): |
| 52 file_count += 1 | 52 file_count += 1 |
| 53 if (not main_file_found): | 53 if (not main_file_found): |
| 54 inpt = open(string_file, 'r') | 54 inpt = open(string_file, 'r') |
| 55 for line in inpt: | 55 for line in inpt: |
| 56 # File with library tag is the main file. | 56 # File with library tag is the main file. |
| 57 if line.startswith('library '): | 57 if line.startswith('library '): |
| 58 main_file_found = True | 58 main_file_found = True |
| 59 bootstrap_cc_text = bootstrap_cc_text.replace( | 59 bootstrap_cc_text = bootstrap_cc_text.replace( |
| 60 "{{LIBRARY_SOURCE_MAP}}", | 60 "{{LIBRARY_SOURCE_MAP}}", |
| 61 ' "' + lib_name + '",\n "' + | 61 ' "' + lib_name + '",\n' + |
| 62 os.path.abspath(string_file).replace('\\', '\\\\') + '",\n' + | |
| 63 ' source_array_' + str(file_count) + ',\n') | 62 ' source_array_' + str(file_count) + ',\n') |
| 64 inpt.close() | 63 inpt.close() |
| 65 if (main_file_found): | 64 if (main_file_found): |
| 66 continue | 65 continue |
| 67 part_index.append(' "' + | 66 part_index.append(' "' + |
| 68 os.path.basename(string_file).replace('\\', '\\\\') + '",\n') | 67 os.path.basename(string_file).replace('\\', '\\\\') + '",\n') |
| 69 part_index.append(' "' + | |
| 70 os.path.abspath(string_file).replace('\\', '\\\\') + '",\n') | |
| 71 part_index.append(' source_array_' + str(file_count) + ',\n\n') | 68 part_index.append(' source_array_' + str(file_count) + ',\n\n') |
| 72 bootstrap_cc_text = bootstrap_cc_text.replace("{{LIBRARY_SOURCE_MAP}}", '') | 69 bootstrap_cc_text = bootstrap_cc_text.replace("{{LIBRARY_SOURCE_MAP}}", '') |
| 73 bootstrap_cc_text = bootstrap_cc_text.replace("{{PART_SOURCE_MAP}}", | 70 bootstrap_cc_text = bootstrap_cc_text.replace("{{PART_SOURCE_MAP}}", |
| 74 ''.join(part_index)) | 71 ''.join(part_index)) |
| 75 open(output_file, 'w').write(bootstrap_cc_text) | 72 open(output_file, 'w').write(bootstrap_cc_text) |
| 76 return True | 73 return True |
| 77 | 74 |
| 78 def main(args): | 75 def main(args): |
| 79 try: | 76 try: |
| 80 # Parse input. | 77 # Parse input. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 126 |
| 130 return 0 | 127 return 0 |
| 131 except Exception, inst: | 128 except Exception, inst: |
| 132 sys.stderr.write('gen_library_src_paths.py exception\n') | 129 sys.stderr.write('gen_library_src_paths.py exception\n') |
| 133 sys.stderr.write(str(inst)) | 130 sys.stderr.write(str(inst)) |
| 134 sys.stderr.write('\n') | 131 sys.stderr.write('\n') |
| 135 return -1 | 132 return -1 |
| 136 | 133 |
| 137 if __name__ == '__main__': | 134 if __name__ == '__main__': |
| 138 sys.exit(main(sys.argv)) | 135 sys.exit(main(sys.argv)) |
| OLD | NEW |