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

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

Issue 1416293003: Some cleanups to observatory BUILD.gn (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 | « runtime/observatory/BUILD.gn ('k') | 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 22 matching lines...) Expand all
33 inner_namespace, 33 inner_namespace,
34 name, 34 name,
35 tar_archive, 35 tar_archive,
36 ): 36 ):
37 cc_text = ''' 37 cc_text = '''
38 // Copyright (c) %d, the Dart project authors. Please see the AUTHORS file 38 // Copyright (c) %d, the Dart project authors. Please see the AUTHORS file
39 // for details. All rights reserved. Use of this source code is governed by a 39 // for details. All rights reserved. Use of this source code is governed by a
40 // BSD-style license that can be found in the LICENSE file. 40 // BSD-style license that can be found in the LICENSE file.
41 41
42 ''' % date.today().year 42 ''' % date.today().year
43 cc_text += '''
44
45 #if defined(_WIN32)
46 typedef unsigned __int8 uint8_t;
47 #else
48 #include <inttypes.h>
49 #include <stdint.h>
50 #endif
51 #include <stddef.h>
52
53 '''
43 cc_text += 'namespace %s {\n' % outer_namespace 54 cc_text += 'namespace %s {\n' % outer_namespace
44 if inner_namespace != None: 55 if inner_namespace != None:
45 cc_text += 'namespace %s {\n' % inner_namespace 56 cc_text += 'namespace %s {\n' % inner_namespace
46 cc_text += '\n\n' 57 cc_text += '\n\n'
47 # Write the archive. 58 # Write the archive.
48 cc_text += 'static const char %s_[] = {\n ' % name 59 cc_text += 'static const uint8_t %s_[] = {\n ' % name
49 lineCounter = 0 60 lineCounter = 0
50 for byte in tar_archive: 61 for byte in tar_archive:
51 cc_text += r" '\x%02x'," % ord(byte) 62 cc_text += r" '\x%02x'," % ord(byte)
52 lineCounter += 1 63 lineCounter += 1
53 if lineCounter == 10: 64 if lineCounter == 10:
54 cc_text += '\n ' 65 cc_text += '\n '
55 lineCounter = 0 66 lineCounter = 0
56 if lineCounter != 0: 67 if lineCounter != 0:
57 cc_text += '\n ' 68 cc_text += '\n '
58 cc_text += '};\n' 69 cc_text += '};\n'
59 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))
60 cc_text += '\nconst char* %s = %s_;\n' % (name, name) 71 cc_text += '\nconst uint8_t* %s = %s_;\n' % (name, name)
61 if inner_namespace != None: 72 if inner_namespace != None:
62 cc_text += '} // namespace %s\n' % inner_namespace 73 cc_text += '} // namespace %s\n' % inner_namespace
63 cc_text += '} // namespace %s\n' % outer_namespace 74 cc_text += '} // namespace %s\n' % outer_namespace
64 75
65 open(output_file, 'w').write(cc_text) 76 open(output_file, 'w').write(cc_text)
66 77
67 def main(args): 78 def main(args):
68 try: 79 try:
69 # Parse input. 80 # Parse input.
70 parser = OptionParser() 81 parser = OptionParser()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return 0 142 return 0
132 143
133 except Exception, inst: 144 except Exception, inst:
134 sys.stderr.write('create_resources.py exception\n') 145 sys.stderr.write('create_resources.py exception\n')
135 sys.stderr.write(str(inst)) 146 sys.stderr.write(str(inst))
136 sys.stderr.write('\n') 147 sys.stderr.write('\n')
137 return -1 148 return -1
138 149
139 if __name__ == '__main__': 150 if __name__ == '__main__':
140 sys.exit(main(sys.argv)) 151 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « runtime/observatory/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698