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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « icu.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« 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