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 | |
9 import 'package:front_end/src/base/performace_logger.dart'; | 7 import 'package:front_end/src/base/performace_logger.dart'; |
10 import 'package:front_end/src/incremental/byte_store.dart'; | 8 import 'package:front_end/src/incremental/byte_store.dart'; |
11 | 9 |
12 import 'compilation_error.dart'; | 10 import 'compilation_error.dart'; |
13 import 'file_system.dart'; | 11 import 'file_system.dart'; |
14 import 'physical_file_system.dart'; | 12 import 'physical_file_system.dart'; |
15 import 'src/simple_error.dart'; | |
16 | 13 |
17 /// Default error handler used by [CompilerOptions.onError]. | 14 /// Default error handler used by [CompilerOptions.onError]. |
18 void defaultErrorHandler(CompilationError error) => throw error; | 15 void defaultErrorHandler(CompilationError error) => throw error; |
19 | 16 |
20 /// Callback used to report errors encountered during compilation. | 17 /// Callback used to report errors encountered during compilation. |
21 typedef void ErrorHandler(CompilationError error); | 18 typedef void ErrorHandler(CompilationError error); |
22 | 19 |
23 /// Front-end options relevant to compiler back ends. | 20 /// Front-end options relevant to compiler back ends. |
24 /// | 21 /// |
25 /// Not intended to be implemented or extended by clients. | 22 /// Not intended to be implemented or extended by clients. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 /// either absolute or relative URIs. Absolute URIs are read directly, while | 140 /// either absolute or relative URIs. Absolute URIs are read directly, while |
144 /// relative URIs are resolved from the [sdkRoot]. | 141 /// relative URIs are resolved from the [sdkRoot]. |
145 Map<Uri, List<Uri>> targetPatches = {}; | 142 Map<Uri, List<Uri>> targetPatches = {}; |
146 | 143 |
147 /// Additional core libraries to be loaded when building a program. | 144 /// Additional core libraries to be loaded when building a program. |
148 // TODO(sigmund): delete. Ideally building a program only needs what's | 145 // TODO(sigmund): delete. Ideally building a program only needs what's |
149 // reachable and we can use kernelForBuildUnit when creating a snapshot of the | 146 // reachable and we can use kernelForBuildUnit when creating a snapshot of the |
150 // SDK itself. | 147 // SDK itself. |
151 List<Uri> additionalLibraries = []; | 148 List<Uri> additionalLibraries = []; |
152 } | 149 } |
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 |