OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.cmdline; | 5 library dart2js.cmdline; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection' show Queue, LinkedHashMap; | 8 import 'dart:collection' show Queue, LinkedHashMap; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:utf'; | 10 import 'dart:utf'; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 categories = allowedCategoriesList; | 158 categories = allowedCategoriesList; |
159 } else { | 159 } else { |
160 String allowedCategoriesString = allowedCategoriesList.join(', '); | 160 String allowedCategoriesString = allowedCategoriesList.join(', '); |
161 for (String category in categories) { | 161 for (String category in categories) { |
162 if (!allowedCategories.contains(category)) { | 162 if (!allowedCategories.contains(category)) { |
163 fail('Error: unsupported library category "$category", ' | 163 fail('Error: unsupported library category "$category", ' |
164 'supported categories are: $allowedCategoriesString'); | 164 'supported categories are: $allowedCategoriesString'); |
165 } | 165 } |
166 } | 166 } |
167 } | 167 } |
168 return passThrough('--categories=${categories.join(",")}'); | 168 passThrough('--categories=${categories.join(",")}'); |
169 } | |
170 | |
171 checkGlobalName(String argument) { | |
172 String globalName = extractParameter(argument); | |
173 if (!new RegExp(r'^\$[a-z]*$').hasMatch(globalName)) { | |
174 fail('Error: "$globalName" must match "\\\$[a-z]*"'); | |
ngeoffray
2013/05/28 20:01:54
Why? We could reserve the name in the namer.
ahe
2013/05/30 09:13:31
That wouldn't handle calling it "init", for exampl
| |
175 } | |
176 passThrough(argument); | |
169 } | 177 } |
170 | 178 |
171 handleShortOptions(String argument) { | 179 handleShortOptions(String argument) { |
172 var shortOptions = argument.substring(1).split(""); | 180 var shortOptions = argument.substring(1).split(""); |
173 for (var shortOption in shortOptions) { | 181 for (var shortOption in shortOptions) { |
174 switch (shortOption) { | 182 switch (shortOption) { |
175 case 'v': | 183 case 'v': |
176 setVerbose(null); | 184 setVerbose(null); |
177 break; | 185 break; |
178 case 'h': | 186 case 'h': |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), | 225 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), |
218 new OptionHandler('--disallow-unsafe-eval', passThrough), | 226 new OptionHandler('--disallow-unsafe-eval', passThrough), |
219 new OptionHandler('--analyze-all', passThrough), | 227 new OptionHandler('--analyze-all', passThrough), |
220 new OptionHandler('--analyze-only', setAnalyzeOnly), | 228 new OptionHandler('--analyze-only', setAnalyzeOnly), |
221 new OptionHandler('--analyze-signatures-only', passThrough), | 229 new OptionHandler('--analyze-signatures-only', passThrough), |
222 new OptionHandler('--disable-native-live-type-analysis', passThrough), | 230 new OptionHandler('--disable-native-live-type-analysis', passThrough), |
223 new OptionHandler('--reject-deprecated-language-features', passThrough), | 231 new OptionHandler('--reject-deprecated-language-features', passThrough), |
224 new OptionHandler('--report-sdk-use-of-deprecated-language-features', | 232 new OptionHandler('--report-sdk-use-of-deprecated-language-features', |
225 passThrough), | 233 passThrough), |
226 new OptionHandler('--categories=.*', setCategories), | 234 new OptionHandler('--categories=.*', setCategories), |
235 new OptionHandler('--global-js-name=.*', checkGlobalName), | |
227 | 236 |
228 // The following two options must come last. | 237 // The following two options must come last. |
229 new OptionHandler('-.*', (String argument) { | 238 new OptionHandler('-.*', (String argument) { |
230 helpAndFail('Error: Unknown option "$argument".'); | 239 helpAndFail('Error: Unknown option "$argument".'); |
231 }), | 240 }), |
232 new OptionHandler('.*', (String argument) { | 241 new OptionHandler('.*', (String argument) { |
233 arguments.add(nativeToUriPath(argument)); | 242 arguments.add(nativeToUriPath(argument)); |
234 }) | 243 }) |
235 ]; | 244 ]; |
236 | 245 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 | 397 |
389 Compiles Dart to JavaScript. | 398 Compiles Dart to JavaScript. |
390 | 399 |
391 Common options: | 400 Common options: |
392 -o<file> Generate the output into <file>. | 401 -o<file> Generate the output into <file>. |
393 -c Insert runtime type checks and enable assertions (checked mode). | 402 -c Insert runtime type checks and enable assertions (checked mode). |
394 -h Display this message (add -v for information about all options).'''); | 403 -h Display this message (add -v for information about all options).'''); |
395 } | 404 } |
396 | 405 |
397 void verboseHelp() { | 406 void verboseHelp() { |
398 print(''' | 407 print(r''' |
399 Usage: dart2js [options] dartfile | 408 Usage: dart2js [options] dartfile |
400 | 409 |
401 Compiles Dart to JavaScript. | 410 Compiles Dart to JavaScript. |
402 | 411 |
403 Supported options: | 412 Supported options: |
404 -o<file>, --out=<file> | 413 -o<file>, --out=<file> |
405 Generate the output into <file>. | 414 Generate the output into <file>. |
406 | 415 |
407 -c, --enable-checked-mode, --checked | 416 -c, --enable-checked-mode, --checked |
408 Insert runtime type checks and enable assertions (checked mode). | 417 Insert runtime type checks and enable assertions (checked mode). |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 deprecated language features from these libraries. The option | 486 deprecated language features from these libraries. The option |
478 --reject-deprecated-language-features controls if these usages are | 487 --reject-deprecated-language-features controls if these usages are |
479 reported as errors or warnings. | 488 reported as errors or warnings. |
480 | 489 |
481 --categories=<categories> | 490 --categories=<categories> |
482 A comma separated list of allowed library categories. The default | 491 A comma separated list of allowed library categories. The default |
483 is "Client". Possible categories can be seen by providing an | 492 is "Client". Possible categories can be seen by providing an |
484 unsupported category, for example, --categories=help. To enable | 493 unsupported category, for example, --categories=help. To enable |
485 all categories, use --categories=all. | 494 all categories, use --categories=all. |
486 | 495 |
496 --global-js-name=<name> | |
497 By default, dart2js generates JavaScript output that uses a global | |
498 variable named "$". The name of this global can be overridden | |
499 with this option. The name must match the regular expression "\$[a-z]*". | |
500 | |
487 '''.trim()); | 501 '''.trim()); |
488 } | 502 } |
489 | 503 |
490 void helpAndExit(bool verbose) { | 504 void helpAndExit(bool verbose) { |
491 if (verbose) { | 505 if (verbose) { |
492 verboseHelp(); | 506 verboseHelp(); |
493 } else { | 507 } else { |
494 help(); | 508 help(); |
495 } | 509 } |
496 exit(0); | 510 exit(0); |
(...skipping 18 matching lines...) Expand all Loading... | |
515 print(trace); | 529 print(trace); |
516 } finally { | 530 } finally { |
517 exit(253); // 253 is recognized as a crash by our test scripts. | 531 exit(253); // 253 is recognized as a crash by our test scripts. |
518 } | 532 } |
519 } | 533 } |
520 } | 534 } |
521 | 535 |
522 void main() { | 536 void main() { |
523 mainWithErrorHandler(new Options()); | 537 mainWithErrorHandler(new Options()); |
524 } | 538 } |
OLD | NEW |