| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library fasta.compile_platform; | |
| 6 | |
| 7 import 'dart:async' show Future; | |
| 8 | |
| 9 import 'dart:io' show exitCode, File; | |
| 10 | |
| 11 import '../kernel_generator_impl.dart' show generateKernelInternal; | |
| 12 | |
| 13 import 'compiler_command_line.dart' show CompilerCommandLine; | |
| 14 | |
| 15 import 'compiler_context.dart' show CompilerContext; | |
| 16 | |
| 17 import 'deprecated_problems.dart' show deprecated_InputError; | |
| 18 | |
| 19 import 'kernel/utils.dart' show writeProgramToFile; | |
| 20 | |
| 21 import 'severity.dart' show Severity; | |
| 22 | |
| 23 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); | |
| 24 | |
| 25 Future mainEntryPoint(List<String> arguments) async { | |
| 26 for (int i = 0; i < iterations; i++) { | |
| 27 if (i > 0) { | |
| 28 print("\n"); | |
| 29 } | |
| 30 try { | |
| 31 await compilePlatform(arguments); | |
| 32 } on deprecated_InputError catch (e) { | |
| 33 exitCode = 1; | |
| 34 CompilerContext.runWithDefaultOptions( | |
| 35 (c) => c.report(deprecated_InputError.toMessage(e), Severity.error)); | |
| 36 return null; | |
| 37 } | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 Future compilePlatform(List<String> arguments) async { | |
| 42 await CompilerCommandLine | |
| 43 .withGlobalOptions("compile_platform", arguments, false, | |
| 44 (CompilerContext c, List<String> restArguments) { | |
| 45 c.options.inputs.add(Uri.parse('dart:core')); | |
| 46 // Note: the patchedSdk argument is already stored in c.options.sdkRoot. | |
| 47 Uri fullOutput = Uri.base.resolveUri(new Uri.file(restArguments[1])); | |
| 48 Uri outlineOutput = Uri.base.resolveUri(new Uri.file(restArguments[2])); | |
| 49 return compilePlatformInternal(c, fullOutput, outlineOutput); | |
| 50 }); | |
| 51 } | |
| 52 | |
| 53 Future compilePlatformInternal( | |
| 54 CompilerContext c, Uri fullOutput, Uri outlineOutput) async { | |
| 55 if (c.options.strongMode) { | |
| 56 print("Note: strong mode support is preliminary and may not work."); | |
| 57 } | |
| 58 if (c.options.verbose) { | |
| 59 print("Generating outline of ${c.options.sdkRoot} into $outlineOutput"); | |
| 60 print("Compiling ${c.options.sdkRoot} to $fullOutput"); | |
| 61 } | |
| 62 | |
| 63 var result = | |
| 64 await generateKernelInternal(buildSummary: true, buildProgram: true); | |
| 65 if (result == null) { | |
| 66 // Note: an error should have been reported by now. | |
| 67 print('The platform .dill files were not created.'); | |
| 68 return; | |
| 69 } | |
| 70 new File.fromUri(outlineOutput).writeAsBytesSync(result.summary); | |
| 71 c.options.ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}"); | |
| 72 await writeProgramToFile(result.program, fullOutput); | |
| 73 c.options.ticker.logMs("Wrote program to ${fullOutput.toFilePath()}"); | |
| 74 } | |
| OLD | NEW |