Chromium Code Reviews| Index: scripts/gen_datS.py |
| diff --git a/scripts/gen_datS.py b/scripts/gen_datS.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..73fc4cb6b2cffa73e126d89db764a528529e9828 |
| --- /dev/null |
| +++ b/scripts/gen_datS.py |
| @@ -0,0 +1,47 @@ |
| +#!/usr/bin/env python |
| + |
| +import binascii |
| +import sys |
| + |
| +if len(sys.argv)<3: |
| + print "Provide input and output file names as arguments to use the script!" |
| +else: |
| + input_file = sys.argv[1]; |
| + output_file = sys.argv[2]; |
| + |
| + input = open(input_file, 'rb').read() |
| + |
| + output = open(output_file, 'w') |
| + |
| + 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
|
| + output.write("\t.section .note.GNU-stack,\"\",%progbits\n") |
| + output.write("\t.section .rodata\n") |
| + output.write("\t.balign 16\n") |
| + output.write("#ifdef U_HIDE_DATA_SYMBOL\n") |
| + output.write("\t.hidden icudt54_dat\n") |
| + output.write("#endif\n") |
| + output.write("\t.type icudt54_dat,%object\n") |
| + output.write("icudt54_dat:\n") |
| + |
| + split = [binascii.hexlify(input[i:i+4]).upper().lstrip('0') for i in range(0, len(input), 4)] |
| + |
| + for i in range(len(split)): |
| + if (len(split[i])==0): |
| + split[i]='0' |
| + elif (len(split[i])==1): |
| + if not any((c in '123456789') for c in split[i]): |
| + split[i]='0x0'+split[i] |
| + elif (len(split[i])%2==1): |
| + split[i]='0x0'+split[i] |
| + else: |
| + split[i]='0x'+split[i] |
| + |
| + 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
|
| + if (i%32==0): |
| + output.write("\n.long ") |
| + else: |
| + output.write(",") |
| + output.write(split[i]) |
| + |
| + output.write("\n") |
| + output.close() |