| 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 HOST_OS = utils.GuessOS() | 17 HOST_OS = utils.GuessOS() |
| 18 HOST_CPUS = utils.GuessCpus() | 18 HOST_CPUS = utils.GuessCpus() |
| 19 DEBUG = False | 19 DEBUG = False |
| 20 VERBOSE = False | 20 VERBOSE = False |
| 21 | 21 |
| 22 def BuildOptions(): | 22 def BuildOptions(): |
| 23 result = optparse.OptionParser() | 23 result = optparse.OptionParser() |
| 24 result.add_option("--executable", | 24 result.add_option("--executable", |
| 25 action="store", type="string", | 25 action="store", type="string", |
| 26 help="path to snapshot generator executable") | 26 help="path to snapshot generator executable") |
| 27 result.add_option("--snapshot_kind", |
| 28 action="store", type="string", |
| 29 help="kind of snapshot to generate", |
| 30 default="core") |
| 27 result.add_option("--vm_output_bin", | 31 result.add_option("--vm_output_bin", |
| 28 action="store", type="string", | 32 action="store", type="string", |
| 29 help="output file name into which vm isolate snapshot in binary form " + | 33 help="output file name into which vm isolate snapshot in binary form " + |
| 30 "is generated") | 34 "is generated") |
| 31 result.add_option("--output_bin", | 35 result.add_option("--isolate_output_bin", |
| 32 action="store", type="string", | 36 action="store", type="string", |
| 33 help="output file name into which isolate snapshot in binary form " + | 37 help="output file name into which isolate snapshot in binary form " + |
| 34 "is generated") | 38 "is generated") |
| 35 result.add_option("--embedder_entry_points_manifest", | 39 result.add_option("--embedder_entry_points_manifest", |
| 36 action="store", type="string", | 40 action="store", type="string", |
| 37 help="input manifest with the vm entry points in a precompiled snapshot") | 41 help="input manifest with the vm entry points in a precompiled snapshot") |
| 38 result.add_option("--script", | 42 result.add_option("--script", |
| 39 action="store", type="string", | 43 action="store", type="string", |
| 40 help="Dart script for which snapshot is to be generated") | 44 help="Dart script for which snapshot is to be generated") |
| 41 result.add_option("--package_root", | 45 result.add_option("--package_root", |
| (...skipping 20 matching lines...) Expand all Loading... |
| 62 action="store", type="string", | 66 action="store", type="string", |
| 63 help="Path to timestamp file that will be written", | 67 help="Path to timestamp file that will be written", |
| 64 default="") | 68 default="") |
| 65 return result | 69 return result |
| 66 | 70 |
| 67 | 71 |
| 68 def ProcessOptions(options): | 72 def ProcessOptions(options): |
| 69 if not options.executable: | 73 if not options.executable: |
| 70 sys.stderr.write('--executable not specified\n') | 74 sys.stderr.write('--executable not specified\n') |
| 71 return False | 75 return False |
| 76 if not options.snapshot_kind: |
| 77 sys.stderr.write('--snapshot_kind not specified\n') |
| 78 return False |
| 72 if not options.vm_output_bin: | 79 if not options.vm_output_bin: |
| 73 sys.stderr.write('--vm_output_bin not specified\n') | 80 sys.stderr.write('--vm_output_bin not specified\n') |
| 74 return False | 81 return False |
| 75 if not options.output_bin: | 82 if not options.isolate_output_bin: |
| 76 sys.stderr.write('--output_bin not specified\n') | 83 sys.stderr.write('--isolate_output_bin not specified\n') |
| 77 return False | 84 return False |
| 78 if options.abi and not options.target_os == 'android': | 85 if options.abi and not options.target_os == 'android': |
| 79 sys.stderr.write('--abi requires --target_os android\n') | 86 sys.stderr.write('--abi requires --target_os android\n') |
| 80 return False | 87 return False |
| 81 return True | 88 return True |
| 82 | 89 |
| 83 | 90 |
| 84 def CreateTimestampFile(options): | 91 def CreateTimestampFile(options): |
| 85 if options.timestamp_file != '': | 92 if options.timestamp_file != '': |
| 86 dir_name = os.path.dirname(options.timestamp_file) | 93 dir_name = os.path.dirname(options.timestamp_file) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 109 | 116 |
| 110 # Pass along the package_root if there is one. | 117 # Pass along the package_root if there is one. |
| 111 if options.package_root: | 118 if options.package_root: |
| 112 script_args.append(''.join([ "--package_root=", options.package_root])) | 119 script_args.append(''.join([ "--package_root=", options.package_root])) |
| 113 | 120 |
| 114 # Pass along the packages if there is one. | 121 # Pass along the packages if there is one. |
| 115 if options.packages: | 122 if options.packages: |
| 116 script_args.append(''.join([ "--packages=", options.packages])) | 123 script_args.append(''.join([ "--packages=", options.packages])) |
| 117 | 124 |
| 118 # First setup the vm isolate and regular isolate snapshot output filename. | 125 # First setup the vm isolate and regular isolate snapshot output filename. |
| 126 script_args.append(''.join([ "--snapshot_kind=", options.snapshot_kind ])) |
| 119 script_args.append(''.join([ "--vm_snapshot_data=", options.vm_output_bin ])) | 127 script_args.append(''.join([ "--vm_snapshot_data=", options.vm_output_bin ])) |
| 120 script_args.append(''.join([ "--isolate_snapshot_data=", options.output_bin ])
) | 128 script_args.append(''.join([ "--isolate_snapshot_data=", options.isolate_outpu
t_bin ])) |
| 121 | 129 |
| 122 # Specify the embedder entry points snapshot | 130 # Specify the embedder entry points snapshot |
| 123 if options.embedder_entry_points_manifest: | 131 if options.embedder_entry_points_manifest: |
| 124 script_args.append(''.join([ "--embedder_entry_points_manifest=", | 132 script_args.append(''.join([ "--embedder_entry_points_manifest=", |
| 125 options.embedder_entry_points_manifest ])) | 133 options.embedder_entry_points_manifest ])) |
| 126 | 134 |
| 127 # Next setup all url mapping options specified. | 135 # Next setup all url mapping options specified. |
| 128 for url_arg in options.url_mapping: | 136 for url_arg in options.url_mapping: |
| 129 url_mapping_argument = ''.join(["--url_mapping=", url_arg ]) | 137 url_mapping_argument = ''.join(["--url_mapping=", url_arg ]) |
| 130 script_args.append(url_mapping_argument) | 138 script_args.append(url_mapping_argument) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 142 return -1 | 150 return -1 |
| 143 | 151 |
| 144 # Success, update timestamp file. | 152 # Success, update timestamp file. |
| 145 CreateTimestampFile(options) | 153 CreateTimestampFile(options) |
| 146 | 154 |
| 147 return 0 | 155 return 0 |
| 148 | 156 |
| 149 | 157 |
| 150 if __name__ == '__main__': | 158 if __name__ == '__main__': |
| 151 sys.exit(Main()) | 159 sys.exit(Main()) |
| OLD | NEW |