22 result = optparse.OptionParser()
27 help=
"input file name of the vm isolate snapshot in binary form")
32 help=
"input file name of the isolate snapshot in binary form")
37 help=
"input file name which contains the C buffer template")
42 help=
"output file name into which snapshot in C buffer form is generated"
47 help=
'Verbose output.',
54 if not options.vm_input_bin:
55 sys.stderr.write(
'--vm_input_bin not specified\n')
57 if not options.input_bin:
58 sys.stderr.write(
'--input_bin not specified\n')
60 if not options.input_cc:
61 sys.stderr.write(
'--input_cc not specified\n')
63 if not options.output:
64 sys.stderr.write(
'--output not specified\n')
70 """Writes byte contents of the input_file into out file as text.
72 Output is formatted
as a list of comma separated integer values - one value
75 with open(input_file,
'rb')
as input:
78 for byte
in input.read():
79 line +=
' %d,' % ord(byte)
82 out.write(line +
'\n')
86 out.write(line +
'\n')
91 """Generates C++ file based on a input_cc_file template and two binary files
93 Template is expected to have two %s placeholders which would be filled
94 with binary contents of the given files each formatted
as a comma separated
97 snapshot_cc_text = open(input_cc_file).read()
98 chunks = snapshot_cc_text.split("%s")
100 raise Exception(
"Template %s should contain exactly two %%s occurrences"
103 with open(output_file,
'w')
as out:
114 (options, args) = parser.parse_args()
125 options.vm_input_bin, options.input_bin)
130if __name__ ==
'__main__':
static bool read(SkStream *stream, void *buffer, size_t amount)
def ProcessOptions(options)
def WriteBytesAsText(out, input_file)
def GenerateFileFromTemplate(output_file, input_cc_file, vm_isolate_input_file, isolate_input_file)