Flutter Engine
The Flutter Engine
Functions
create_snapshot_bin Namespace Reference

Functions

def BuildOptions ()
 
def ProcessOptions (options)
 
def CreateTimestampFile (options)
 
def Main ()
 

Function Documentation

◆ BuildOptions()

def create_snapshot_bin.BuildOptions ( )

Definition at line 16 of file create_snapshot_bin.py.

16def BuildOptions():
17 result = optparse.OptionParser()
18 result.add_option(
19 "--executable",
20 action="store",
21 type="string",
22 help="path to snapshot generator executable")
23 result.add_option(
24 "--snapshot_kind",
25 action="store",
26 type="string",
27 help="kind of snapshot to generate",
28 default="core")
29 result.add_option(
30 "--vm_flag",
31 action="append",
32 type="string",
33 default=[],
34 help="pass additional Dart VM flag")
35 result.add_option(
36 "--vm_output_bin",
37 action="store",
38 type="string",
39 help="output file name into which vm isolate snapshot in binary form " +
40 "is generated")
41 result.add_option(
42 "--vm_instructions_output_bin",
43 action="store",
44 type="string",
45 help="output file name into which vm isolate snapshot in binary form " +
46 "is generated")
47 result.add_option(
48 "--isolate_output_bin",
49 action="store",
50 type="string",
51 help="output file name into which isolate snapshot in binary form " +
52 "is generated")
53 result.add_option(
54 "--isolate_instructions_output_bin",
55 action="store",
56 type="string",
57 help="output file name into which isolate snapshot in binary form " +
58 "is generated")
59 result.add_option(
60 "--script",
61 action="store",
62 type="string",
63 help="Dart script for which snapshot is to be generated")
64 result.add_option(
65 "--packages",
66 action="store",
67 type="string",
68 help="package config file used to reasolve package: imports.")
69 result.add_option(
70 "-v",
71 "--verbose",
72 help='Verbose output.',
73 default=False,
74 action="store_true")
75 result.add_option(
76 "--timestamp_file",
77 action="store",
78 type="string",
79 help="Path to timestamp file that will be written",
80 default="")
81 return result
82
83

◆ CreateTimestampFile()

def create_snapshot_bin.CreateTimestampFile (   options)

Definition at line 100 of file create_snapshot_bin.py.

100def CreateTimestampFile(options):
101 if options.timestamp_file != '':
102 dir_name = os.path.dirname(options.timestamp_file)
103 if not os.path.exists(dir_name):
104 os.mkdir(dir_name)
105 open(options.timestamp_file, 'w').close()
106
107
def CreateTimestampFile(options)

◆ Main()

def create_snapshot_bin.Main ( )

Definition at line 108 of file create_snapshot_bin.py.

108def Main():
109 # Parse options.
110 parser = BuildOptions()
111 (options, args) = parser.parse_args()
112 if not ProcessOptions(options):
113 parser.print_help()
114 return 1
115
116 # If there are additional arguments, report error and exit.
117 if args:
118 parser.print_help()
119 return 1
120
121 # Setup arguments to the snapshot generator binary.
122 script_args = ["--ignore_unrecognized_flags"]
123
124 for flag in options.vm_flag:
125 script_args.append(flag)
126
127 # Pass along the packages if there is one.
128 if options.packages:
129 script_args.append(''.join(["--packages=", options.packages]))
130
131 # First setup the vm isolate and regular isolate snapshot output filename.
132 script_args.append(''.join(["--snapshot_kind=", options.snapshot_kind]))
133 script_args.append(''.join(["--vm_snapshot_data=", options.vm_output_bin]))
134 script_args.append(''.join(
135 ["--isolate_snapshot_data=", options.isolate_output_bin]))
136
137 if options.vm_instructions_output_bin != None:
138 script_args.append(''.join(
139 ["--vm_snapshot_instructions=",
140 options.vm_instructions_output_bin]))
141 if options.isolate_instructions_output_bin != None:
142 script_args.append(''.join([
143 "--isolate_snapshot_instructions=",
144 options.isolate_instructions_output_bin
145 ]))
146
147 # Finally append the script name if one is specified.
148 if options.script:
149 script_args.append(options.script)
150
151 # Construct command line to execute the snapshot generator binary and invoke.
152 command = [options.executable] + script_args
153 try:
155 command,
156 outStream=sys.stderr,
157 errStream=sys.stderr,
158 verbose=options.verbose,
159 printErrorInfo=True)
160 except Exception as e:
161 return -1
162
163 # Success, update timestamp file.
164 CreateTimestampFile(options)
165
166 return 0
167
168
def RunCommand(command, input=None, pollFn=None, outStream=None, errStream=None, killOnEarlyReturn=True, verbose=False, debug=False, printErrorInfo=False)
Definition: utils.py:160
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ ProcessOptions()

def create_snapshot_bin.ProcessOptions (   options)

Definition at line 84 of file create_snapshot_bin.py.

84def ProcessOptions(options):
85 if not options.executable:
86 sys.stderr.write('--executable not specified\n')
87 return False
88 if not options.snapshot_kind:
89 sys.stderr.write('--snapshot_kind not specified\n')
90 return False
91 if not options.vm_output_bin:
92 sys.stderr.write('--vm_output_bin not specified\n')
93 return False
94 if not options.isolate_output_bin:
95 sys.stderr.write('--isolate_output_bin not specified\n')
96 return False
97 return True
98
99