| 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) 2014, 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 from __future__ import with_statement | 6 from __future__ import with_statement |
| 7 import StringIO | 7 import StringIO |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 class GenerateError(Exception): | 11 class GenerateError(Exception): |
| 12 | 12 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 old_text = f.read() | 87 old_text = f.read() |
| 88 if old_text == new_text: | 88 if old_text == new_text: |
| 89 return | 89 return |
| 90 sys.stderr.write('Updating %s\n' % file_name) | 90 sys.stderr.write('Updating %s\n' % file_name) |
| 91 with open(file_name, 'w') as f: | 91 with open(file_name, 'w') as f: |
| 92 f.write(new_text) | 92 f.write(new_text) |
| 93 | 93 |
| 94 def generate(self): | 94 def generate(self): |
| 95 self._list_files() | 95 self._list_files() |
| 96 | 96 |
| 97 file_name = self.output + '.gypi'; | 97 file_name = self.output + '.gypi' |
| 98 gypi = self._make_output(file_name) | 98 gypi = self._make_output(file_name) |
| 99 gypi.write("{\n 'variables': {\n") | 99 gypi.write("{\n 'variables': {\n") |
| 100 self._print_gypi_files(gypi, self.name + '_sources', self.sources) | 100 self._print_gypi_files(gypi, self.name + '_sources', self.sources) |
| 101 self._print_gypi_files(gypi, self.name + '_resources', self.resources) | 101 self._print_gypi_files(gypi, self.name + '_resources', self.resources) |
| 102 gypi.write(" },\n}\n") | 102 gypi.write(" },\n}\n") |
| 103 self._close(file_name, gypi) | 103 self._close(file_name, gypi) |
| 104 | 104 |
| 105 file_name = self.output + '.xml' | 105 file_name = self.output + '.xml' |
| 106 ant = self._make_output(file_name) | 106 ant = self._make_output(file_name) |
| 107 ant.write("<project>\n") | 107 ant.write("<project>\n") |
| 108 self._print_ant_files(ant, self.name + '_sources', self.sources) | 108 self._print_ant_files(ant, self.name + '_sources', self.sources) |
| 109 self._print_ant_files(ant, self.name + '_resources', self.resources) | 109 self._print_ant_files(ant, self.name + '_resources', self.resources) |
| 110 ant.write("</project>\n") | 110 ant.write("</project>\n") |
| 111 self._close(file_name, ant) | 111 self._close(file_name, ant) |
| 112 | 112 |
| 113 file_name = self.output + '.txt'; | 113 file_name = self.output + '.txt' |
| 114 txt = self._make_output(file_name) | 114 txt = self._make_output(file_name) |
| 115 self._print_txt_files(txt, self.sources) | 115 self._print_txt_files(txt, self.sources) |
| 116 self._close(file_name, txt) | 116 self._close(file_name, txt) |
| 117 | 117 |
| 118 | 118 |
| 119 def Main(script_name = None, name = None, output = None, path = None, | 119 def Main(script_name = None, name = None, output = None, path = None, |
| 120 *rest): | 120 *rest): |
| 121 if not path: | 121 if not path: |
| 122 raise GenerateError("usage: %s NAME OUTPUT PATH EXCLUDE_DIR_NAME ..." | 122 raise GenerateError("usage: %s NAME OUTPUT PATH EXCLUDE_DIR_NAME ..." |
| 123 % script_name) | 123 % script_name) |
| 124 base_directory = os.path.dirname(output) | 124 base_directory = os.path.dirname(output) |
| 125 Generator(base_directory, name, output, path, *rest).generate() | 125 Generator(base_directory, name, output, path, *rest).generate() |
| 126 | 126 |
| 127 | 127 |
| 128 if __name__ == '__main__': | 128 if __name__ == '__main__': |
| 129 sys.exit(Main(*sys.argv)) | 129 sys.exit(Main(*sys.argv)) |
| OLD | NEW |