Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: pkg/front_end/lib/src/fasta/compile_platform.dart

Issue 2953703002: Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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, File;
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;
16
17 import 'errors.dart' show InputError; 15 import 'errors.dart' show InputError;
18 16
19 import 'kernel/kernel_target.dart' show KernelTarget; 17 import 'kernel/utils.dart' show writeProgramToFile;
20
21 import 'kernel/utils.dart' show printProgramText, writeProgramToFile;
22 18
23 import 'ticker.dart' show Ticker; 19 import 'ticker.dart' show Ticker;
24 20
25 import 'translate_uri.dart' show TranslateUri; 21 import '../../compiler_options.dart';
ahe 2017/07/05 13:29:39 Add show and move to before line 11. I've sorted
Siggi Cherem (dart-lang) 2017/07/05 18:42:09 Done.
22 import '../kernel_generator_impl.dart';
ahe 2017/07/05 13:29:39 Ditto.
Siggi Cherem (dart-lang) 2017/07/05 18:42:09 Done.
26 23
27 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); 24 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1);
28 25
29 Future mainEntryPoint(List<String> arguments) async { 26 Future mainEntryPoint(List<String> arguments) async {
30 for (int i = 0; i < iterations; i++) { 27 for (int i = 0; i < iterations; i++) {
31 if (i > 0) { 28 if (i > 0) {
32 print("\n"); 29 print("\n");
33 } 30 }
34 try { 31 try {
35 await compilePlatform(arguments); 32 await compilePlatform(arguments);
(...skipping 13 matching lines...) Expand all
49 Uri fullOutput = Uri.base.resolveUri(new Uri.file(c.options.arguments[1])); 46 Uri fullOutput = Uri.base.resolveUri(new Uri.file(c.options.arguments[1]));
50 Uri outlineOutput = 47 Uri outlineOutput =
51 Uri.base.resolveUri(new Uri.file(c.options.arguments[2])); 48 Uri.base.resolveUri(new Uri.file(c.options.arguments[2]));
52 return compilePlatformInternal( 49 return compilePlatformInternal(
53 c, ticker, patchedSdk, fullOutput, outlineOutput); 50 c, ticker, patchedSdk, fullOutput, outlineOutput);
54 }); 51 });
55 } 52 }
56 53
57 Future compilePlatformInternal(CompilerContext c, Ticker ticker, Uri patchedSdk, 54 Future compilePlatformInternal(CompilerContext c, Ticker ticker, Uri patchedSdk,
58 Uri fullOutput, Uri outlineOutput) async { 55 Uri fullOutput, Uri outlineOutput) async {
59 if (c.options.strongMode) { 56 var options = new CompilerOptions()
57 ..strongMode = c.options.strongMode
58 ..sdkRoot = patchedSdk
59 ..packagesFileUri = c.options.packages
60 ..compileSdk = true
61 ..chaseDependencies = true
62 ..target = c.options.target
63 ..debugDump = c.options.dumpIr
64 ..verify = c.options.verify
65 ..verbose = c.options.verbose;
66
67 if (options.strongMode) {
60 print("Note: strong mode support is preliminary and may not work."); 68 print("Note: strong mode support is preliminary and may not work.");
61 } 69 }
62 ticker.isVerbose = c.options.verbose; 70 if (options.verbose) {
63 Uri deps = Uri.base.resolveUri(new Uri.file("${fullOutput.toFilePath()}.d"));
64 ticker.logMs("Parsed arguments");
65 if (ticker.isVerbose) {
66 print("Generating outline of $patchedSdk into $outlineOutput"); 71 print("Generating outline of $patchedSdk into $outlineOutput");
67 print("Compiling $patchedSdk to $fullOutput"); 72 print("Compiling $patchedSdk to $fullOutput");
68 } 73 }
69 74
70 TranslateUri uriTranslator = await TranslateUri 75 var result = await generateKernel([Uri.parse('dart:core')], options,
71 .parse(c.fileSystem, patchedSdk, packages: c.options.packages); 76 buildSummary: true, buildProgram: true);
72 ticker.logMs("Read packages file"); 77 new File.fromUri(outlineOutput).writeAsBytesSync(result.summary);
73
74 DillTarget dillTarget =
75 new DillTarget(ticker, uriTranslator, c.options.target);
76 KernelTarget kernelTarget =
77 new KernelTarget(c.fileSystem, dillTarget, uriTranslator, c.uriToSource);
78
79 kernelTarget.read(Uri.parse("dart:core"));
80 await dillTarget.buildOutlines();
81 var outline = await kernelTarget.buildOutlines();
82
83 await writeProgramToFile(outline, outlineOutput);
84 ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}"); 78 ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}");
85 79 await writeProgramToFile(result.program, fullOutput);
86 if (exitCode != 0) return null;
87
88 var program = await kernelTarget.buildProgram(verify: c.options.verify);
89 if (c.options.dumpIr) printProgramText(program);
90 await writeProgramToFile(program, fullOutput);
91 ticker.logMs("Wrote program to ${fullOutput.toFilePath()}"); 80 ticker.logMs("Wrote program to ${fullOutput.toFilePath()}");
92 await kernelTarget.writeDepsFile(fullOutput, deps);
93 } 81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698