| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** General options used by the compiler. */ | 5 /** General options used by the compiler. */ |
| 6 FrogOptions options; | 6 FrogOptions options; |
| 7 | 7 |
| 8 /** Extracts options from command-line arguments. */ | 8 /** Extracts options from command-line arguments. */ |
| 9 void parseOptions(String homedir, List<String> args, FileSystem files) { | 9 void parseOptions(String homedir, List<String> args, FileSystem files) { |
| 10 assert(options == null); | 10 assert(options == null); |
| 11 options = new FrogOptions(homedir, args, files); | 11 options = new FrogOptions(homedir, args, files); |
| 12 } | 12 } |
| 13 | 13 |
| 14 // TODO(sigmund): make into a generic option parser... | 14 // TODO(sigmund): make into a generic option parser... |
| 15 class FrogOptions { | 15 class FrogOptions { |
| 16 /** Location of corelib and other special dart libraries. */ | 16 /** Location of corelib and other special dart libraries. */ |
| 17 String libDir; | 17 String libDir; |
| 18 | 18 |
| 19 /* The top-level dart script to compile. */ | 19 /* The top-level dart script to compile. */ |
| 20 String dartScript; | 20 String dartScript; |
| 21 | 21 |
| 22 /** Where to place the generated code. */ | 22 /** Where to place the generated code. */ |
| 23 String outfile; | 23 String outfile; |
| 24 | 24 |
| 25 // TODO(dgrove): fix this. For now, either 'sdk' or 'dev'. |
| 26 final config = 'dev'; |
| 27 |
| 25 // Options that modify behavior significantly | 28 // Options that modify behavior significantly |
| 26 bool enableLeg = false; | 29 bool enableLeg = false; |
| 27 bool legOnly = false; | 30 bool legOnly = false; |
| 28 bool enableAsserts = false; | 31 bool enableAsserts = false; |
| 29 bool enableTypeChecks = false; | 32 bool enableTypeChecks = false; |
| 30 bool verifyImplements = false; // TODO(jimhug): Implement | 33 bool verifyImplements = false; // TODO(jimhug): Implement |
| 31 bool compileAll = false; | 34 bool compileAll = false; |
| 32 bool dietParse = false; | 35 bool dietParse = false; |
| 33 bool compileOnly = false; | 36 bool compileOnly = false; |
| 34 | 37 |
| 35 // Message support | 38 // Message support |
| 36 bool throwOnErrors = false; | 39 bool throwOnErrors = false; |
| 37 bool throwOnWarnings = false; | 40 bool throwOnWarnings = false; |
| 38 bool throwOnFatal = false; | 41 bool throwOnFatal = false; |
| 39 bool showInfo = false; | 42 bool showInfo = false; |
| 40 bool showWarnings = true; | 43 bool showWarnings = true; |
| 41 | 44 |
| 42 /** | 45 /** |
| 43 * Options to be used later for passing to the generated code. These are all | 46 * Options to be used later for passing to the generated code. These are all |
| 44 * the arguments after the first dart script, if any. | 47 * the arguments after the first dart script, if any. |
| 45 */ | 48 */ |
| 46 List<String> childArgs; | 49 List<String> childArgs; |
| 47 | 50 |
| 48 FrogOptions(String homedir, List<String> args, FileSystem files) { | 51 FrogOptions(String homedir, List<String> args, FileSystem files) { |
| 49 libDir = homedir + '/lib'; // Default value for --libdir. | 52 if (config == 'dev') { |
| 53 libDir = joinPaths(homedir, '/lib'); // Default value for --libdir. |
| 54 } else if (config == 'sdk') { |
| 55 libDir = joinPaths(homedir, '/../lib/corelib/frog'); |
| 56 } else { |
| 57 world.error('Invalid reader configuration $config', null); |
| 58 throw('Invalid reader config'); |
| 59 } |
| 60 |
| 50 bool ignoreUnrecognizedFlags = false; | 61 bool ignoreUnrecognizedFlags = false; |
| 51 bool passedLibDir = false; | 62 bool passedLibDir = false; |
| 52 childArgs = []; | 63 childArgs = []; |
| 53 | 64 |
| 54 // Start from 2 to skip arguments representing the compiler command | 65 // Start from 2 to skip arguments representing the compiler command |
| 55 // (node/python followed by frogsh/frog.py). | 66 // (node/python followed by frogsh/frog.py). |
| 56 // TODO(jimhug): break on switch cases seems broken? | 67 // TODO(jimhug): break on switch cases seems broken? |
| 57 loop: for (int i = 2; i < args.length; i++) { | 68 loop: for (int i = 2; i < args.length; i++) { |
| 58 var arg = args[i]; | 69 var arg = args[i]; |
| 59 | 70 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 passedLibDir = true; | 137 passedLibDir = true; |
| 127 } else { | 138 } else { |
| 128 if (!ignoreUnrecognizedFlags) { | 139 if (!ignoreUnrecognizedFlags) { |
| 129 print('unrecognized flag: "$arg"'); | 140 print('unrecognized flag: "$arg"'); |
| 130 } | 141 } |
| 131 } | 142 } |
| 132 } | 143 } |
| 133 } | 144 } |
| 134 | 145 |
| 135 // TODO(jimhug): Remove this hack. | 146 // TODO(jimhug): Remove this hack. |
| 136 if (!passedLibDir && !files.fileExists(libDir)) { | 147 if (!passedLibDir && |
| 148 !files.fileExists(joinPaths(libDir, "/corelib.dart"))) { |
| 137 // Try locally | 149 // Try locally |
| 138 var temp = 'frog/lib'; | 150 var temp = 'frog/lib'; |
| 139 if (files.fileExists(temp)) { | 151 if (files.fileExists(temp)) { |
| 140 libDir = temp; | 152 libDir = temp; |
| 141 } else { | 153 } else { |
| 142 libDir = 'lib'; | 154 libDir = 'lib'; |
| 143 } | 155 } |
| 144 } | 156 } |
| 145 } | 157 } |
| 146 } | 158 } |
| OLD | NEW |