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

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

Issue 1419263004: Update create_archve.py to output a uint8_t array (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 char %s_[] = {\n ' % name 59 cc_text += 'static const uint8_t %s_[] = {\n ' % name
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" %d," % 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};\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 = ' % name 71 cc_text += '\nconst uint8_t* %s = %s_;\n\n' % (name, name)
72 cc_text += 'reinterpret_cast<const uint8_t*>(&%s_[0]);\n' % name
73 if inner_namespace != None: 72 if inner_namespace != None:
74 cc_text += '} // namespace %s\n' % inner_namespace 73 cc_text += '} // namespace %s\n' % inner_namespace
75 cc_text += '} // namespace %s\n' % outer_namespace 74 cc_text += '} // namespace %s\n' % outer_namespace
76 75
77 open(output_file, 'w').write(cc_text) 76 open(output_file, 'w').write(cc_text)
78 77
79 def main(args): 78 def main(args):
80 try: 79 try:
81 # Parse input. 80 # Parse input.
82 parser = OptionParser() 81 parser = OptionParser()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return 0 142 return 0
144 143
145 except Exception, inst: 144 except Exception, inst:
146 sys.stderr.write('create_resources.py exception\n') 145 sys.stderr.write('create_resources.py exception\n')
147 sys.stderr.write(str(inst)) 146 sys.stderr.write(str(inst))
148 sys.stderr.write('\n') 147 sys.stderr.write('\n')
149 return -1 148 return -1
150 149
151 if __name__ == '__main__': 150 if __name__ == '__main__':
152 sys.exit(main(sys.argv)) 151 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