| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library fasta.compile_platform; | 5 library fasta.compile_platform; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:io' show exitCode; | 9 import 'dart:io' show exitCode; |
| 10 | 10 |
| 11 import 'compiler_command_line.dart' show CompilerCommandLine; | 11 import 'compiler_command_line.dart' show CompilerCommandLine; |
| 12 | 12 |
| 13 import 'compiler_context.dart' show CompilerContext; | 13 import 'compiler_context.dart' show CompilerContext; |
| 14 | 14 |
| 15 import 'dill/dill_target.dart' show DillTarget; | 15 import 'dill/dill_target.dart' show DillTarget; |
| 16 | 16 |
| 17 import 'errors.dart' show InputError; | 17 import 'errors.dart' show InputError; |
| 18 | 18 |
| 19 import 'kernel/kernel_target.dart' show KernelTarget; | 19 import 'kernel/kernel_target.dart' show KernelTarget; |
| 20 | 20 |
| 21 import 'kernel/utils.dart' show printProgramText, writeProgramToFile; | 21 import 'kernel/utils.dart' show printProgramText, writeProgramToFile; |
| 22 | 22 |
| 23 import 'ticker.dart' show Ticker; | 23 import 'ticker.dart' show Ticker; |
| 24 | 24 |
| 25 import 'translate_uri.dart' show TranslateUri; | 25 import 'translate_uri.dart' show TranslateUri; |
| 26 | 26 |
| 27 import 'package:kernel/target/targets.dart' show getTarget, TargetFlags; | |
| 28 | |
| 29 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); | 27 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); |
| 30 | 28 |
| 31 Future mainEntryPoint(List<String> arguments) async { | 29 Future mainEntryPoint(List<String> arguments) async { |
| 32 for (int i = 0; i < iterations; i++) { | 30 for (int i = 0; i < iterations; i++) { |
| 33 if (i > 0) { | 31 if (i > 0) { |
| 34 print("\n"); | 32 print("\n"); |
| 35 } | 33 } |
| 36 try { | 34 try { |
| 37 await compilePlatform(arguments); | 35 await compilePlatform(arguments); |
| 38 } on InputError catch (e) { | 36 } on InputError catch (e) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 66 ticker.logMs("Parsed arguments"); | 64 ticker.logMs("Parsed arguments"); |
| 67 if (ticker.isVerbose) { | 65 if (ticker.isVerbose) { |
| 68 print("Generating outline of $patchedSdk into $outlineOutput"); | 66 print("Generating outline of $patchedSdk into $outlineOutput"); |
| 69 print("Compiling $patchedSdk to $fullOutput"); | 67 print("Compiling $patchedSdk to $fullOutput"); |
| 70 } | 68 } |
| 71 | 69 |
| 72 TranslateUri uriTranslator = await TranslateUri | 70 TranslateUri uriTranslator = await TranslateUri |
| 73 .parse(c.fileSystem, patchedSdk, packages: c.options.packages); | 71 .parse(c.fileSystem, patchedSdk, packages: c.options.packages); |
| 74 ticker.logMs("Read packages file"); | 72 ticker.logMs("Read packages file"); |
| 75 | 73 |
| 76 DillTarget dillTarget = new DillTarget( | 74 DillTarget dillTarget = |
| 77 ticker, | 75 new DillTarget(ticker, uriTranslator, c.options.target); |
| 78 uriTranslator, | |
| 79 getTarget( | |
| 80 c.options.target, new TargetFlags(strongMode: c.options.strongMode))); | |
| 81 KernelTarget kernelTarget = | 76 KernelTarget kernelTarget = |
| 82 new KernelTarget(c.fileSystem, dillTarget, uriTranslator, c.uriToSource); | 77 new KernelTarget(c.fileSystem, dillTarget, uriTranslator, c.uriToSource); |
| 83 | 78 |
| 84 kernelTarget.read(Uri.parse("dart:core")); | 79 kernelTarget.read(Uri.parse("dart:core")); |
| 85 await dillTarget.buildOutlines(); | 80 await dillTarget.buildOutlines(); |
| 86 var outline = await kernelTarget.buildOutlines(); | 81 var outline = await kernelTarget.buildOutlines(); |
| 87 | 82 |
| 88 await writeProgramToFile(outline, outlineOutput); | 83 await writeProgramToFile(outline, outlineOutput); |
| 89 ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}"); | 84 ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}"); |
| 90 | 85 |
| 91 if (exitCode != 0) return null; | 86 if (exitCode != 0) return null; |
| 92 | 87 |
| 93 var program = await kernelTarget.buildProgram(verify: c.options.verify); | 88 var program = await kernelTarget.buildProgram(verify: c.options.verify); |
| 94 if (c.options.dumpIr) printProgramText(program); | 89 if (c.options.dumpIr) printProgramText(program); |
| 95 await writeProgramToFile(program, fullOutput); | 90 await writeProgramToFile(program, fullOutput); |
| 96 ticker.logMs("Wrote program to ${fullOutput.toFilePath()}"); | 91 ticker.logMs("Wrote program to ${fullOutput.toFilePath()}"); |
| 97 await kernelTarget.writeDepsFile(fullOutput, deps); | 92 await kernelTarget.writeDepsFile(fullOutput, deps); |
| 98 } | 93 } |
| OLD | NEW |