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

Side by Side Diff: scripts/gen_datS.py

Issue 1967523002: Add big endian support (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: Created 4 years, 7 months 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 | « icu.gyp ('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
(Empty)
1 #!/usr/bin/env python
2
3 import binascii
4 import sys
5
6 if len(sys.argv)<3:
7 print "Provide input and output file names as arguments to use the scrip t!"
8 else:
9 input_file = sys.argv[1];
10 output_file = sys.argv[2];
11
12 input = open(input_file, 'rb').read()
13
14 output = open(output_file, 'w')
15
16 output.write(".globl icudt54_dat\n")
jungshik at Google 2016/05/12 08:52:52 It'd be better to take a major version number as a
jungshik at Google 2016/05/12 17:27:15 Or, a bit hacky approach of reading the major vers
17 output.write("\t.section .note.GNU-stack,\"\",%progbits\n")
18 output.write("\t.section .rodata\n")
19 output.write("\t.balign 16\n")
20 output.write("#ifdef U_HIDE_DATA_SYMBOL\n")
21 output.write("\t.hidden icudt54_dat\n")
22 output.write("#endif\n")
23 output.write("\t.type icudt54_dat,%object\n")
24 output.write("icudt54_dat:\n")
25
26 split = [binascii.hexlify(input[i:i+4]).upper().lstrip('0') for i in ran ge(0, len(input), 4)]
27
28 for i in range(len(split)):
29 if (len(split[i])==0):
30 split[i]='0'
31 elif (len(split[i])==1):
32 if not any((c in '123456789') for c in split[i]):
33 split[i]='0x0'+split[i]
34 elif (len(split[i])%2==1):
35 split[i]='0x0'+split[i]
36 else:
37 split[i]='0x'+split[i]
38
39 for i in range(len(split)):
jungshik at Google 2016/05/12 08:52:52 Can't you just combine this for-loop with the prev
40 if (i%32==0):
41 output.write("\n.long ")
42 else:
43 output.write(",")
44 output.write(split[i])
45
46 output.write("\n")
47 output.close()
OLDNEW
« no previous file with comments | « icu.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698