Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: utils/compiler/create_snapshot.dart

Issue 23054008: Remove the Path class from dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed first round of review comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/coverage.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 suffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; 8 var suffix = Platform.operatingSystem == 'windows' ? '.exe' : '';
9 var printVersionScript = 9 var printVersionScript = rootPath.resolve("tools/print_version.py");
10 rootPath.append("tools").append("print_version.py").toNativePath(); 10 return Process.run("python$suffix",
11 return Process.run("python$suffix", [printVersionScript]).then((result) { 11 [printVersionScript.toFilePath()]).then((result) {
12 if (result.exitCode != 0) { 12 if (result.exitCode != 0) {
13 throw "Could not generate version"; 13 throw "Could not generate version";
14 } 14 }
15 return result.stdout.trim(); 15 return result.stdout.trim();
16 }); 16 });
17 } 17 }
18 18
19 Future<String> getSnapshotGenerationFile(var options, var args, var rootPath) { 19 Future<String> getSnapshotGenerationFile(var options, var args, var rootPath) {
20 var dart2js = rootPath.append(args["dart2js_main"]); 20 var dart2js = rootPath.resolve(args["dart2js_main"]);
21 var dartdoc = rootPath.append(args["dartdoc_main"]); 21 var dartdoc = rootPath.resolve(args["dartdoc_main"]);
22
23 return getVersion(options, rootPath).then((version) { 22 return getVersion(options, rootPath).then((version) {
24 var snapshotGenerationText = 23 var snapshotGenerationText =
25 """ 24 """
26 import '${dart2js}' as dart2jsMain; 25 import '${dart2js.toFilePath()}' as dart2jsMain;
ahe 2013/08/15 09:29:00 That isn't right. Dart imports use URI syntax.
27 import '${dartdoc}' as dartdocMain; 26 import '${dartdoc.toFilePath()}' as dartdocMain;
28 import 'dart:io'; 27 import 'dart:io';
29 28
30 void main() { 29 void main() {
31 Options options = new Options(); 30 Options options = new Options();
32 if (options.arguments.length < 1) throw "No tool given as argument"; 31 if (options.arguments.length < 1) throw "No tool given as argument";
33 String tool = options.arguments.removeAt(0); 32 String tool = options.arguments.removeAt(0);
34 if (tool == "dart2js") { 33 if (tool == "dart2js") {
35 dart2jsMain.BUILD_ID = "$version"; 34 dart2jsMain.BUILD_ID = "$version";
36 dart2jsMain.mainWithErrorHandler(options); 35 dart2jsMain.mainWithErrorHandler(options);
37 } else if (tool == "dartdoc") { 36 } else if (tool == "dartdoc") {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (!validArguments.contains(argumentSplit[0])) { 78 if (!validArguments.contains(argumentSplit[0])) {
80 throw "Invalid argument $argument"; 79 throw "Invalid argument $argument";
81 } 80 }
82 args[argumentSplit[0].substring(2)] = argumentSplit[1]; 81 args[argumentSplit[0].substring(2)] = argumentSplit[1];
83 } 82 }
84 if (!args.containsKey("dart2js_main")) throw "Please specify dart2js_main"; 83 if (!args.containsKey("dart2js_main")) throw "Please specify dart2js_main";
85 if (!args.containsKey("dartdoc_main")) throw "Please specify dartdoc_main"; 84 if (!args.containsKey("dartdoc_main")) throw "Please specify dartdoc_main";
86 if (!args.containsKey("output_dir")) throw "Please specify output_dir"; 85 if (!args.containsKey("output_dir")) throw "Please specify output_dir";
87 if (!args.containsKey("package_root")) throw "Please specify package_root"; 86 if (!args.containsKey("package_root")) throw "Please specify package_root";
88 87
89 var scriptFile = new File(new File(options.script).fullPathSync()); 88 var scriptFile = new Uri.file(new File(options.script).fullPathSync());
90 var path = new Path(scriptFile.directory.path); 89 var path = scriptFile.resolve(".");
91 var rootPath = path.directoryPath.directoryPath; 90 var rootPath = path.resolve("../..");
92 getSnapshotGenerationFile(options, args, rootPath).then((result) { 91 getSnapshotGenerationFile(options, args, rootPath).then((result) {
93 var wrapper = "${args['output_dir']}/utils_wrapper.dart"; 92 var wrapper = "${args['output_dir']}/utils_wrapper.dart";
94 writeSnapshotFile(wrapper, result); 93 writeSnapshotFile(wrapper, result);
95 createSnapshot(options, wrapper, args["package_root"]); 94 createSnapshot(options, wrapper, args["package_root"]);
96 }); 95 });
97 } 96 }
OLDNEW
« no previous file with comments | « tools/coverage.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698