| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 178 var relative = p.url.relative(compilerDir, |
| 179 from: p.dirname(p.toUri(destPath).toString())); | 179 from: p.url.dirname(p.toUri(destPath).toString())); |
| 180 return source.replaceAll(_compilerPattern, "import '$relative"); | 180 return source.replaceAll(_compilerPattern, "import '$relative"); |
| 181 } | 181 } |
| 182 | 182 |
| 183 /// 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 |
| 184 /// 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 |
| 185 /// build. | 185 /// build. |
| 186 void _generateSnapshot(String buildDir) { | 186 void _generateSnapshot(String buildDir) { |
| 187 buildDir = p.normalize(buildDir); | 187 buildDir = p.normalize(buildDir); |
| 188 | 188 |
| 189 var entrypoint = p.join(generatedDir, 'bin/pub.dart'); | 189 var entrypoint = p.join(generatedDir, 'bin/pub.dart'); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 /// | 222 /// |
| 223 /// This swallows errors to accommodate multiple compilers running concurrently. | 223 /// This swallows errors to accommodate multiple compilers running concurrently. |
| 224 /// 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. |
| 225 void _writeFile(String path, String contents) { | 225 void _writeFile(String path, String contents) { |
| 226 try { | 226 try { |
| 227 new File(path).writeAsStringSync(contents); | 227 new File(path).writeAsStringSync(contents); |
| 228 } on IOException catch (ex) { | 228 } on IOException catch (ex) { |
| 229 // Do nothing. | 229 // Do nothing. |
| 230 } | 230 } |
| 231 } | 231 } |
| OLD | NEW |