| 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 |
| 11 import utils |
| 11 | 12 |
| 12 from os.path import join | 13 from os.path import join |
| 13 from optparse import OptionParser | 14 from optparse import OptionParser |
| 14 | 15 |
| 16 HOST_OS = utils.GuessOS() |
| 17 |
| 15 | 18 |
| 16 def makeString(input_file): | 19 def makeString(input_file): |
| 20 # TODO(iposva): For now avoid creating overly long strings on Windows. |
| 21 if HOST_OS == 'win32': |
| 22 return 'NULL' |
| 17 result = '"' | 23 result = '"' |
| 18 fileHandle = open(input_file, 'rb') | 24 fileHandle = open(input_file, 'rb') |
| 19 lineCounter = 0 | 25 lineCounter = 0 |
| 20 for byte in fileHandle.read(): | 26 for byte in fileHandle.read(): |
| 21 result += '\\x%02x' % ord(byte) | 27 result += '\\x%02x' % ord(byte) |
| 22 lineCounter += 1 | 28 lineCounter += 1 |
| 23 if lineCounter == 19: | 29 if lineCounter == 19: |
| 24 result += '"\n "' | 30 result += '"\n "' |
| 25 lineCounter = 0 | 31 lineCounter = 0 |
| 26 result += '"' | 32 result += '"' |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 121 |
| 116 return 0 | 122 return 0 |
| 117 except Exception, inst: | 123 except Exception, inst: |
| 118 sys.stderr.write('gen_library_src_paths.py exception\n') | 124 sys.stderr.write('gen_library_src_paths.py exception\n') |
| 119 sys.stderr.write(str(inst)) | 125 sys.stderr.write(str(inst)) |
| 120 sys.stderr.write('\n') | 126 sys.stderr.write('\n') |
| 121 return -1 | 127 return -1 |
| 122 | 128 |
| 123 if __name__ == '__main__': | 129 if __name__ == '__main__': |
| 124 sys.exit(main(sys.argv)) | 130 sys.exit(main(sys.argv)) |
| OLD | NEW |