| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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:async' show | 5 import 'dart:async' show |
| 6 Future; | 6 Future; |
| 7 | 7 |
| 8 import 'dart:io' show | 8 import 'dart:io' show |
| 9 Directory, | 9 Directory, |
| 10 Platform; | 10 Platform; |
| 11 | 11 |
| 12 import 'dart:isolate' show | 12 import 'dart:isolate' show |
| 13 Isolate; | 13 Isolate; |
| 14 | 14 |
| 15 import 'package:async_helper/async_helper.dart' show | 15 import 'package:async_helper/async_helper.dart' show |
| 16 asyncEnd, | 16 asyncEnd, |
| 17 asyncStart; | 17 asyncStart; |
| 18 | 18 |
| 19 import 'package:front_end/src/fasta/testing/kernel_chain.dart' show | 19 import 'package:front_end/src/fasta/testing/kernel_chain.dart' show |
| 20 computePatchedSdk; | 20 computePatchedSdk; |
| 21 | 21 |
| 22 import 'package:testing/testing.dart' show | 22 import 'package:testing/testing.dart' show |
| 23 StdioProcess; | 23 StdioProcess; |
| 24 | 24 |
| 25 Future main() async { | 25 Future main() async { |
| 26 asyncStart(); | 26 asyncStart(); |
| 27 Uri sourceCompiler = await Isolate.resolvePackageUri( | 27 Uri sourceCompiler = await Isolate.resolvePackageUri( |
| 28 Uri.parse("package:front_end/src/fasta/bin/compile.dart")); | 28 Uri.parse("package:front_end/src/fasta/bin/compile.dart")); |
| 29 Uri packages = await Isolate.packageConfig; | 29 Uri packages = await Isolate.packageConfig; |
| 30 Directory tmp = await Directory.systemTemp.createTemp("fasta_bootstrap"); |
| 31 Uri compiledOnceCompiler = tmp.uri.resolve("fasta1.dill"); |
| 32 Uri compiledTwiceCompiler = tmp.uri.resolve("fasta2.dill"); |
| 30 try { | 33 try { |
| 31 Directory tmp = await Directory.systemTemp.createTemp("fasta_bootstrap"); | 34 await runCompiler(sourceCompiler, sourceCompiler, compiledOnceCompiler); |
| 32 Uri compiledOnceCompiler = tmp.uri.resolve("fasta1.dill"); | 35 await runCompiler( |
| 33 Uri compiledTwiceCompiler = tmp.uri.resolve("fasta2.dill"); | 36 compiledOnceCompiler, sourceCompiler, compiledTwiceCompiler); |
| 34 try { | |
| 35 await runCompiler(sourceCompiler, sourceCompiler, compiledOnceCompiler); | |
| 36 await runCompiler( | |
| 37 compiledOnceCompiler, sourceCompiler, compiledTwiceCompiler); | |
| 38 } finally { | |
| 39 await tmp.delete(recursive: true); | |
| 40 } | |
| 41 } finally { | 37 } finally { |
| 42 asyncEnd(); | 38 await tmp.delete(recursive: true); |
| 43 } | 39 } |
| 40 asyncEnd(); |
| 44 } | 41 } |
| 45 | 42 |
| 46 Future runCompiler(Uri compiler, Uri input, Uri output) async { | 43 Future runCompiler(Uri compiler, Uri input, Uri output) async { |
| 47 Uri patchedSdk = await computePatchedSdk(); | 44 Uri patchedSdk = await computePatchedSdk(); |
| 48 Uri dartVm = Uri.base.resolve(Platform.resolvedExecutable); | 45 Uri dartVm = Uri.base.resolve(Platform.resolvedExecutable); |
| 49 StdioProcess result = await StdioProcess.run( | 46 StdioProcess result = await StdioProcess.run( |
| 50 dartVm.toFilePath(), | 47 dartVm.toFilePath(), |
| 51 <String>[ | 48 <String>[ |
| 49 "-c", |
| 52 compiler.toFilePath(), | 50 compiler.toFilePath(), |
| 53 "--compile-sdk=${patchedSdk.toFilePath()}", | 51 "--compile-sdk=${patchedSdk.toFilePath()}", |
| 54 "--output=${output.toFilePath()}", | 52 "--output=${output.toFilePath()}", |
| 53 "--verify", |
| 55 input.toFilePath(), | 54 input.toFilePath(), |
| 56 ]); | 55 ]); |
| 57 print(result.output); | 56 print(result.output); |
| 58 if (result.exitCode != 0) { | 57 if (result.exitCode != 0) { |
| 59 throw "Compilation failed."; | 58 throw "Compilation failed."; |
| 60 } | 59 } |
| 61 } | 60 } |
| OLD | NEW |