Index: pkg/front_end/lib/compiler_options.dart |
diff --git a/pkg/front_end/lib/compiler_options.dart b/pkg/front_end/lib/compiler_options.dart |
index 8653baa02915515c847126e816f5d9e052d1ec23..c828a38f9f04a7f33ef26873a567ba57b6655901 100644 |
--- a/pkg/front_end/lib/compiler_options.dart |
+++ b/pkg/front_end/lib/compiler_options.dart |
@@ -4,9 +4,11 @@ |
library front_end.compiler_options; |
+import 'dart:async'; |
import 'compilation_error.dart'; |
import 'file_system.dart'; |
import 'physical_file_system.dart'; |
+import 'src/simple_error.dart'; |
/// Default error handler used by [CompilerOptions.onError]. |
void defaultErrorHandler(CompilationError error) => throw error; |
@@ -134,3 +136,24 @@ class CompilerOptions { |
// SDK itself. |
List<Uri> additionalLibraries = []; |
} |
+ |
+Future<bool> validateOptions(CompilerOptions options) async { |
Paul Berry
2017/05/03 22:22:26
These checks should be moved into ProcessedOptions
|
+ var fs = options.fileSystem; |
+ var root = options.sdkRoot; |
+ |
+ bool _report(String msg) { |
+ options.onError(new SimpleError(msg)); |
+ return false; |
+ } |
+ |
+ if (root != null && !await fs.entityForUri(root).exists()) { |
+ return _report("SDK root directory not found: ${options.sdkRoot}"); |
+ } |
+ |
+ var summary = options.sdkSummary; |
+ if (summary != null && !await fs.entityForUri(summary).exists()) { |
+ return _report("SDK summary not found: ${options.sdkSummary}"); |
+ } |
+ |
+ return true; |
+} |