6"""Script to create snapshot bin file."""
11from os.path
import basename, join
17 result = optparse.OptionParser()
22 help=
"path to snapshot generator executable")
27 help=
"kind of snapshot to generate",
34 help=
"pass additional Dart VM flag")
39 help=
"output file name into which vm isolate snapshot in binary form " +
42 "--vm_instructions_output_bin",
45 help=
"output file name into which vm isolate snapshot in binary form " +
48 "--isolate_output_bin",
51 help=
"output file name into which isolate snapshot in binary form " +
54 "--isolate_instructions_output_bin",
57 help=
"output file name into which isolate snapshot in binary form " +
63 help=
"Dart script for which snapshot is to be generated")
68 help=
"package config file used to reasolve package: imports.")
72 help=
'Verbose output.',
79 help=
"Path to timestamp file that will be written",
85 if not options.executable:
86 sys.stderr.write(
'--executable not specified\n')
88 if not options.snapshot_kind:
89 sys.stderr.write(
'--snapshot_kind not specified\n')
91 if not options.vm_output_bin:
92 sys.stderr.write(
'--vm_output_bin not specified\n')
94 if not options.isolate_output_bin:
95 sys.stderr.write(
'--isolate_output_bin not specified\n')
101 if options.timestamp_file !=
'':
102 dir_name = os.path.dirname(options.timestamp_file)
103 if not os.path.exists(dir_name):
105 open(options.timestamp_file,
'w').close()
111 (options, args) = parser.parse_args()
122 script_args = [
"--ignore_unrecognized_flags"]
124 for flag
in options.vm_flag:
125 script_args.append(flag)
129 script_args.append(
''.
join([
"--packages=", options.packages]))
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]))
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
149 script_args.append(options.script)
152 command = [options.executable] + script_args
156 outStream=sys.stderr,
157 errStream=sys.stderr,
158 verbose=options.verbose,
160 except Exception
as e:
169if __name__ ==
'__main__':
def ProcessOptions(options)
def CreateTimestampFile(options)
def RunCommand(command, input=None, pollFn=None, outStream=None, errStream=None, killOnEarlyReturn=True, verbose=False, debug=False, printErrorInfo=False)
static SkString join(const CommandLineFlags::StringArray &)