Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
gen_library_src_paths Namespace Reference

Functions

 makeString (input_file, var_name)
 
 makeSourceArrays (in_files)
 
 makeFile (output_file, input_cc_file, include, var_name, lib_name, in_files)
 
 main (args)
 

Variables

 HOST_OS = utils.GuessOS()
 

Function Documentation

◆ main()

gen_library_src_paths.main (   args)

Definition at line 79 of file gen_library_src_paths.py.

79def main(args):
80 try:
81 # Parse input.
82 parser = OptionParser()
83 parser.add_option(
84 "--output", action="store", type="string", help="output file name")
85 parser.add_option(
86 "--input_cc",
87 action="store",
88 type="string",
89 help="input template file")
90 parser.add_option(
91 "--include", action="store", type="string", help="variable name")
92 parser.add_option(
93 "--library_name",
94 action="store",
95 type="string",
96 help="library name")
97 parser.add_option(
98 "--var_name", action="store", type="string", help="variable name")
99
100 (options, args) = parser.parse_args()
101 if not options.output:
102 sys.stderr.write('--output not specified\n')
103 return -1
104 if not len(options.input_cc):
105 sys.stderr.write('--input_cc not specified\n')
106 return -1
107 if not len(options.include):
108 sys.stderr.write('--include not specified\n')
109 return -1
110 if not len(options.var_name):
111 sys.stderr.write('--var_name not specified\n')
112 return -1
113 if not len(options.library_name):
114 sys.stderr.write('--library_name not specified\n')
115 return -1
116 if len(args) == 0:
117 sys.stderr.write('No input files specified\n')
118 return -1
119
120 files = []
121 for arg in args:
122 files.append(arg)
123
124 if not makeFile(options.output, options.input_cc, options.include,
125 options.var_name, options.library_name, files):
126 return -1
127
128 return 0
129 except Exception as inst:
130 sys.stderr.write('gen_library_src_paths.py exception\n')
131 sys.stderr.write(str(inst))
132 sys.stderr.write('\n')
133 return -1
134
135
Definition main.py:1

◆ makeFile()

gen_library_src_paths.makeFile (   output_file,
  input_cc_file,
  include,
  var_name,
  lib_name,
  in_files 
)

Definition at line 45 of file gen_library_src_paths.py.

45def makeFile(output_file, input_cc_file, include, var_name, lib_name, in_files):
46 part_index = []
47 bootstrap_cc_text = open(input_cc_file).read()
48 bootstrap_cc_text = bootstrap_cc_text.replace("{{SOURCE_ARRAYS}}",
49 makeSourceArrays(in_files))
50 bootstrap_cc_text = bootstrap_cc_text.replace("{{INCLUDE}}", include)
51 bootstrap_cc_text = bootstrap_cc_text.replace("{{VAR_NAME}}", var_name)
52 main_file_found = False
53 file_count = 0
54 for string_file in in_files:
55 if string_file.endswith('.dart'):
56 file_count += 1
57 if (not main_file_found):
58 inpt = open(string_file, 'r')
59 for line in inpt:
60 # File with library tag is the main file.
61 if line.startswith('library '):
62 main_file_found = True
63 bootstrap_cc_text = bootstrap_cc_text.replace(
64 "{{LIBRARY_SOURCE_MAP}}", ' "' + lib_name + '",\n' +
65 ' source_array_' + str(file_count) + ',\n')
66 inpt.close()
67 if (main_file_found):
68 continue
69 part_index.append(' "' + lib_name + "/" + os.path.basename(
70 string_file).replace('\\', '\\\\') + '",\n')
71 part_index.append(' source_array_' + str(file_count) + ',\n\n')
72 bootstrap_cc_text = bootstrap_cc_text.replace("{{LIBRARY_SOURCE_MAP}}", '')
73 bootstrap_cc_text = bootstrap_cc_text.replace("{{PART_SOURCE_MAP}}",
74 ''.join(part_index))
75 open(output_file, 'w').write(bootstrap_cc_text)
76 return True
77
78
static bool read(SkStream *stream, void *buffer, size_t amount)
void write(SkWStream *wStream, const T &text)
Definition skqp.cpp:188

◆ makeSourceArrays()

gen_library_src_paths.makeSourceArrays (   in_files)

Definition at line 33 of file gen_library_src_paths.py.

33def makeSourceArrays(in_files):
34 result = ''
35 file_count = 0
36 for string_file in in_files:
37 if string_file.endswith('.dart'):
38 file_count += 1
39 file_string = makeString(string_file,
40 "source_array_" + str(file_count))
41 result += file_string
42 return result
43
44

◆ makeString()

gen_library_src_paths.makeString (   input_file,
  var_name 
)

Definition at line 19 of file gen_library_src_paths.py.

19def makeString(input_file, var_name):
20 result = 'static const char ' + var_name + '[] = {\n '
21 fileHandle = open(input_file, 'rb')
22 lineCounter = 0
23 for byte in fileHandle.read():
24 result += '\'\\x%02x' % ord(byte) + '\', '
25 lineCounter += 1
26 if lineCounter == 19:
27 result += '\n '
28 lineCounter = 0
29 result += '0};\n'
30 return result
31
32

Variable Documentation

◆ HOST_OS

gen_library_src_paths.HOST_OS = utils.GuessOS()

Definition at line 16 of file gen_library_src_paths.py.