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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « icu.gypi ('k') | icu_untrusted.gyp » ('j') | icu_untrusted.gyp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: icu_data_to_c.py
diff --git a/icu_data_to_c.py b/icu_data_to_c.py
new file mode 100755
index 0000000000000000000000000000000000000000..dc10f4a208e11ffe74542cf3e2a29a4326e5b329
--- /dev/null
+++ b/icu_data_to_c.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This scripts generates a compilable .c file from ICU data files. Currently
+# it's used to compile ICU for PNaCl. It's necessary because, unlike other
+# platforms, .S files can't be compiled on PNaCl.
+
+import struct
+import sys
+
+def main():
+ if len(sys.argv) != 3:
+ print "Usage: %s <input> <output>" % sys.argv[0]
+ return 1
+
+ input_file = file(sys.argv[1])
+ output_file = file(sys.argv[2], "w")
+
+ output_file.write(
+"""#include <stdint.h>
+#ifndef U_HIDE_DATA_SYMBOL
+__attribute__((visibility("default")))
+#endif
Mark Mentovai 2013/12/19 18:26:47 #else __attribute__((visibility("hidden")))
Sergey Ulanov 2013/12/20 00:55:21 Removed this script.
+uint32_t icudt46_dat[] = {
Mark Mentovai 2013/12/19 18:26:47 This should absolutely 100% be const.
+""")
+ line_pos = 0
+ while True:
+ data = input_file.read(4096)
+ if len(data) == 0:
+ break
+ for pos in xrange(0, len(data), 4):
+ 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
+ output_file.write(hex(struct.unpack("I", bytes)[0]) + ",")
+ line_pos += 1
+ if line_pos >= 8:
Mark Mentovai 2013/12/19 18:26:47 Make this |if line_pos % 8 == 0:|. Then you can ge
+ output_file.write("\n")
+ line_pos = 0
+
+ output_file.write("\n};")
+ output_file.close()
+
+if __name__ == "__main__":
+ sys.exit(main())
« 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