12from os.path
import join
14from optparse
import OptionParser
19 for string_file
in input_files:
20 if string_file.endswith(
'dart'):
21 fileHandle = open(string_file,
'rb')
23 result +=
' // ' + string_file +
'\n '
24 for byte
in fileHandle.read():
25 result +=
' %d,' % ord(byte)
32 result +=
' // Terminating null character.\n 0'
36def makeFile(output_file, input_cc_file, include, var_name, input_files):
37 bootstrap_cc_text = open(input_cc_file).
read()
38 bootstrap_cc_text = bootstrap_cc_text.replace(
"{{INCLUDE}}", include)
39 bootstrap_cc_text = bootstrap_cc_text.replace(
"{{VAR_NAME}}", var_name)
40 bootstrap_cc_text = bootstrap_cc_text.replace(
"{{DART_SOURCE}}",
42 open(output_file,
'w').
write(bootstrap_cc_text)
49 parser = OptionParser()
51 "--output", action=
"store", type=
"string", help=
"output file name")
56 help=
"input template file")
58 "--include", action=
"store", type=
"string", help=
"variable name")
60 "--var_name", action=
"store", type=
"string", help=
"variable name")
62 (options, args) = parser.parse_args()
63 if not options.output:
64 sys.stderr.write(
'--output not specified\n')
66 if not len(options.input_cc):
67 sys.stderr.write(
'--input_cc not specified\n')
69 if not len(options.include):
70 sys.stderr.write(
'--include not specified\n')
72 if not len(options.var_name):
73 sys.stderr.write(
'--var_name not specified\n')
76 sys.stderr.write(
'No input files specified\n')
83 if not makeFile(options.output, options.input_cc, options.include,
84 options.var_name, files):
88 except Exception
as inst:
89 sys.stderr.write(
'create_string_literal.py exception\n')
90 sys.stderr.write(str(inst))
91 sys.stderr.write(
'\n')
95if __name__ ==
'__main__':
96 sys.exit(
main(sys.argv))
static bool read(SkStream *stream, void *buffer, size_t amount)
def makeFile(output_file, input_cc_file, include, var_name, input_files)
def makeString(input_files)
void write(SkWStream *wStream, const T &text)