OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 /// Command line tool to merge the SDK libraries and our patch files. | 6 /// Command line tool to merge the SDK libraries and our patch files. |
7 /// This is currently designed as an offline tool, but we could automate it. | 7 /// This is currently designed as an offline tool, but we could automate it. |
8 | 8 |
9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'dart:async'; |
10 import 'dart:math' as math; | 11 import 'dart:math' as math; |
11 | 12 |
12 import 'package:analyzer/analyzer.dart'; | 13 import 'package:analyzer/analyzer.dart'; |
13 import 'package:analyzer/src/generated/sdk.dart'; | 14 import 'package:analyzer/src/generated/sdk.dart'; |
14 import 'package:path/path.dart' as path; | 15 import 'package:path/path.dart' as path; |
15 import 'package:front_end/src/fasta/bin/compile_platform.dart' as | 16 import 'package:front_end/src/fasta/bin/compile_platform.dart' as |
16 compile_platform; | 17 compile_platform; |
17 | 18 |
18 Future main(List<String> argv) async { | 19 Future main(List<String> argv) async { |
19 var base = path.fromUri(Platform.script); | 20 var base = path.fromUri(Platform.script); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 _writeSync(builtinLibraryOut, new File(builtinLibraryIn).readAsStringSync(
)); | 188 _writeSync(builtinLibraryOut, new File(builtinLibraryIn).readAsStringSync(
)); |
188 } | 189 } |
189 | 190 |
190 for (var file in ['loader.dart', 'server.dart', 'vmservice_io.dart']) { | 191 for (var file in ['loader.dart', 'server.dart', 'vmservice_io.dart']) { |
191 var libraryIn = path.join(dartDir, 'runtime', 'bin', 'vmservice', file); | 192 var libraryIn = path.join(dartDir, 'runtime', 'bin', 'vmservice', file); |
192 var libraryOut = path.join(sdkOut, 'vmservice_io', file); | 193 var libraryOut = path.join(sdkOut, 'vmservice_io', file); |
193 _writeSync(libraryOut, new File(libraryIn).readAsStringSync()); | 194 _writeSync(libraryOut, new File(libraryIn).readAsStringSync()); |
194 } | 195 } |
195 } | 196 } |
196 | 197 |
197 await compile_platform.main(<String>[ | 198 // TODO(kustermann): We suppress compiler hints/warnings/errors temporarily |
198 '--packages', | 199 // because everyone building the `runtime` target will get these now. |
199 new Uri.file(packagesFile).toString(), | 200 // We should remove the suppression again once the underlying issues have |
200 sdkOut, | 201 // been fixed (either in fasta or the dart files in the patched_sdk). |
201 path.join(sdkOut, 'platform.dill') | 202 final capturedLines = <String>[]; |
202 ]); | 203 try { |
| 204 await runZoned(() async { |
| 205 await compile_platform.main(<String>[ |
| 206 '--packages', |
| 207 new Uri.file(packagesFile).toString(), |
| 208 sdkOut, |
| 209 path.join(sdkOut, 'platform.dill') |
| 210 ]); |
| 211 }, zoneSpecification: new ZoneSpecification(print: (_, _2, _3, line) { |
| 212 capturedLines.add(line); |
| 213 })); |
| 214 } catch (_) { |
| 215 for (final line in capturedLines) { |
| 216 print(line); |
| 217 } |
| 218 rethrow; |
| 219 } |
203 } | 220 } |
204 | 221 |
205 /// Writes a file, creating the directory if needed. | 222 /// Writes a file, creating the directory if needed. |
206 void _writeSync(String filePath, String contents) { | 223 void _writeSync(String filePath, String contents) { |
207 var outDir = new Directory(path.dirname(filePath)); | 224 var outDir = new Directory(path.dirname(filePath)); |
208 if (!outDir.existsSync()) outDir.createSync(recursive: true); | 225 if (!outDir.existsSync()) outDir.createSync(recursive: true); |
209 | 226 |
210 new File(filePath).writeAsStringSync(contents); | 227 new File(filePath).writeAsStringSync(contents); |
211 } | 228 } |
212 | 229 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 if (diff != 0) return diff; | 553 if (diff != 0) return diff; |
537 return end - other.end; | 554 return end - other.end; |
538 } | 555 } |
539 } | 556 } |
540 | 557 |
541 List<SdkLibrary> _getSdkLibraries(String contents) { | 558 List<SdkLibrary> _getSdkLibraries(String contents) { |
542 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); | 559 var libraryBuilder = new SdkLibrariesReader_LibraryBuilder(true); |
543 parseCompilationUnit(contents).accept(libraryBuilder); | 560 parseCompilationUnit(contents).accept(libraryBuilder); |
544 return libraryBuilder.librariesMap.sdkLibraries; | 561 return libraryBuilder.librariesMap.sdkLibraries; |
545 } | 562 } |
OLD | NEW |