Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: runtime/tools/create_archive.py

Issue 1411543006: Tweak create_archive.py to output the data as const char instead of const uint8_t (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2015, 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 tar archive and a C++ source file which contains 5 # This python script creates a tar archive and a C++ source file which contains
6 # the tar archive as an array of bytes. 6 # the tar archive as an array of bytes.
7 7
8 import os 8 import os
9 import sys 9 import sys
10 from os.path import join, splitext 10 from os.path import join, splitext
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include <stdint.h> 49 #include <stdint.h>
50 #endif 50 #endif
51 #include <stddef.h> 51 #include <stddef.h>
52 52
53 ''' 53 '''
54 cc_text += 'namespace %s {\n' % outer_namespace 54 cc_text += 'namespace %s {\n' % outer_namespace
55 if inner_namespace != None: 55 if inner_namespace != None:
56 cc_text += 'namespace %s {\n' % inner_namespace 56 cc_text += 'namespace %s {\n' % inner_namespace
57 cc_text += '\n\n' 57 cc_text += '\n\n'
58 # Write the archive. 58 # Write the archive.
59 cc_text += 'static const uint8_t %s_[] = {\n ' % name 59 cc_text += 'static const char %s_[] = {\n ' % name
Ivan Posva 2015/10/28 20:14:51 As discussed let's change this back to uint8_t but
60 lineCounter = 0 60 lineCounter = 0
61 for byte in tar_archive: 61 for byte in tar_archive:
62 cc_text += r" '\x%02x'," % ord(byte) 62 cc_text += r" '\x%02x'," % ord(byte)
63 lineCounter += 1 63 lineCounter += 1
64 if lineCounter == 10: 64 if lineCounter == 10:
65 cc_text += '\n ' 65 cc_text += '\n '
66 lineCounter = 0 66 lineCounter = 0
67 if lineCounter != 0: 67 if lineCounter != 0:
68 cc_text += '\n ' 68 cc_text += '\n '
69 cc_text += '};\n' 69 cc_text += '};\n'
70 cc_text += '\nunsigned int %s_len = %d;\n' % (name, len(tar_archive)) 70 cc_text += '\nunsigned int %s_len = %d;\n' % (name, len(tar_archive))
71 cc_text += '\nconst uint8_t* %s = %s_;\n' % (name, name) 71 cc_text += '\nconst uint8_t* %s = ' % name
72 cc_text += 'reinterpret_cast<const uint8_t*>(&%s_[0]);\n' % name
72 if inner_namespace != None: 73 if inner_namespace != None:
73 cc_text += '} // namespace %s\n' % inner_namespace 74 cc_text += '} // namespace %s\n' % inner_namespace
74 cc_text += '} // namespace %s\n' % outer_namespace 75 cc_text += '} // namespace %s\n' % outer_namespace
75 76
76 open(output_file, 'w').write(cc_text) 77 open(output_file, 'w').write(cc_text)
77 78
78 def main(args): 79 def main(args):
79 try: 80 try:
80 # Parse input. 81 # Parse input.
81 parser = OptionParser() 82 parser = OptionParser()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return 0 143 return 0
143 144
144 except Exception, inst: 145 except Exception, inst:
145 sys.stderr.write('create_resources.py exception\n') 146 sys.stderr.write('create_resources.py exception\n')
146 sys.stderr.write(str(inst)) 147 sys.stderr.write(str(inst))
147 sys.stderr.write('\n') 148 sys.stderr.write('\n')
148 return -1 149 return -1
149 150
150 if __name__ == '__main__': 151 if __name__ == '__main__':
151 sys.exit(main(sys.argv)) 152 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698