| 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 rootPath) { | 7 Future<String> getVersion(var rootPath) { |
| 8 var suffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; | 8 var suffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; |
| 9 var printVersionScript = rootPath.resolve("tools/print_version.py"); | 9 var printVersionScript = rootPath.resolve("tools/print_version.py"); |
| 10 return Process.run("python$suffix", | 10 return Process.run("python$suffix", |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } else if (tool == "dartdoc") { | 35 } else if (tool == "dartdoc") { |
| 36 dartdocMain.main(arguments.skip(1).toList()); | 36 dartdocMain.main(arguments.skip(1).toList()); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 """; | 40 """; |
| 41 return snapshotGenerationText; | 41 return snapshotGenerationText; |
| 42 }); | 42 }); |
| 43 } | 43 } |
| 44 | 44 |
| 45 Future<String> getDart2jsSnapshotGenerationFile(var args, var rootPath) { | |
| 46 var dart2js = rootPath.resolve(args["dart2js_main"]); | |
| 47 return getVersion(rootPath).then((version) { | |
| 48 var snapshotGenerationText = | |
| 49 """ | |
| 50 import '${dart2js.toFilePath(windows: false)}' as dart2jsMain; | |
| 51 import 'dart:io'; | |
| 52 | |
| 53 void main(List<String> arguments) { | |
| 54 dart2jsMain.BUILD_ID = "$version"; | |
| 55 dart2jsMain.main(arguments.skip(1).toList()); | |
| 56 } | |
| 57 """; | |
| 58 return snapshotGenerationText; | |
| 59 }); | |
| 60 } | |
| 61 | |
| 62 void writeSnapshotFile(var path, var content) { | 45 void writeSnapshotFile(var path, var content) { |
| 63 File file = new File(path); | 46 File file = new File(path); |
| 64 var writer = file.openSync(mode: FileMode.WRITE); | 47 var writer = file.openSync(mode: FileMode.WRITE); |
| 65 writer.writeStringSync(content); | 48 writer.writeStringSync(content); |
| 66 writer.close(); | 49 writer.close(); |
| 67 } | 50 } |
| 68 | 51 |
| 69 Future createSnapshot(var dart_file, var packageRoot) { | 52 Future createSnapshot(var dart_file, var packageRoot) { |
| 70 return Process.run(Platform.executable, | 53 return Process.run(Platform.executable, |
| 71 ["--package-root=$packageRoot", | 54 ["--package-root=$packageRoot", |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 if (!args.containsKey("package_root")) throw "Please specify package_root"; | 84 if (!args.containsKey("package_root")) throw "Please specify package_root"; |
| 102 | 85 |
| 103 var scriptFile = Uri.base.resolveUri(Platform.script); | 86 var scriptFile = Uri.base.resolveUri(Platform.script); |
| 104 var path = scriptFile.resolve("."); | 87 var path = scriptFile.resolve("."); |
| 105 var rootPath = path.resolve("../.."); | 88 var rootPath = path.resolve("../.."); |
| 106 getSnapshotGenerationFile(args, rootPath).then((result) { | 89 getSnapshotGenerationFile(args, rootPath).then((result) { |
| 107 var wrapper = "${args['output_dir']}/utils_wrapper.dart"; | 90 var wrapper = "${args['output_dir']}/utils_wrapper.dart"; |
| 108 writeSnapshotFile(wrapper, result); | 91 writeSnapshotFile(wrapper, result); |
| 109 createSnapshot(wrapper, args["package_root"]); | 92 createSnapshot(wrapper, args["package_root"]); |
| 110 }); | 93 }); |
| 111 | |
| 112 getDart2jsSnapshotGenerationFile(args, rootPath).then((result) { | |
| 113 var wrapper = "${args['output_dir']}/dart2js.dart"; | |
| 114 writeSnapshotFile(wrapper, result); | |
| 115 createSnapshot(wrapper, args["package_root"]); | |
| 116 }); | |
| 117 | |
| 118 } | 94 } |
| OLD | NEW |