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

Side by Side Diff: pkg/compiler/lib/src/apiimpl.dart

Issue 1314833003: Shared commandline flags. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 3 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/commandline_options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 leg_apiimpl; 5 library leg_apiimpl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:package_config/packages.dart'; 10 import 'package:package_config/packages.dart';
11 import 'package:package_config/packages_file.dart' as pkgs; 11 import 'package:package_config/packages_file.dart' as pkgs;
12 import 'package:package_config/src/packages_impl.dart' show 12 import 'package:package_config/src/packages_impl.dart' show
13 MapPackages, 13 MapPackages,
14 NonFilePackagesDirectoryPackages; 14 NonFilePackagesDirectoryPackages;
15 import 'package:package_config/src/util.dart' show 15 import 'package:package_config/src/util.dart' show
16 checkValidPackageUri; 16 checkValidPackageUri;
17 import 'package:sdk_library_metadata/libraries.dart' hide LIBRARIES; 17 import 'package:sdk_library_metadata/libraries.dart' hide LIBRARIES;
18 import 'package:sdk_library_metadata/libraries.dart' as library_info show 18 import 'package:sdk_library_metadata/libraries.dart' as library_info show
19 LIBRARIES; 19 LIBRARIES;
20 20
21 import '../compiler_new.dart' as api; 21 import '../compiler_new.dart' as api;
22 import 'commandline_options.dart';
22 import 'common/tasks.dart' show 23 import 'common/tasks.dart' show
23 GenericTask; 24 GenericTask;
24 import 'compiler.dart' as leg; 25 import 'compiler.dart' as leg;
25 import 'diagnostics/messages.dart'; 26 import 'diagnostics/messages.dart';
26 import 'diagnostics/source_span.dart' show 27 import 'diagnostics/source_span.dart' show
27 SourceSpan; 28 SourceSpan;
28 import 'diagnostics/spannable.dart' show 29 import 'diagnostics/spannable.dart' show
29 NO_LOCATION_SPANNABLE, 30 NO_LOCATION_SPANNABLE,
30 Spannable; 31 Spannable;
31 import 'elements/elements.dart' as elements; 32 import 'elements/elements.dart' as elements;
(...skipping 27 matching lines...) Expand all
59 this.libraryRoot, 60 this.libraryRoot,
60 this.packageRoot, 61 this.packageRoot,
61 List<String> options, 62 List<String> options,
62 this.environment, 63 this.environment,
63 [this.packageConfig, 64 [this.packageConfig,
64 this.packagesDiscoveryProvider]) 65 this.packagesDiscoveryProvider])
65 : this.options = options, 66 : this.options = options,
66 this.allowedLibraryCategories = getAllowedLibraryCategories(options), 67 this.allowedLibraryCategories = getAllowedLibraryCategories(options),
67 super( 68 super(
68 outputProvider: outputProvider, 69 outputProvider: outputProvider,
69 enableTypeAssertions: hasOption(options, '--enable-checked-mode'), 70 enableTypeAssertions: hasOption(options, Flags.enableCheckedMode),
70 enableUserAssertions: hasOption(options, '--enable-checked-mode'), 71 enableUserAssertions: hasOption(options, Flags.enableCheckedMode),
71 trustTypeAnnotations: 72 trustTypeAnnotations:
72 hasOption(options, '--trust-type-annotations'), 73 hasOption(options, Flags.trustTypeAnnotations),
73 trustPrimitives: 74 trustPrimitives:
74 hasOption(options, '--trust-primitives'), 75 hasOption(options, Flags.trustPrimitives),
75 enableMinification: hasOption(options, '--minify'), 76 enableMinification: hasOption(options, Flags.minify),
76 useFrequencyNamer: 77 useFrequencyNamer:
77 !hasOption(options, "--no-frequency-based-minification"), 78 !hasOption(options, Flags.noFrequencyBasedMinification),
78 preserveUris: hasOption(options, '--preserve-uris'), 79 preserveUris: hasOption(options, Flags.preserveUris),
79 enableNativeLiveTypeAnalysis: 80 enableNativeLiveTypeAnalysis:
80 !hasOption(options, '--disable-native-live-type-analysis'), 81 !hasOption(options, Flags.disableNativeLiveTypeAnalysis),
81 emitJavaScript: !(hasOption(options, '--output-type=dart') || 82 emitJavaScript: !(hasOption(options, '--output-type=dart') ||
82 hasOption(options, '--output-type=dart-multi')), 83 hasOption(options, '--output-type=dart-multi')),
83 dart2dartMultiFile: hasOption(options, '--output-type=dart-multi'), 84 dart2dartMultiFile: hasOption(options, '--output-type=dart-multi'),
84 generateSourceMap: !hasOption(options, '--no-source-maps'), 85 generateSourceMap: !hasOption(options, Flags.noSourceMaps),
85 analyzeAllFlag: hasOption(options, '--analyze-all'), 86 analyzeAllFlag: hasOption(options, Flags.analyzeAll),
86 analyzeOnly: hasOption(options, '--analyze-only'), 87 analyzeOnly: hasOption(options, Flags.analyzeOnly),
87 analyzeMain: hasOption(options, '--analyze-main'), 88 analyzeMain: hasOption(options, Flags.analyzeMain),
88 analyzeSignaturesOnly: 89 analyzeSignaturesOnly:
89 hasOption(options, '--analyze-signatures-only'), 90 hasOption(options, Flags.analyzeSignaturesOnly),
90 strips: extractCsvOption(options, '--force-strip='), 91 strips: extractCsvOption(options, '--force-strip='),
91 enableConcreteTypeInference: 92 enableConcreteTypeInference:
92 hasOption(options, '--enable-concrete-type-inference'), 93 hasOption(options, Flags.enableConcreteTypeInference),
93 disableTypeInferenceFlag: 94 disableTypeInferenceFlag:
94 hasOption(options, '--disable-type-inference'), 95 hasOption(options, Flags.disableTypeInference),
95 preserveComments: hasOption(options, '--preserve-comments'), 96 preserveComments: hasOption(options, Flags.preserveComments),
96 useCpsIr: hasOption(options, '--use-cps-ir'), 97 useCpsIr: hasOption(options, Flags.useCpsIr),
97 verbose: hasOption(options, '--verbose'), 98 verbose: hasOption(options, Flags.verbose),
98 sourceMapUri: extractUriOption(options, '--source-map='), 99 sourceMapUri: extractUriOption(options, '--source-map='),
99 outputUri: extractUriOption(options, '--out='), 100 outputUri: extractUriOption(options, '--out='),
100 terseDiagnostics: hasOption(options, '--terse'), 101 terseDiagnostics: hasOption(options, Flags.terse),
101 deferredMapUri: extractUriOption(options, '--deferred-map='), 102 deferredMapUri: extractUriOption(options, '--deferred-map='),
102 dumpInfo: hasOption(options, '--dump-info'), 103 dumpInfo: hasOption(options, Flags.dumpInfo),
103 buildId: extractStringOption( 104 buildId: extractStringOption(
104 options, '--build-id=', 105 options, '--build-id=',
105 "build number could not be determined"), 106 "build number could not be determined"),
106 showPackageWarnings: 107 showPackageWarnings:
107 hasOption(options, '--show-package-warnings'), 108 hasOption(options, Flags.showPackageWarnings),
108 useContentSecurityPolicy: hasOption(options, '--csp'), 109 useContentSecurityPolicy:
109 useStartupEmitter: hasOption(options, '--fast-startup'), 110 hasOption(options, Flags.useContentSecurityPolicy),
111 useStartupEmitter: hasOption(options, Flags.fastStartup),
110 hasIncrementalSupport: 112 hasIncrementalSupport:
111 forceIncrementalSupport || 113 forceIncrementalSupport ||
112 hasOption(options, '--incremental-support'), 114 hasOption(options, Flags.incrementalSupport),
113 suppressWarnings: hasOption(options, '--suppress-warnings'), 115 suppressWarnings: hasOption(options, Flags.suppressWarnings),
114 fatalWarnings: hasOption(options, '--fatal-warnings'), 116 fatalWarnings: hasOption(options, Flags.fatalWarnings),
115 enableExperimentalMirrors: 117 enableExperimentalMirrors:
116 hasOption(options, '--enable-experimental-mirrors'), 118 hasOption(options, Flags.enableExperimentalMirrors),
117 generateCodeWithCompileTimeErrors: 119 generateCodeWithCompileTimeErrors:
118 hasOption(options, '--generate-code-with-compile-time-errors'), 120 hasOption(options, Flags.generateCodeWithCompileTimeErrors),
119 testMode: hasOption(options, '--test-mode'), 121 testMode: hasOption(options, Flags.testMode),
120 allowNativeExtensions: 122 allowNativeExtensions:
121 hasOption(options, '--allow-native-extensions')) { 123 hasOption(options, Flags.allowNativeExtensions)) {
122 tasks.addAll([ 124 tasks.addAll([
123 userHandlerTask = new GenericTask('Diagnostic handler', this), 125 userHandlerTask = new GenericTask('Diagnostic handler', this),
124 userProviderTask = new GenericTask('Input provider', this), 126 userProviderTask = new GenericTask('Input provider', this),
125 userPackagesDiscoveryTask = 127 userPackagesDiscoveryTask =
126 new GenericTask('Package discovery', this), 128 new GenericTask('Package discovery', this),
127 ]); 129 ]);
128 if (libraryRoot == null) { 130 if (libraryRoot == null) {
129 throw new ArgumentError("[libraryRoot] is null."); 131 throw new ArgumentError("[libraryRoot] is null.");
130 } 132 }
131 if (!libraryRoot.path.endsWith("/")) { 133 if (!libraryRoot.path.endsWith("/")) {
132 throw new ArgumentError("[libraryRoot] must end with a /."); 134 throw new ArgumentError("[libraryRoot] must end with a /.");
133 } 135 }
134 if (packageRoot != null && packageConfig != null) { 136 if (packageRoot != null && packageConfig != null) {
135 throw new ArgumentError("Only one of [packageRoot] or [packageConfig] " 137 throw new ArgumentError("Only one of [packageRoot] or [packageConfig] "
136 "may be given."); 138 "may be given.");
137 } 139 }
138 if (packageRoot != null && !packageRoot.path.endsWith("/")) { 140 if (packageRoot != null && !packageRoot.path.endsWith("/")) {
139 throw new ArgumentError("[packageRoot] must end with a /."); 141 throw new ArgumentError("[packageRoot] must end with a /.");
140 } 142 }
141 if (!analyzeOnly) { 143 if (!analyzeOnly) {
142 if (allowNativeExtensions) { 144 if (allowNativeExtensions) {
143 throw new ArgumentError( 145 throw new ArgumentError(
144 "--allow-native-extensions is only supported in combination with " 146 "${Flags.allowNativeExtensions} is only supported in combination "
145 "--analyze-only"); 147 "with ${Flags.analyzeOnly}");
146 } 148 }
147 } 149 }
148 } 150 }
149 151
150 static String extractStringOption(List<String> options, 152 static String extractStringOption(List<String> options,
151 String prefix, 153 String prefix,
152 String defaultValue) { 154 String defaultValue) {
153 for (String option in options) { 155 for (String option in options) {
154 if (option.startsWith(prefix)) { 156 if (option.startsWith(prefix)) {
155 return option.substring(prefix.length); 157 return option.substring(prefix.length);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 if (span == null || span.uri == null) { 467 if (span == null || span.uri == null) {
466 callUserHandler(message, null, null, null, '$message', kind); 468 callUserHandler(message, null, null, null, '$message', kind);
467 } else { 469 } else {
468 callUserHandler( 470 callUserHandler(
469 message, span.uri, span.begin, span.end, '$message', kind); 471 message, span.uri, span.begin, span.end, '$message', kind);
470 } 472 }
471 } 473 }
472 474
473 bool get isMockCompilation { 475 bool get isMockCompilation {
474 return mockableLibraryUsed 476 return mockableLibraryUsed
475 && (options.indexOf('--allow-mock-compilation') != -1); 477 && (options.indexOf(Flags.allowMockCompilation) != -1);
476 } 478 }
477 479
478 void callUserHandler(Message message, Uri uri, int begin, int end, 480 void callUserHandler(Message message, Uri uri, int begin, int end,
479 String text, api.Diagnostic kind) { 481 String text, api.Diagnostic kind) {
480 try { 482 try {
481 userHandlerTask.measure(() { 483 userHandlerTask.measure(() {
482 handler.report(message, uri, begin, end, text, kind); 484 handler.report(message, uri, begin, end, text, kind);
483 }); 485 });
484 } catch (ex, s) { 486 } catch (ex, s) {
485 diagnoseCrashInUserCode( 487 diagnoseCrashInUserCode(
(...skipping 26 matching lines...) Expand all
512 print('$message: ${tryToString(exception)}'); 514 print('$message: ${tryToString(exception)}');
513 print(tryToString(stackTrace)); 515 print(tryToString(stackTrace));
514 } 516 }
515 517
516 fromEnvironment(String name) => environment[name]; 518 fromEnvironment(String name) => environment[name];
517 519
518 LibraryInfo lookupLibraryInfo(String libraryName) { 520 LibraryInfo lookupLibraryInfo(String libraryName) {
519 return library_info.LIBRARIES[libraryName]; 521 return library_info.LIBRARIES[libraryName];
520 } 522 }
521 } 523 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/commandline_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698