| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 """Script to create snapshot bin file.""" | 7 """Script to create snapshot bin file.""" |
| 8 | 8 |
| 9 import getopt | 9 import getopt |
| 10 import optparse | 10 import optparse |
| 11 import os | 11 import os |
| 12 from os.path import basename, join | 12 from os.path import basename, join |
| 13 import sys | 13 import sys |
| 14 import utils | 14 import utils |
| 15 | 15 |
| 16 | 16 |
| 17 def BuildOptions(): | 17 def BuildOptions(): |
| 18 result = optparse.OptionParser() | 18 result = optparse.OptionParser() |
| 19 result.add_option("--executable", | 19 result.add_option("--executable", |
| 20 action="store", type="string", | 20 action="store", type="string", |
| 21 help="path to snapshot generator executable") | 21 help="path to snapshot generator executable") |
| 22 result.add_option("--snapshot_kind", | 22 result.add_option("--snapshot_kind", |
| 23 action="store", type="string", | 23 action="store", type="string", |
| 24 help="kind of snapshot to generate", | 24 help="kind of snapshot to generate", |
| 25 default="core") | 25 default="core") |
| 26 result.add_option("--load_compilation_trace", |
| 27 action="store", type="string", |
| 28 help="path to a compilation trace to load before generating a core-jit sna
pshot") |
| 29 result.add_option("--vm_flag", |
| 30 action="append", type="string", default=[], |
| 31 help="pass additional Dart VM flag") |
| 26 result.add_option("--vm_output_bin", | 32 result.add_option("--vm_output_bin", |
| 27 action="store", type="string", | 33 action="store", type="string", |
| 28 help="output file name into which vm isolate snapshot in binary form " + | 34 help="output file name into which vm isolate snapshot in binary form " + |
| 29 "is generated") | 35 "is generated") |
| 30 result.add_option("--vm_instructions_output_bin", | 36 result.add_option("--vm_instructions_output_bin", |
| 31 action="store", type="string", | 37 action="store", type="string", |
| 32 help="output file name into which vm isolate snapshot in binary form " + | 38 help="output file name into which vm isolate snapshot in binary form " + |
| 33 "is generated") | 39 "is generated") |
| 34 result.add_option("--isolate_output_bin", | 40 result.add_option("--isolate_output_bin", |
| 35 action="store", type="string", | 41 action="store", type="string", |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if not ProcessOptions(options): | 111 if not ProcessOptions(options): |
| 106 parser.print_help() | 112 parser.print_help() |
| 107 return 1 | 113 return 1 |
| 108 | 114 |
| 109 # If there are additional arguments, report error and exit. | 115 # If there are additional arguments, report error and exit. |
| 110 if args: | 116 if args: |
| 111 parser.print_help() | 117 parser.print_help() |
| 112 return 1 | 118 return 1 |
| 113 | 119 |
| 114 # Setup arguments to the snapshot generator binary. | 120 # Setup arguments to the snapshot generator binary. |
| 115 script_args = ["--ignore_unrecognized_flags" ] | 121 script_args = ["--ignore_unrecognized_flags"] |
| 122 |
| 123 for flag in options.vm_flag: |
| 124 script_args.append(flag) |
| 125 |
| 126 if options.load_compilation_trace: |
| 127 script_args.append(''.join([ "--load_compilation_trace=", options.load_compi
lation_trace])) |
| 116 | 128 |
| 117 # Pass along the package_root if there is one. | 129 # Pass along the package_root if there is one. |
| 118 if options.package_root: | 130 if options.package_root: |
| 119 script_args.append(''.join([ "--package_root=", options.package_root])) | 131 script_args.append(''.join([ "--package_root=", options.package_root])) |
| 120 | 132 |
| 121 # Pass along the packages if there is one. | 133 # Pass along the packages if there is one. |
| 122 if options.packages: | 134 if options.packages: |
| 123 script_args.append(''.join([ "--packages=", options.packages])) | 135 script_args.append(''.join([ "--packages=", options.packages])) |
| 124 | 136 |
| 125 # First setup the vm isolate and regular isolate snapshot output filename. | 137 # First setup the vm isolate and regular isolate snapshot output filename. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 return -1 | 169 return -1 |
| 158 | 170 |
| 159 # Success, update timestamp file. | 171 # Success, update timestamp file. |
| 160 CreateTimestampFile(options) | 172 CreateTimestampFile(options) |
| 161 | 173 |
| 162 return 0 | 174 return 0 |
| 163 | 175 |
| 164 | 176 |
| 165 if __name__ == '__main__': | 177 if __name__ == '__main__': |
| 166 sys.exit(Main()) | 178 sys.exit(Main()) |
| OLD | NEW |