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 front_end.compiler_options; | 5 library front_end.compiler_options; |
6 | 6 |
7 import 'package:front_end/src/base/performace_logger.dart'; | 7 import 'package:front_end/src/base/performace_logger.dart'; |
8 import 'package:front_end/src/incremental/byte_store.dart'; | 8 import 'package:front_end/src/incremental/byte_store.dart'; |
9 import 'package:kernel/target/targets.dart' show Target; | 9 import 'package:kernel/target/targets.dart' show Target; |
10 | 10 |
11 import 'compilation_error.dart'; | 11 import 'compilation_message.dart'; |
12 import 'file_system.dart'; | 12 import 'file_system.dart'; |
13 import 'physical_file_system.dart'; | 13 import 'physical_file_system.dart'; |
14 | 14 |
15 /// Default error handler used by [CompilerOptions.onError]. | |
16 void defaultErrorHandler(CompilationError error) => throw error; | |
17 | |
18 /// Callback used to report errors encountered during compilation. | 15 /// Callback used to report errors encountered during compilation. |
19 typedef void ErrorHandler(CompilationError error); | 16 typedef void ErrorHandler(CompilationMessage error); |
20 | 17 |
21 /// Front-end options relevant to compiler back ends. | 18 /// Front-end options relevant to compiler back ends. |
22 /// | 19 /// |
23 /// Not intended to be implemented or extended by clients. | 20 /// Not intended to be implemented or extended by clients. |
24 class CompilerOptions { | 21 class CompilerOptions { |
25 /// The URI of the root of the Dart SDK (typically a "file:" URI). | 22 /// The URI of the root of the Dart SDK (typically a "file:" URI). |
26 /// | 23 /// |
27 /// If `null`, the SDK will be searched for using | 24 /// If `null`, the SDK will be searched for using |
28 /// [Platform.resolvedExecutable] as a starting point. | 25 /// [Platform.resolvedExecutable] as a starting point. |
29 Uri sdkRoot; | 26 Uri sdkRoot; |
30 | 27 |
31 /// Map of `dart:*` libraries to URIs in the [fileSystem]. | 28 /// Map of `dart:*` libraries to URIs in the [fileSystem]. |
32 /// | 29 /// |
33 /// Keys in the map are the name of the library with no `dart:` prefix, for | 30 /// Keys in the map are the name of the library with no `dart:` prefix, for |
34 /// example: | 31 /// example: |
35 /// | 32 /// |
36 /// {'core': 'file:///sdk/lib/core/core.dart'} | 33 /// {'core': 'file:///sdk/lib/core/core.dart'} |
37 /// | 34 /// |
38 /// If `null`, the default set of libraries will be loaded from | 35 /// If `null`, the default set of libraries will be loaded from |
39 /// `sdkRoot/lib/libraries.json`. | 36 /// `sdkRoot/lib/libraries.json`. |
40 // TODO(sigmund): also provide an option to specify the .json file, then | 37 // TODO(sigmund): also provide an option to specify the .json file, then |
41 // consider dropping this option. | 38 // consider dropping this option. |
42 Map<String, Uri> dartLibraries; | 39 Map<String, Uri> dartLibraries; |
43 | 40 |
44 /// Callback to which compilation errors should be delivered. | 41 /// Callback to which compilation errors should be delivered. |
45 /// | 42 /// |
46 /// By default, the first error will be reported by throwing an exception of | 43 /// By default, when no callback is provided, the compiler will report |
47 /// type [CompilationError]. | 44 /// messages on the console and will throw when fatal errors are discovered. |
48 ErrorHandler onError = defaultErrorHandler; | 45 ErrorHandler onError; |
46 | |
47 /// Whether messages should be reported using the compiler's internal | |
48 /// reporting mechanism. | |
49 /// | |
50 /// If no [onError] handler is provided, the default is true. If an [onError] | |
51 /// handler is provided, the default is false. Setting this to true will | |
52 /// ensure that error messages are printed in the console and that fatal | |
53 /// errors cause an exception. | |
54 bool reportMessages; | |
Siggi Cherem (dart-lang)
2017/07/18 00:11:07
Paul & Peter - there are many ways to address what
ahe
2017/07/18 16:54:36
As we discussed in our 1:1, I'd like to make forma
Paul Berry
2017/07/18 18:36:21
I'm fine with the code as is for now. IMHO we can
ahe
2017/07/18 21:07:26
Agreed. If it wasn't clear when we discussed it, a
Siggi Cherem (dart-lang)
2017/07/18 22:50:43
Sounds good, thanks both, added TODO.
| |
49 | 55 |
50 /// URI of the ".packages" file (typically a "file:" URI). | 56 /// URI of the ".packages" file (typically a "file:" URI). |
51 /// | 57 /// |
52 /// If `null`, the ".packages" file will be found via the standard | 58 /// If `null`, the ".packages" file will be found via the standard |
53 /// package_config search algorithm. | 59 /// package_config search algorithm. |
54 /// | 60 /// |
55 /// If the URI's path component is empty (e.g. `new Uri()`), no packages file | 61 /// If the URI's path component is empty (e.g. `new Uri()`), no packages file |
56 /// will be used. | 62 /// will be used. |
57 Uri packagesFileUri; | 63 Uri packagesFileUri; |
58 | 64 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 | 196 |
191 /// Whether to dump generated programs in a text format (also mainly for | 197 /// Whether to dump generated programs in a text format (also mainly for |
192 /// debugging). | 198 /// debugging). |
193 /// | 199 /// |
194 /// Dumped data is printed in stdout. | 200 /// Dumped data is printed in stdout. |
195 bool debugDump = false; | 201 bool debugDump = false; |
196 | 202 |
197 /// Whether to set the exit code to non-zero if any problem (including | 203 /// Whether to set the exit code to non-zero if any problem (including |
198 /// warning, etc.) is encountered during compilation. | 204 /// warning, etc.) is encountered during compilation. |
199 bool setExitCodeOnProblem = false; | 205 bool setExitCodeOnProblem = false; |
206 | |
207 /// Whether to generate kernel that excludes source informaton. | |
208 /// | |
209 /// When false, APIs that return a kernel `Program` include a | |
210 /// `uriToSource` map. | |
211 bool excludeSourceInformation = false; | |
212 | |
213 /// Whether errors are considered fatal and should stop the compiler. | |
214 bool errorsAreFatal = false; | |
Siggi Cherem (dart-lang)
2017/07/18 00:11:07
should this default to true?
ahe
2017/07/18 16:54:36
I don't think so. For both hot reloading and the a
Paul Berry
2017/07/18 18:36:21
Normally I agree with the notion of having the def
ahe
2017/07/18 21:07:26
As long as we make sure to set this to false for a
Siggi Cherem (dart-lang)
2017/07/18 22:50:43
OK - a few updates.
I changed the default as foll
| |
215 | |
216 /// Whether warnings are considered fatal and should stop the compiler. | |
217 bool warningsAreFatal = false; | |
218 | |
219 /// Whether errors are considered fatal and should stop the compiler. | |
220 bool nitsAreFatal = false; | |
ahe
2017/07/18 16:54:36
Note: all these "AreFatal" options are mostly used
Siggi Cherem (dart-lang)
2017/07/18 22:50:43
Done. Renamed to `throwOnX`
| |
200 } | 221 } |
OLD | NEW |