Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
create_string_literal Namespace Reference

Functions

 makeString (input_files)
 
 makeFile (output_file, input_cc_file, include, var_name, input_files)
 
 main (args)
 

Function Documentation

◆ main()

create_string_literal.main (   args)

Definition at line 46 of file create_string_literal.py.

46def main(args):
47 try:
48 # Parse input.
49 parser = OptionParser()
50 parser.add_option(
51 "--output", action="store", type="string", help="output file name")
52 parser.add_option(
53 "--input_cc",
54 action="store",
55 type="string",
56 help="input template file")
57 parser.add_option(
58 "--include", action="store", type="string", help="variable name")
59 parser.add_option(
60 "--var_name", action="store", type="string", help="variable name")
61
62 (options, args) = parser.parse_args()
63 if not options.output:
64 sys.stderr.write('--output not specified\n')
65 return -1
66 if not len(options.input_cc):
67 sys.stderr.write('--input_cc not specified\n')
68 return -1
69 if not len(options.include):
70 sys.stderr.write('--include not specified\n')
71 return -1
72 if not len(options.var_name):
73 sys.stderr.write('--var_name not specified\n')
74 return -1
75 if len(args) == 0:
76 sys.stderr.write('No input files specified\n')
77 return -1
78
79 files = []
80 for arg in args:
81 files.append(arg)
82
83 if not makeFile(options.output, options.input_cc, options.include,
84 options.var_name, files):
85 return -1
86
87 return 0
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')
92 return -1
93
94
Definition main.py:1

◆ makeFile()

create_string_literal.makeFile (   output_file,
  input_cc_file,
  include,
  var_name,
  input_files 
)

Definition at line 36 of file create_string_literal.py.

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}}",
41 makeString(input_files))
42 open(output_file, 'w').write(bootstrap_cc_text)
43 return True
44
45
static bool read(SkStream *stream, void *buffer, size_t amount)
void write(SkWStream *wStream, const T &text)
Definition skqp.cpp:188

◆ makeString()

create_string_literal.makeString (   input_files)

Definition at line 17 of file create_string_literal.py.

17def makeString(input_files):
18 result = ' '
19 for string_file in input_files:
20 if string_file.endswith('dart'):
21 fileHandle = open(string_file, 'rb')
22 lineCounter = 0
23 result += ' // ' + string_file + '\n '
24 for byte in fileHandle.read():
25 result += ' %d,' % ord(byte)
26 lineCounter += 1
27 if lineCounter == 10:
28 result += '\n '
29 lineCounter = 0
30 if lineCounter != 0:
31 result += '\n '
32 result += ' // Terminating null character.\n 0'
33 return result
34
35