OLD | NEW |
---|---|
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 157 matching lines...) Loading... | |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 /// Fix relative imports to dart2js libraries. | 171 /// Fix relative imports to dart2js libraries. |
172 /// | 172 /// |
173 /// Pub imports dart2js using relative imports that reach outside of pub's | 173 /// Pub imports dart2js using relative imports that reach outside of pub's |
174 /// source tree. Since the build directory is in a different location, we need | 174 /// source tree. Since the build directory is in a different location, we need |
175 /// to fix those to be valid relative imports from the build directory. | 175 /// to fix those to be valid relative imports from the build directory. |
176 String _fixDart2jsImports(String sourcePath, String source, String destPath) { | 176 String _fixDart2jsImports(String sourcePath, String source, String destPath) { |
177 var compilerDir = p.url.join(sourceUrl, "../compiler"); | 177 var compilerDir = p.url.join(sourceUrl, "../compiler"); |
178 var relative = p.url.relative(compilerDir, from: p.dirname(destPath)); | 178 var relative = p.url.relative(compilerDir, |
179 from: p.dirname(p.toUri(destPath).toString())); | |
nweiz
2014/09/09 19:21:31
This should be p.url.dirname if it's working on a
| |
179 return source.replaceAll(_compilerPattern, "import '$relative"); | 180 return source.replaceAll(_compilerPattern, "import '$relative"); |
180 } | 181 } |
181 | 182 |
182 /// Regenerate the pub snapshot from the async/await-compiled output. We do | 183 /// Regenerate the pub snapshot from the async/await-compiled output. We do |
183 /// this here since the tests need it and it's faster than doing a full SDK | 184 /// this here since the tests need it and it's faster than doing a full SDK |
184 /// build. | 185 /// build. |
185 void _generateSnapshot(String buildDir) { | 186 void _generateSnapshot(String buildDir) { |
186 buildDir = p.normalize(buildDir); | 187 buildDir = p.normalize(buildDir); |
187 | 188 |
188 var entrypoint = p.join(generatedDir, 'bin/pub.dart'); | 189 var entrypoint = p.join(generatedDir, 'bin/pub.dart'); |
(...skipping 32 matching lines...) Loading... | |
221 /// | 222 /// |
222 /// This swallows errors to accommodate multiple compilers running concurrently. | 223 /// This swallows errors to accommodate multiple compilers running concurrently. |
223 /// Since they will produce the same output anyway, a failure of one is fine. | 224 /// Since they will produce the same output anyway, a failure of one is fine. |
224 void _writeFile(String path, String contents) { | 225 void _writeFile(String path, String contents) { |
225 try { | 226 try { |
226 new File(path).writeAsStringSync(contents); | 227 new File(path).writeAsStringSync(contents); |
227 } on IOException catch (ex) { | 228 } on IOException catch (ex) { |
228 // Do nothing. | 229 // Do nothing. |
229 } | 230 } |
230 } | 231 } |
OLD | NEW |