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