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

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

Issue 2979463002: Revert "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, File; 9 import 'dart:io' show exitCode;
10
11 import '../../compiler_options.dart' show CompilerOptions;
12
13 import '../base/processed_options.dart' show ProcessedOptions;
14
15 import '../kernel_generator_impl.dart' show generateKernel;
16 10
17 import 'compiler_command_line.dart' show CompilerCommandLine; 11 import 'compiler_command_line.dart' show CompilerCommandLine;
18 12
19 import 'compiler_context.dart' show CompilerContext; 13 import 'compiler_context.dart' show CompilerContext;
20 14
15 import 'dill/dill_target.dart' show DillTarget;
16
21 import 'errors.dart' show InputError; 17 import 'errors.dart' show InputError;
22 18
23 import 'kernel/utils.dart' show writeProgramToFile; 19 import 'kernel/kernel_target.dart' show KernelTarget;
20
21 import 'kernel/utils.dart' show printProgramText, writeProgramToFile;
24 22
25 import 'ticker.dart' show Ticker; 23 import 'ticker.dart' show Ticker;
26 24
25 import 'translate_uri.dart' show TranslateUri;
26
27 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); 27 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1);
28 28
29 Future mainEntryPoint(List<String> arguments) async { 29 Future mainEntryPoint(List<String> arguments) async {
30 for (int i = 0; i < iterations; i++) { 30 for (int i = 0; i < iterations; i++) {
31 if (i > 0) { 31 if (i > 0) {
32 print("\n"); 32 print("\n");
33 } 33 }
34 try { 34 try {
35 await compilePlatform(arguments); 35 await compilePlatform(arguments);
36 } on InputError catch (e) { 36 } on InputError catch (e) {
(...skipping 12 matching lines...) Expand all
49 Uri fullOutput = Uri.base.resolveUri(new Uri.file(c.options.arguments[1])); 49 Uri fullOutput = Uri.base.resolveUri(new Uri.file(c.options.arguments[1]));
50 Uri outlineOutput = 50 Uri outlineOutput =
51 Uri.base.resolveUri(new Uri.file(c.options.arguments[2])); 51 Uri.base.resolveUri(new Uri.file(c.options.arguments[2]));
52 return compilePlatformInternal( 52 return compilePlatformInternal(
53 c, ticker, patchedSdk, fullOutput, outlineOutput); 53 c, ticker, patchedSdk, fullOutput, outlineOutput);
54 }); 54 });
55 } 55 }
56 56
57 Future compilePlatformInternal(CompilerContext c, Ticker ticker, Uri patchedSdk, 57 Future compilePlatformInternal(CompilerContext c, Ticker ticker, Uri patchedSdk,
58 Uri fullOutput, Uri outlineOutput) async { 58 Uri fullOutput, Uri outlineOutput) async {
59 var options = new CompilerOptions() 59 if (c.options.strongMode) {
60 ..strongMode = c.options.strongMode
61 ..sdkRoot = patchedSdk
62 ..packagesFileUri = c.options.packages
63 ..compileSdk = true
64 ..chaseDependencies = true
65 ..target = c.options.target
66 ..debugDump = c.options.dumpIr
67 ..verify = c.options.verify
68 ..verbose = c.options.verbose;
69
70 if (options.strongMode) {
71 print("Note: strong mode support is preliminary and may not work."); 60 print("Note: strong mode support is preliminary and may not work.");
72 } 61 }
73 if (options.verbose) { 62 ticker.isVerbose = c.options.verbose;
63 Uri deps = Uri.base.resolveUri(new Uri.file("${fullOutput.toFilePath()}.d"));
64 ticker.logMs("Parsed arguments");
65 if (ticker.isVerbose) {
74 print("Generating outline of $patchedSdk into $outlineOutput"); 66 print("Generating outline of $patchedSdk into $outlineOutput");
75 print("Compiling $patchedSdk to $fullOutput"); 67 print("Compiling $patchedSdk to $fullOutput");
76 } 68 }
77 69
78 var result = await generateKernel( 70 TranslateUri uriTranslator = await TranslateUri
79 new ProcessedOptions(options, false, [Uri.parse('dart:core')]), 71 .parse(c.fileSystem, patchedSdk, packages: c.options.packages);
80 buildSummary: true, 72 ticker.logMs("Read packages file");
81 buildProgram: true); 73
82 new File.fromUri(outlineOutput).writeAsBytesSync(result.summary); 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);
83 ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}"); 84 ticker.logMs("Wrote outline to ${outlineOutput.toFilePath()}");
84 await writeProgramToFile(result.program, fullOutput); 85
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);
85 ticker.logMs("Wrote program to ${fullOutput.toFilePath()}"); 91 ticker.logMs("Wrote program to ${fullOutput.toFilePath()}");
92 await kernelTarget.writeDepsFile(fullOutput, deps);
86 } 93 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/builder/library_builder.dart ('k') | pkg/front_end/lib/src/fasta/fasta.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698