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

Side by Side Diff: icu_data_to_c.py

Issue 109553005: Compile ICU for [P]NaCl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/icu46
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « icu.gypi ('k') | icu_untrusted.gyp » ('j') | icu_untrusted.gyp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 # This scripts generates a compilable .c file from ICU data files. Currently
7 # it's used to compile ICU for PNaCl. It's necessary because, unlike other
8 # platforms, .S files can't be compiled on PNaCl.
9
10 import struct
11 import sys
12
13 def main():
14 if len(sys.argv) != 3:
15 print "Usage: %s <input> <output>" % sys.argv[0]
16 return 1
17
18 input_file = file(sys.argv[1])
19 output_file = file(sys.argv[2], "w")
20
21 output_file.write(
22 """#include <stdint.h>
23 #ifndef U_HIDE_DATA_SYMBOL
24 __attribute__((visibility("default")))
25 #endif
Mark Mentovai 2013/12/19 18:26:47 #else __attribute__((visibility("hidden")))
Sergey Ulanov 2013/12/20 00:55:21 Removed this script.
26 uint32_t icudt46_dat[] = {
Mark Mentovai 2013/12/19 18:26:47 This should absolutely 100% be const.
27 """)
28 line_pos = 0
29 while True:
30 data = input_file.read(4096)
31 if len(data) == 0:
32 break
33 for pos in xrange(0, len(data), 4):
34 bytes = data[pos:pos+4]
Mark Mentovai 2013/12/19 18:26:47 Uh-oh! If len(data) % 4 != 0, the last one of thes
35 output_file.write(hex(struct.unpack("I", bytes)[0]) + ",")
36 line_pos += 1
37 if line_pos >= 8:
Mark Mentovai 2013/12/19 18:26:47 Make this |if line_pos % 8 == 0:|. Then you can ge
38 output_file.write("\n")
39 line_pos = 0
40
41 output_file.write("\n};")
42 output_file.close()
43
44 if __name__ == "__main__":
45 sys.exit(main())
OLDNEW
« no previous file with comments | « icu.gypi ('k') | icu_untrusted.gyp » ('j') | icu_untrusted.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698