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 'dart:async'; |
| 8 |
7 import 'package:front_end/src/base/performace_logger.dart'; | 9 import 'package:front_end/src/base/performace_logger.dart'; |
8 import 'package:front_end/src/incremental/byte_store.dart'; | 10 import 'package:front_end/src/incremental/byte_store.dart'; |
9 | 11 |
10 import 'compilation_error.dart'; | 12 import 'compilation_error.dart'; |
11 import 'file_system.dart'; | 13 import 'file_system.dart'; |
12 import 'physical_file_system.dart'; | 14 import 'physical_file_system.dart'; |
| 15 import 'src/simple_error.dart'; |
13 | 16 |
14 /// Default error handler used by [CompilerOptions.onError]. | 17 /// Default error handler used by [CompilerOptions.onError]. |
15 void defaultErrorHandler(CompilationError error) => throw error; | 18 void defaultErrorHandler(CompilationError error) => throw error; |
16 | 19 |
17 /// Callback used to report errors encountered during compilation. | 20 /// Callback used to report errors encountered during compilation. |
18 typedef void ErrorHandler(CompilationError error); | 21 typedef void ErrorHandler(CompilationError error); |
19 | 22 |
20 /// Front-end options relevant to compiler back ends. | 23 /// Front-end options relevant to compiler back ends. |
21 /// | 24 /// |
22 /// Not intended to be implemented or extended by clients. | 25 /// Not intended to be implemented or extended by clients. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 /// either absolute or relative URIs. Absolute URIs are read directly, while | 143 /// either absolute or relative URIs. Absolute URIs are read directly, while |
141 /// relative URIs are resolved from the [sdkRoot]. | 144 /// relative URIs are resolved from the [sdkRoot]. |
142 Map<Uri, List<Uri>> targetPatches = {}; | 145 Map<Uri, List<Uri>> targetPatches = {}; |
143 | 146 |
144 /// Additional core libraries to be loaded when building a program. | 147 /// Additional core libraries to be loaded when building a program. |
145 // TODO(sigmund): delete. Ideally building a program only needs what's | 148 // TODO(sigmund): delete. Ideally building a program only needs what's |
146 // reachable and we can use kernelForBuildUnit when creating a snapshot of the | 149 // reachable and we can use kernelForBuildUnit when creating a snapshot of the |
147 // SDK itself. | 150 // SDK itself. |
148 List<Uri> additionalLibraries = []; | 151 List<Uri> additionalLibraries = []; |
149 } | 152 } |
| 153 |
| 154 Future<bool> validateOptions(CompilerOptions options) async { |
| 155 var fs = options.fileSystem; |
| 156 var root = options.sdkRoot; |
| 157 |
| 158 bool _report(String msg) { |
| 159 options.onError(new SimpleError(msg)); |
| 160 return false; |
| 161 } |
| 162 |
| 163 if (root != null && !await fs.entityForUri(root).exists()) { |
| 164 return _report("SDK root directory not found: ${options.sdkRoot}"); |
| 165 } |
| 166 |
| 167 var summary = options.sdkSummary; |
| 168 if (summary != null && !await fs.entityForUri(summary).exists()) { |
| 169 return _report("SDK summary not found: ${options.sdkSummary}"); |
| 170 } |
| 171 |
| 172 return true; |
| 173 } |
OLD | NEW |