Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/dart2js.dart

Issue 11740025: Add dart2js option to select library categories. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix dartdoc and some unit tests Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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; 5 library dart2js;
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:uri'; 10 import 'dart:uri';
11 import 'dart:utf'; 11 import 'dart:utf';
12 12
13 import '../compiler.dart' as api; 13 import '../compiler.dart' as api;
14 import 'source_file.dart'; 14 import 'source_file.dart';
15 import 'source_file_provider.dart'; 15 import 'source_file_provider.dart';
16 import 'filenames.dart'; 16 import 'filenames.dart';
17 import 'util/uri_extras.dart'; 17 import 'util/uri_extras.dart';
18 import '../../libraries.dart';
18 19
19 const String LIBRARY_ROOT = '../../../../..'; 20 const String LIBRARY_ROOT = '../../../../..';
20 const String OUTPUT_LANGUAGE_DART = 'Dart'; 21 const String OUTPUT_LANGUAGE_DART = 'Dart';
21 22
22 typedef void HandleOption(String option); 23 typedef void HandleOption(String option);
23 24
24 class OptionHandler { 25 class OptionHandler {
25 String pattern; 26 String pattern;
26 HandleOption handle; 27 HandleOption handle;
27 28
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 setStrip(String argument) { 121 setStrip(String argument) {
121 stripArgumentSet = true; 122 stripArgumentSet = true;
122 passThrough(argument); 123 passThrough(argument);
123 } 124 }
124 125
125 setAnalyzeOnly(String argument) { 126 setAnalyzeOnly(String argument) {
126 analyzeOnly = true; 127 analyzeOnly = true;
127 passThrough(argument); 128 passThrough(argument);
128 } 129 }
129 130
131 setCategories(String argument) {
132 List<String> categories = extractParameter(argument).split(',');
133 Set<String> allowedCategories =
134 LIBRARIES.values.mappedBy((x) => x.category).toSet();
135 allowedCategories.remove('Shared');
136 allowedCategories.remove('Internal');
137 List<String> allowedCategoriesList =
138 new List<String>.from(allowedCategories);
139 allowedCategoriesList.sort();
140 if (categories.contains('all')) {
141 categories = allowedCategoriesList;
142 } else {
143 String allowedCategoriesString =
144 Strings.join(allowedCategoriesList, ', ');
145 for (String category in categories) {
146 if (!allowedCategories.contains(category)) {
147 fail('Error: unsupported library category "$category", '
148 'supported categories are: $allowedCategoriesString');
149 }
150 }
151 }
152 return passThrough('--categories=${Strings.join(categories, ",")}');
153 }
154
130 handleShortOptions(String argument) { 155 handleShortOptions(String argument) {
131 var shortOptions = argument.substring(1).splitChars(); 156 var shortOptions = argument.substring(1).splitChars();
132 for (var shortOption in shortOptions) { 157 for (var shortOption in shortOptions) {
133 switch (shortOption) { 158 switch (shortOption) {
134 case 'v': 159 case 'v':
135 diagnosticHandler.verbose = true; 160 diagnosticHandler.verbose = true;
136 break; 161 break;
137 case 'h': 162 case 'h':
138 case '?': 163 case '?':
139 wantHelp = true; 164 wantHelp = true;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), 198 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true),
174 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), 199 new OptionHandler('--package-root=.+|-p.+', setPackageRoot),
175 new OptionHandler('--disallow-unsafe-eval', passThrough), 200 new OptionHandler('--disallow-unsafe-eval', passThrough),
176 new OptionHandler('--analyze-all', passThrough), 201 new OptionHandler('--analyze-all', passThrough),
177 new OptionHandler('--analyze-only', setAnalyzeOnly), 202 new OptionHandler('--analyze-only', setAnalyzeOnly),
178 new OptionHandler('--disable-native-live-type-analysis', passThrough), 203 new OptionHandler('--disable-native-live-type-analysis', passThrough),
179 new OptionHandler('--enable-native-live-type-analysis', passThrough), 204 new OptionHandler('--enable-native-live-type-analysis', passThrough),
180 new OptionHandler('--reject-deprecated-language-features', passThrough), 205 new OptionHandler('--reject-deprecated-language-features', passThrough),
181 new OptionHandler('--report-sdk-use-of-deprecated-language-features', 206 new OptionHandler('--report-sdk-use-of-deprecated-language-features',
182 passThrough), 207 passThrough),
208 new OptionHandler('--categories=.*', setCategories),
183 209
184 // The following two options must come last. 210 // The following two options must come last.
185 new OptionHandler('-.*', (String argument) { 211 new OptionHandler('-.*', (String argument) {
186 helpAndFail('Error: Unknown option "$argument".'); 212 helpAndFail('Error: Unknown option "$argument".');
187 }), 213 }),
188 new OptionHandler('.*', (String argument) { 214 new OptionHandler('.*', (String argument) {
189 arguments.add(nativeToUriPath(argument)); 215 arguments.add(nativeToUriPath(argument));
190 }) 216 })
191 ]; 217 ];
192 218
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 according to The Dart Programming Language Specification, version 397 according to The Dart Programming Language Specification, version
372 0.12, M1. 398 0.12, M1.
373 399
374 --report-sdk-use-of-deprecated-language-features 400 --report-sdk-use-of-deprecated-language-features
375 Report use of deprecated features in Dart platform libraries. 401 Report use of deprecated features in Dart platform libraries.
376 Without this option, the compiler will silently accept use of 402 Without this option, the compiler will silently accept use of
377 deprecated language features from these libraries. The option 403 deprecated language features from these libraries. The option
378 --reject-deprecated-language-features controls if these usages are 404 --reject-deprecated-language-features controls if these usages are
379 reported as errors or warnings. 405 reported as errors or warnings.
380 406
407 --categories=<categories>
408
409 A comma separated list of allowed library categories. The default
410 is "Client". Possible categories can be seen by providing an
411 unsupported category, for example, --categories=help. To enable
412 all categories, use --categories=all.
413
381 '''.trim()); 414 '''.trim());
382 } 415 }
383 416
384 void helpAndExit(bool verbose) { 417 void helpAndExit(bool verbose) {
385 if (verbose) { 418 if (verbose) {
386 verboseHelp(); 419 verboseHelp();
387 } else { 420 } else {
388 help(); 421 help();
389 } 422 }
390 exit(0); 423 exit(0);
(...skipping 14 matching lines...) Expand all
405 } catch (ignored) { 438 } catch (ignored) {
406 print('Internal error: error while printing exception'); 439 print('Internal error: error while printing exception');
407 } 440 }
408 try { 441 try {
409 print(trace); 442 print(trace);
410 } finally { 443 } finally {
411 exit(253); // 253 is recognized as a crash by our test scripts. 444 exit(253); // 253 is recognized as a crash by our test scripts.
412 } 445 }
413 } 446 }
414 } 447 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/apiimpl.dart ('k') | dart/sdk/lib/_internal/dartdoc/lib/dartdoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698