| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 Future<String> getVersion(var options, var rootPath) { | 7 Future<String> getVersion(var options, var rootPath) { |
| 8 var os = Platform.operatingSystem; | 8 var os = Platform.operatingSystem; |
| 9 var suffix = os == 'windows' ? '.exe' : ''; | 9 var suffix = os == 'windows' ? '.exe' : ''; |
| 10 var checkedInBinary = | 10 var checkedInBinary = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 void writeSnapshotFile(var path, var content) { | 51 void writeSnapshotFile(var path, var content) { |
| 52 File file = new File(path); | 52 File file = new File(path); |
| 53 var writer = file.openSync(mode: FileMode.WRITE); | 53 var writer = file.openSync(mode: FileMode.WRITE); |
| 54 writer.writeStringSync(content); | 54 writer.writeStringSync(content); |
| 55 writer.close(); | 55 writer.close(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 Future createSnapshot(var options, var dart_file, var packageRoot) { | 58 Future createSnapshot(var options, var dart_file, var packageRoot) { |
| 59 return Process.run(options.executable, | 59 return Process.run(options.executable, |
| 60 ["--package-root=$packageRoot", | 60 ["--package-root=$packageRoot", |
| 61 "--generate-script-snapshot=$dart_file.snapshot", | 61 "--snapshot=$dart_file.snapshot", |
| 62 dart_file]) | 62 dart_file]) |
| 63 .then((result) { | 63 .then((result) { |
| 64 if (result.exitCode != 0) { | 64 if (result.exitCode != 0) { |
| 65 throw "Could not generate snapshot"; | 65 throw "Could not generate snapshot"; |
| 66 } | 66 } |
| 67 }); | 67 }); |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * Takes the following arguments: | 71 * Takes the following arguments: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 92 | 92 |
| 93 var scriptFile = new File(new File(options.script).fullPathSync()); | 93 var scriptFile = new File(new File(options.script).fullPathSync()); |
| 94 var path = new Path(scriptFile.directory.path); | 94 var path = new Path(scriptFile.directory.path); |
| 95 var rootPath = path.directoryPath.directoryPath; | 95 var rootPath = path.directoryPath.directoryPath; |
| 96 getSnapshotGenerationFile(options, args, rootPath).then((result) { | 96 getSnapshotGenerationFile(options, args, rootPath).then((result) { |
| 97 var wrapper = "${args['output_dir']}/utils_wrapper.dart"; | 97 var wrapper = "${args['output_dir']}/utils_wrapper.dart"; |
| 98 writeSnapshotFile(wrapper, result); | 98 writeSnapshotFile(wrapper, result); |
| 99 createSnapshot(options, wrapper, args["package_root"]); | 99 createSnapshot(options, wrapper, args["package_root"]); |
| 100 }); | 100 }); |
| 101 } | 101 } |
| OLD | NEW |