OLD | NEW |
---|---|
(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() | |
OLD | NEW |