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 |
| 52 void main(List<String> arguments) { |
| 53 dart2jsMain.BUILD_ID = "$version"; |
| 54 dart2jsMain.main(arguments); |
| 55 } |
| 56 """; |
| 57 return snapshotGenerationText; |
| 58 }); |
| 59 } |
| 60 |
45 void writeSnapshotFile(var path, var content) { | 61 void writeSnapshotFile(var path, var content) { |
46 File file = new File(path); | 62 File file = new File(path); |
47 var writer = file.openSync(mode: FileMode.WRITE); | 63 var writer = file.openSync(mode: FileMode.WRITE); |
48 writer.writeStringSync(content); | 64 writer.writeStringSync(content); |
49 writer.close(); | 65 writer.close(); |
50 } | 66 } |
51 | 67 |
52 Future createSnapshot(var dart_file, var packageRoot) { | 68 Future createSnapshot(var dart_file, var packageRoot) { |
53 return Process.run(Platform.executable, | 69 return Process.run(Platform.executable, |
54 ["--package-root=$packageRoot", | 70 ["--package-root=$packageRoot", |
(...skipping 29 matching lines...) Expand all Loading... |
84 if (!args.containsKey("package_root")) throw "Please specify package_root"; | 100 if (!args.containsKey("package_root")) throw "Please specify package_root"; |
85 | 101 |
86 var scriptFile = Uri.base.resolveUri(Platform.script); | 102 var scriptFile = Uri.base.resolveUri(Platform.script); |
87 var path = scriptFile.resolve("."); | 103 var path = scriptFile.resolve("."); |
88 var rootPath = path.resolve("../.."); | 104 var rootPath = path.resolve("../.."); |
89 getSnapshotGenerationFile(args, rootPath).then((result) { | 105 getSnapshotGenerationFile(args, rootPath).then((result) { |
90 var wrapper = "${args['output_dir']}/utils_wrapper.dart"; | 106 var wrapper = "${args['output_dir']}/utils_wrapper.dart"; |
91 writeSnapshotFile(wrapper, result); | 107 writeSnapshotFile(wrapper, result); |
92 createSnapshot(wrapper, args["package_root"]); | 108 createSnapshot(wrapper, args["package_root"]); |
93 }); | 109 }); |
| 110 |
| 111 getDart2jsSnapshotGenerationFile(args, rootPath).then((result) { |
| 112 var wrapper = "${args['output_dir']}/dart2js.dart"; |
| 113 writeSnapshotFile(wrapper, result); |
| 114 createSnapshot(wrapper, args["package_root"]); |
| 115 }); |
| 116 |
94 } | 117 } |
OLD | NEW |