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

Side by Side Diff: services/icu_data/embed_icu_data.py

Issue 826093004: Support ICU on Android (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address review comments Created 5 years, 11 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7 import sys
8 import hashlib
9
10 in_file = sys.argv[1]
11 out_file = sys.argv[2]
12
13 out_dir = os.path.dirname(out_file)
14
15 data = None
16 with open(in_file, "rb") as f:
17 data = f.read()
18
19 if not os.path.exists(out_dir):
20 os.makedirs(out_dir)
21
22 sha1hash = hashlib.sha1(data).hexdigest()
23
24 values = ["0x%02x" % ord(c) for c in data]
25 lines = []
26 chunk_size = 16
27 for i in range(0, len(values), chunk_size):
28 lines.append(", ".join(values[i: i + chunk_size]))
29
30 with open(out_file, "w") as f:
31 f.write('#include "services/icu_data/data.h"\n')
32 f.write("namespace icu_data {\n")
33 f.write("const char kICUDataTable[] = {\n")
34 f.write(",\n".join(lines))
35 f.write("\n};\n")
36 f.write("const size_t kICUDataTableSize = sizeof(kICUDataTable);\n")
37 f.write("const char kICUDataTableHash[] = \"%s\";\n" % sha1hash)
38 f.write("}\n")
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698