OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 /** General options used by the compiler. */ |
| 6 TemplateOptions options; |
| 7 |
| 8 /** Extracts options from command-line arguments. */ |
| 9 void parseOptions(List<String> args, var files) { |
| 10 assert(options == null); |
| 11 options = new TemplateOptions(args, files); |
| 12 } |
| 13 |
| 14 class TemplateOptions { |
| 15 /** Location of corelib and other special dart libraries. */ |
| 16 String libDir; |
| 17 |
| 18 /* The top-level dart script to compile. */ |
| 19 String dartScript; |
| 20 |
| 21 /** Where to place the generated code. */ |
| 22 String outfile; |
| 23 |
| 24 // Options that modify behavior significantly |
| 25 |
| 26 bool warningsAsErrors = false; |
| 27 bool checkOnly = false; |
| 28 |
| 29 // Message support |
| 30 bool throwOnErrors = false; |
| 31 bool throwOnWarnings = false; |
| 32 bool throwOnFatal = false; |
| 33 bool showInfo = false; |
| 34 bool showWarnings = true; |
| 35 bool useColors = true; |
| 36 |
| 37 /** |
| 38 * Options to be used later for passing to the generated code. These are all |
| 39 * the arguments after the first dart script, if any. |
| 40 */ |
| 41 List<String> childArgs; |
| 42 |
| 43 TemplateOptions(List<String> args, var files) { |
| 44 bool ignoreUnrecognizedFlags = false; |
| 45 bool passedLibDir = false; |
| 46 childArgs = []; |
| 47 |
| 48 // Start from 2 to skip arguments representing the compiler command |
| 49 // (node/python followed by frogsh/frog.py). |
| 50 loop: for (int i = 2; i < args.length; i++) { |
| 51 var arg = args[i]; |
| 52 |
| 53 switch (arg) { |
| 54 case '--check-only': |
| 55 checkOnly = true; |
| 56 break; |
| 57 |
| 58 case '--verbose': |
| 59 showInfo = true; |
| 60 break; |
| 61 |
| 62 case '--suppress_warnings': |
| 63 showWarnings = false; |
| 64 break; |
| 65 |
| 66 case '--warnings_as_errors': |
| 67 warningsAsErrors = true; |
| 68 break; |
| 69 |
| 70 case '--throw_on_errors': |
| 71 throwOnErrors = true; |
| 72 break; |
| 73 |
| 74 case '--throw_on_warnings': |
| 75 throwOnWarnings = true; |
| 76 break; |
| 77 |
| 78 case '--no_colors': |
| 79 useColors = false; |
| 80 break; |
| 81 |
| 82 case '--checked': |
| 83 checkOnly = true; |
| 84 break; |
| 85 |
| 86 default: |
| 87 if (!ignoreUnrecognizedFlags) { |
| 88 print('unrecognized flag: "$arg"'); |
| 89 } |
| 90 } |
| 91 } |
| 92 } |
| 93 } |
OLD | NEW |