e6cfe77185
Change DEPS to point at upstream, not chromium's fork. `skia_use_icu` defaults to true everywhere but iOS Clean up SkLoadICU: use U_ICUDATA_ENTRY_POINT, no DLL. Add data dep to icu/icu.gni Scripts: icu/{make_data_assembly.py,make_data_obj_win.py} Scripts: icu/{update_icu.sh,build_icu_data_file.py} for rebuilding document process in icu/README.md Bug: skia:8702 Change-Id: I99789749ba84ae737f6c62475d0d676cd36715bb Reviewed-on: https://skia-review.googlesource.com/c/186870 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Ben Wagner <bungeman@google.com>
58 lines
1.7 KiB
Python
Executable File
58 lines
1.7 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# Copyright 2019 Google LLC.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
'''
|
|
Generate a source file containing the given binary data.
|
|
|
|
File type is either assembly or C++, depending on platform.
|
|
'''
|
|
|
|
import os
|
|
import struct
|
|
import sys
|
|
import mmap
|
|
|
|
def iterate_as_uint32(path):
|
|
with open(path, 'rb') as f:
|
|
s = struct.Struct('@I')
|
|
assert s.size == 4
|
|
mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
|
|
assert (len(mm) % s.size) == 0
|
|
for offset in xrange(0, len(mm), s.size):
|
|
yield s.unpack_from(mm, offset)[0]
|
|
mm.close()
|
|
|
|
|
|
def convert(fmt, name, src_path, dst_path):
|
|
header, line_begin, line_end, footer = fmt
|
|
assert os.path.exists(src_path)
|
|
src = iterate_as_uint32(src_path)
|
|
with open(dst_path, 'w') as o:
|
|
o.write(header.format(name))
|
|
while True:
|
|
line = ','.join('%d' % v for _, v in zip(range(8), src))
|
|
if not line:
|
|
break
|
|
o.write('%s%s%s\n' % (line_begin, line, line_end))
|
|
o.write(footer.format(name))
|
|
|
|
|
|
gcc_asm = ('.globl {0}\n.balign 16\n{0}:\n', '.long ', '', '')
|
|
|
|
cpp = ('#include <cstdint>\nextern "C" uint32_t {0}[] __attribute__((aligned(16))) = {{\n',
|
|
'', ',', '}};\n')
|
|
|
|
def main(name, current_os, target_cpu, src, dst):
|
|
wasm = target_cpu == 'wasm'
|
|
fmt = gcc_asm if not wasm else cpp
|
|
if not wasm and current_os in ['mac', 'ios', 'tvos']:
|
|
name = '_' + name
|
|
convert(fmt, name, src, dst)
|
|
|
|
if __name__ == '__main__':
|
|
print '\n'.join('>>> %r' % x for x in sys.argv)
|
|
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
|