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 /// Defines the front-end API for converting source code to Dart Kernel objects. | 5 /// Defines the front-end API for converting source code to Dart Kernel objects. |
6 library front_end.kernel_generator_impl; | 6 library front_end.kernel_generator_impl; |
7 | 7 |
8 import 'dart:async' show Future; | 8 import 'dart:async' show Future; |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
11 import 'package:kernel/kernel.dart' show Program, CanonicalName; | 11 import 'package:kernel/kernel.dart' show Program, CanonicalName; |
12 | 12 |
13 import 'base/processed_options.dart'; | 13 import 'base/processed_options.dart'; |
| 14 import 'fasta/compiler_command_line.dart' show CompilerCommandLine; |
| 15 import 'fasta/compiler_context.dart' show CompilerContext; |
| 16 import 'fasta/deprecated_problems.dart' show deprecated_InputError, reportCrash; |
14 import 'fasta/dill/dill_target.dart' show DillTarget; | 17 import 'fasta/dill/dill_target.dart' show DillTarget; |
15 import 'fasta/deprecated_problems.dart' show deprecated_InputError, reportCrash; | |
16 import 'fasta/kernel/kernel_outline_shaker.dart'; | 18 import 'fasta/kernel/kernel_outline_shaker.dart'; |
17 import 'fasta/kernel/kernel_target.dart' show KernelTarget; | 19 import 'fasta/kernel/kernel_target.dart' show KernelTarget; |
| 20 import 'fasta/kernel/utils.dart'; |
18 import 'fasta/kernel/verifier.dart'; | 21 import 'fasta/kernel/verifier.dart'; |
19 import 'fasta/kernel/utils.dart'; | |
20 import 'fasta/compiler_command_line.dart'; | |
21 import 'fasta/translate_uri.dart' show TranslateUri; | 22 import 'fasta/translate_uri.dart' show TranslateUri; |
22 | 23 |
23 /// Implementation for the `package:front_end/kernel_generator.dart` and | 24 /// Implementation for the `package:front_end/kernel_generator.dart` and |
24 /// `package:front_end/summary_generator.dart` APIs. | 25 /// `package:front_end/summary_generator.dart` APIs. |
25 Future<CompilerResult> generateKernel(ProcessedOptions options, | 26 Future<CompilerResult> generateKernel(ProcessedOptions options, |
26 {bool buildSummary: false, | 27 {bool buildSummary: false, |
27 bool buildProgram: true, | 28 bool buildProgram: true, |
28 bool trimDependencies: false}) async { | 29 bool trimDependencies: false}) async { |
29 // TODO(sigmund): Replace CompilerCommandLine and instead simply use a | 30 // TODO(sigmund): Replace CompilerCommandLine and instead simply use a |
30 // CompilerContext that directly uses the ProcessedOptions throught the | 31 // CompilerContext that directly uses the ProcessedOptions through the |
31 // system. | 32 // system. |
32 String programName = ""; | 33 String programName = ""; |
33 List<String> arguments = <String>[programName, "--target=none"]; | 34 List<String> arguments = <String>[programName, "--target=none"]; |
34 if (options.strongMode) { | 35 if (options.strongMode) { |
35 arguments.add("--strong-mode"); | 36 arguments.add("--strong-mode"); |
36 } | 37 } |
37 if (options.verbose) { | 38 if (options.verbose) { |
38 arguments.add("--verbose"); | 39 arguments.add("--verbose"); |
39 } | 40 } |
| 41 if (options.setExitCodeOnProblem) { |
| 42 arguments.add("--set-exit-code-on-problem"); |
| 43 } |
40 return await CompilerCommandLine.withGlobalOptions(programName, arguments, | 44 return await CompilerCommandLine.withGlobalOptions(programName, arguments, |
41 (CompilerContext context) async { | 45 (CompilerContext context) async { |
42 context.options.options["--target"] = options.target; | 46 context.options.options["--target"] = options.target; |
43 return await generateKernelInternal(options, | 47 return await generateKernelInternal(options, |
44 buildSummary: buildSummary, | 48 buildSummary: buildSummary, |
45 buildProgram: buildProgram, | 49 buildProgram: buildProgram, |
46 trimDependencies: trimDependencies); | 50 trimDependencies: trimDependencies); |
47 }); | 51 }); |
48 } | 52 } |
49 | 53 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 final Program program; | 172 final Program program; |
169 | 173 |
170 /// Dependencies traversed by the compiler. Used only for generating | 174 /// Dependencies traversed by the compiler. Used only for generating |
171 /// dependency .GN files in the dart-sdk build system. | 175 /// dependency .GN files in the dart-sdk build system. |
172 /// Note this might be removed when we switch to compute depencencies without | 176 /// Note this might be removed when we switch to compute depencencies without |
173 /// using the compiler itself. | 177 /// using the compiler itself. |
174 final List<Uri> deps; | 178 final List<Uri> deps; |
175 | 179 |
176 CompilerResult({this.summary, this.program, this.deps}); | 180 CompilerResult({this.summary, this.program, this.deps}); |
177 } | 181 } |
OLD | NEW |