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); |
(...skipping 26 matching lines...) Expand all Loading... |
37 bool forceDynamic = false; | 37 bool forceDynamic = false; |
38 bool dietParse = false; | 38 bool dietParse = false; |
39 bool compileOnly = false; | 39 bool compileOnly = false; |
40 | 40 |
41 // Message support | 41 // Message support |
42 bool throwOnErrors = false; | 42 bool throwOnErrors = false; |
43 bool throwOnWarnings = false; | 43 bool throwOnWarnings = false; |
44 bool throwOnFatal = false; | 44 bool throwOnFatal = false; |
45 bool showInfo = false; | 45 bool showInfo = false; |
46 bool showWarnings = true; | 46 bool showWarnings = true; |
| 47 bool useColors = true; |
47 | 48 |
48 /** | 49 /** |
49 * Options to be used later for passing to the generated code. These are all | 50 * Options to be used later for passing to the generated code. These are all |
50 * the arguments after the first dart script, if any. | 51 * the arguments after the first dart script, if any. |
51 */ | 52 */ |
52 List<String> childArgs; | 53 List<String> childArgs; |
53 | 54 |
54 FrogOptions(String homedir, List<String> args, FileSystem files) { | 55 FrogOptions(String homedir, List<String> args, FileSystem files) { |
55 if (config == 'dev') { | 56 if (config == 'dev') { |
56 libDir = joinPaths(homedir, '/lib'); // Default value for --libdir. | 57 libDir = joinPaths(homedir, '/lib'); // Default value for --libdir. |
57 } else if (config == 'sdk') { | 58 } else if (config == 'sdk') { |
58 libDir = joinPaths(homedir, '/../lib'); | 59 libDir = joinPaths(homedir, '/../lib'); |
59 } else { | 60 } else { |
60 world.error('Invalid configuration $config', null); | 61 world.error('Invalid configuration $config', null); |
61 throw('Invalid configuration'); | 62 throw('Invalid configuration'); |
62 } | 63 } |
63 | 64 |
64 bool ignoreUnrecognizedFlags = false; | 65 bool ignoreUnrecognizedFlags = false; |
65 bool passedLibDir = false; | 66 bool passedLibDir = false; |
66 childArgs = []; | 67 childArgs = []; |
67 | 68 |
68 // Start from 2 to skip arguments representing the compiler command | 69 // Start from 2 to skip arguments representing the compiler command |
69 // (node/python followed by frogsh/frog.py). | 70 // (node/python followed by frogsh/frog.py). |
70 // TODO(jimhug): break on switch cases seems broken? | |
71 loop: for (int i = 2; i < args.length; i++) { | 71 loop: for (int i = 2; i < args.length; i++) { |
72 var arg = args[i]; | 72 var arg = args[i]; |
73 | 73 |
74 switch (arg) { | 74 switch (arg) { |
75 case '--enable_leg': | 75 case '--enable_leg': |
76 enableLeg = true; | 76 enableLeg = true; |
77 continue loop; | 77 break; |
78 | 78 |
79 case '--leg_only': | 79 case '--leg_only': |
80 enableLeg = true; | 80 enableLeg = true; |
81 legOnly = true; | 81 legOnly = true; |
82 continue loop; | 82 break; |
83 | 83 |
84 case '--enable_asserts': | 84 case '--enable_asserts': |
85 enableAsserts = true; | 85 enableAsserts = true; |
86 continue loop; | 86 break; |
87 | 87 |
88 case '--enable_type_checks': | 88 case '--enable_type_checks': |
89 enableTypeChecks = true; | 89 enableTypeChecks = true; |
90 // This flag also enables asserts in VM | 90 // This flag also enables asserts in VM |
91 enableAsserts = true; | 91 enableAsserts = true; |
92 continue loop; | 92 break; |
93 | 93 |
94 case '--verify_implements': | 94 case '--verify_implements': |
95 verifyImplements = true; | 95 verifyImplements = true; |
96 continue loop; | 96 break; |
97 | 97 |
98 case '--compile_all': | 98 case '--compile_all': |
99 compileAll = true; | 99 compileAll = true; |
100 continue loop; | 100 break; |
101 | 101 |
102 case '--diet-parse': | 102 case '--diet-parse': |
103 dietParse = true; | 103 dietParse = true; |
104 continue loop; | 104 break; |
105 | 105 |
106 case '--ignore-unrecognized-flags': | 106 case '--ignore-unrecognized-flags': |
107 ignoreUnrecognizedFlags = true; | 107 ignoreUnrecognizedFlags = true; |
108 continue loop; | 108 break; |
109 | 109 |
110 case '--verbose': | 110 case '--verbose': |
111 showInfo = true; | 111 showInfo = true; |
112 continue loop; | 112 break; |
113 | 113 |
114 case '--suppress_warnings': | 114 case '--suppress_warnings': |
115 showWarnings = false; | 115 showWarnings = false; |
116 continue loop; | 116 break; |
117 | 117 |
118 case '--warnings_as_errors': | 118 case '--warnings_as_errors': |
119 warningsAsErrors = true; | 119 warningsAsErrors = true; |
120 continue loop; | 120 break; |
121 | 121 |
122 case '--throw_on_errors': | 122 case '--throw_on_errors': |
123 throwOnErrors = true; | 123 throwOnErrors = true; |
124 continue loop; | 124 break; |
125 | 125 |
126 case '--throw_on_warnings': | 126 case '--throw_on_warnings': |
127 throwOnWarnings = true; | 127 throwOnWarnings = true; |
128 continue loop; | 128 break; |
129 | 129 |
130 case '--compile-only': | 130 case '--compile-only': |
131 // As opposed to compiling and running, the default behavior. | 131 // As opposed to compiling and running, the default behavior. |
132 compileOnly = true; | 132 compileOnly = true; |
133 continue loop; | 133 break; |
134 | 134 |
135 case '--force_dynamic': | 135 case '--force_dynamic': |
136 forceDynamic = true; | 136 forceDynamic = true; |
137 continue loop; | 137 break; |
| 138 |
| 139 case '--no_colors': |
| 140 useColors = false; |
| 141 break; |
138 | 142 |
139 default: | 143 default: |
140 if (arg.endsWith('.dart')) { | 144 if (arg.endsWith('.dart')) { |
141 dartScript = arg; | 145 dartScript = arg; |
142 childArgs = args.getRange(i + 1, args.length - i - 1); | 146 childArgs = args.getRange(i + 1, args.length - i - 1); |
143 break loop; | 147 break loop; |
144 } else if (arg.startsWith('--out=')) { | 148 } else if (arg.startsWith('--out=')) { |
145 outfile = arg.substring('--out='.length); | 149 outfile = arg.substring('--out='.length); |
146 } else if (arg.startsWith('--libdir=')) { | 150 } else if (arg.startsWith('--libdir=')) { |
147 libDir = arg.substring('--libdir='.length); | 151 libDir = arg.substring('--libdir='.length); |
(...skipping 11 matching lines...) Expand all Loading... |
159 // Try locally | 163 // Try locally |
160 var temp = 'frog/lib'; | 164 var temp = 'frog/lib'; |
161 if (files.fileExists(temp)) { | 165 if (files.fileExists(temp)) { |
162 libDir = temp; | 166 libDir = temp; |
163 } else { | 167 } else { |
164 libDir = 'lib'; | 168 libDir = 'lib'; |
165 } | 169 } |
166 } | 170 } |
167 } | 171 } |
168 } | 172 } |
OLD | NEW |