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

Side by Side Diff: sdk/lib/_internal/pub/bin/async_compile.dart

Issue 599343003: Get binstubs working on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comment. Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 import 'package:analyzer/src/services/formatter_impl.dart'; 8 import 'package:analyzer/src/services/formatter_impl.dart';
9 import 'package:async_await/async_await.dart' as async_await; 9 import 'package:async_await/async_await.dart' as async_await;
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 stderr.writeln(ex); 64 stderr.writeln(ex);
65 stderr.writeln(); 65 stderr.writeln();
66 stderr.writeln( 66 stderr.writeln(
67 "Usage: dart async_compile.dart [--verbose] [--force] <build dir>"); 67 "Usage: dart async_compile.dart [--verbose] [--force] <build dir>");
68 exit(64); 68 exit(64);
69 } 69 }
70 70
71 // See what version (i.e. Git commit) of the async-await compiler we 71 // See what version (i.e. Git commit) of the async-await compiler we
72 // currently have. If this is different from the version that was used to 72 // currently have. If this is different from the version that was used to
73 // compile the sources, recompile everything. 73 // compile the sources, recompile everything.
74 var result = Process.runSync("git", ["rev-parse", "HEAD"], workingDirectory: 74 var currentCommit = _getCurrentCommit();
75 p.join(sourceDir, "../../../../third_party/pkg/async_await"));
76 if (result.exitCode != 0) {
77 stderr.writeln("Could not get Git revision of async_await compiler.");
78 exit(1);
79 }
80
81 var currentCommit = result.stdout.trim();
82 75
83 var readmePath = p.join(generatedDir, "README.md"); 76 var readmePath = p.join(generatedDir, "README.md");
84 var lastCommit; 77 var lastCommit;
85 var readme = new File(readmePath).readAsStringSync(); 78 var readme = new File(readmePath).readAsStringSync();
86 var match = _commitPattern.firstMatch(readme); 79 var match = _commitPattern.firstMatch(readme);
87 if (match == null) { 80 if (match == null) {
88 stderr.writeln("Could not find compiler commit hash in README.md."); 81 stderr.writeln("Could not find compiler commit hash in README.md.");
89 exit(1); 82 exit(1);
90 } 83 }
91 84
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (verbose) print("Updated README.md"); 128 if (verbose) print("Updated README.md");
136 } 129 }
137 130
138 if (numCompiled > 0) _generateSnapshot(buildDir); 131 if (numCompiled > 0) _generateSnapshot(buildDir);
139 132
140 if (verbose) print("Compiled $numCompiled out of $numFiles files"); 133 if (verbose) print("Compiled $numCompiled out of $numFiles files");
141 134
142 if (hadFailure) exit(1); 135 if (hadFailure) exit(1);
143 } 136 }
144 137
138 String _getCurrentCommit() {
139 var command = "git";
140 var args = ["rev-parse", "HEAD"];
141
142 // Spawning a process on Windows will not look for the executable in the
143 // system path so spawn git through a shell to find it.
144 if (Platform.operatingSystem == "windows") {
145 command = "cmd";
146 args = ["/c", "git"]..addAll(args);
147 }
148
149 var result = Process.runSync(command, args, workingDirectory:
150 p.join(sourceDir, "../../../../third_party/pkg/async_await"));
151 if (result.exitCode != 0) {
152 stderr.writeln("Could not get Git revision of async_await compiler.");
153 exit(1);
154 }
155
156 return result.stdout.trim();
157 }
158
145 void _compile(String sourcePath, String source, String destPath) { 159 void _compile(String sourcePath, String source, String destPath) {
146 var destDir = new Directory(p.dirname(destPath)); 160 var destDir = new Directory(p.dirname(destPath));
147 destDir.createSync(recursive: true); 161 destDir.createSync(recursive: true);
148 162
149 source = _translateAsyncAwait(sourcePath, source); 163 source = _translateAsyncAwait(sourcePath, source);
150 if (source != null) source = _fixDart2jsImports(sourcePath, source, destPath); 164 if (source != null) source = _fixDart2jsImports(sourcePath, source, destPath);
151 165
152 if (source == null) { 166 if (source == null) {
153 // If the async compile fails, delete the file so that we don't try to 167 // If the async compile fails, delete the file so that we don't try to
154 // run the stale previous output and so that we try to recompile it later. 168 // run the stale previous output and so that we try to recompile it later.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 /// 251 ///
238 /// This swallows errors to accommodate multiple compilers running concurrently. 252 /// This swallows errors to accommodate multiple compilers running concurrently.
239 /// Since they will produce the same output anyway, a failure of one is fine. 253 /// Since they will produce the same output anyway, a failure of one is fine.
240 void _writeFile(String path, String contents) { 254 void _writeFile(String path, String contents) {
241 try { 255 try {
242 new File(path).writeAsStringSync(contents); 256 new File(path).writeAsStringSync(contents);
243 } on IOException catch (ex) { 257 } on IOException catch (ex) {
244 // Do nothing. 258 // Do nothing.
245 } 259 }
246 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698