OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.src.options; | 5 library dart2js.src.options; |
6 | 6 |
7 import '../compiler.dart' show PackagesDiscoveryProvider; | 7 import '../compiler.dart' show PackagesDiscoveryProvider; |
8 import 'commandline_options.dart' show Flags; | 8 import 'commandline_options.dart' show Flags; |
9 | 9 |
10 /// Options used for controlling diagnostic messages. | 10 /// Options used for controlling diagnostic messages. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 /// Whether to trust type annotations during inference and optimizations. | 196 /// Whether to trust type annotations during inference and optimizations. |
197 final bool trustTypeAnnotations; | 197 final bool trustTypeAnnotations; |
198 | 198 |
199 /// Whether to generate code compliant with content security policy (CSP). | 199 /// Whether to generate code compliant with content security policy (CSP). |
200 final bool useContentSecurityPolicy; | 200 final bool useContentSecurityPolicy; |
201 | 201 |
202 /// Whether to use kernel internally as part of compilation. | 202 /// Whether to use kernel internally as part of compilation. |
203 final bool useKernel; | 203 final bool useKernel; |
204 | 204 |
205 /// Read input from a .dill file rather than a .dart input (only to be used in | |
206 /// conjunction with useKernel = true). | |
207 final bool loadFromDill; | |
208 | |
209 // Whether to use kernel internally for global type inference calculations. | 205 // Whether to use kernel internally for global type inference calculations. |
210 // TODO(efortuna): Remove this and consolidate with useKernel. | 206 // TODO(efortuna): Remove this and consolidate with useKernel. |
211 final bool kernelGlobalInference; | 207 final bool kernelGlobalInference; |
212 | 208 |
213 /// When obfuscating for minification, whether to use the frequency of a name | 209 /// When obfuscating for minification, whether to use the frequency of a name |
214 /// as an heuristic to pick shorter names. | 210 /// as an heuristic to pick shorter names. |
215 final bool useFrequencyNamer; | 211 final bool useFrequencyNamer; |
216 | 212 |
217 /// Whether to generate source-information from both the old and the new | 213 /// Whether to generate source-information from both the old and the new |
218 /// source-information engines. (experimental) | 214 /// source-information engines. (experimental) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 sourceMapUri: _extractUriOption(options, '--source-map='), | 295 sourceMapUri: _extractUriOption(options, '--source-map='), |
300 strips: _extractCsvOption(options, '--force-strip='), | 296 strips: _extractCsvOption(options, '--force-strip='), |
301 testMode: _hasOption(options, Flags.testMode), | 297 testMode: _hasOption(options, Flags.testMode), |
302 trustJSInteropTypeAnnotations: | 298 trustJSInteropTypeAnnotations: |
303 _hasOption(options, Flags.trustJSInteropTypeAnnotations), | 299 _hasOption(options, Flags.trustJSInteropTypeAnnotations), |
304 trustPrimitives: _hasOption(options, Flags.trustPrimitives), | 300 trustPrimitives: _hasOption(options, Flags.trustPrimitives), |
305 trustTypeAnnotations: _hasOption(options, Flags.trustTypeAnnotations), | 301 trustTypeAnnotations: _hasOption(options, Flags.trustTypeAnnotations), |
306 useContentSecurityPolicy: | 302 useContentSecurityPolicy: |
307 _hasOption(options, Flags.useContentSecurityPolicy), | 303 _hasOption(options, Flags.useContentSecurityPolicy), |
308 useKernel: _hasOption(options, Flags.useKernel), | 304 useKernel: _hasOption(options, Flags.useKernel), |
309 loadFromDill: _hasOption(options, Flags.loadFromDill), | |
310 useFrequencyNamer: | 305 useFrequencyNamer: |
311 !_hasOption(options, Flags.noFrequencyBasedMinification), | 306 !_hasOption(options, Flags.noFrequencyBasedMinification), |
312 useMultiSourceInfo: _hasOption(options, Flags.useMultiSourceInfo), | 307 useMultiSourceInfo: _hasOption(options, Flags.useMultiSourceInfo), |
313 useNewSourceInfo: _hasOption(options, Flags.useNewSourceInfo), | 308 useNewSourceInfo: _hasOption(options, Flags.useNewSourceInfo), |
314 useStartupEmitter: _hasOption(options, Flags.fastStartup), | 309 useStartupEmitter: _hasOption(options, Flags.fastStartup), |
315 verbose: _hasOption(options, Flags.verbose)); | 310 verbose: _hasOption(options, Flags.verbose)); |
316 } | 311 } |
317 | 312 |
318 /// Creates an option object for the compiler. | 313 /// Creates an option object for the compiler. |
319 /// | 314 /// |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 Uri resolutionOutput: null, | 355 Uri resolutionOutput: null, |
361 bool resolveOnly: false, | 356 bool resolveOnly: false, |
362 Uri sourceMapUri: null, | 357 Uri sourceMapUri: null, |
363 List<String> strips: const [], | 358 List<String> strips: const [], |
364 bool testMode: false, | 359 bool testMode: false, |
365 bool trustJSInteropTypeAnnotations: false, | 360 bool trustJSInteropTypeAnnotations: false, |
366 bool trustPrimitives: false, | 361 bool trustPrimitives: false, |
367 bool trustTypeAnnotations: false, | 362 bool trustTypeAnnotations: false, |
368 bool useContentSecurityPolicy: false, | 363 bool useContentSecurityPolicy: false, |
369 bool useKernel: false, | 364 bool useKernel: false, |
370 bool loadFromDill: false, | |
371 bool useFrequencyNamer: true, | 365 bool useFrequencyNamer: true, |
372 bool useMultiSourceInfo: false, | 366 bool useMultiSourceInfo: false, |
373 bool useNewSourceInfo: false, | 367 bool useNewSourceInfo: false, |
374 bool useStartupEmitter: false, | 368 bool useStartupEmitter: false, |
375 bool verbose: false}) { | 369 bool verbose: false}) { |
376 // TODO(sigmund): should entrypoint be here? should we validate it is not | 370 // TODO(sigmund): should entrypoint be here? should we validate it is not |
377 // null? In unittests we use the same compiler to analyze or build multiple | 371 // null? In unittests we use the same compiler to analyze or build multiple |
378 // entrypoints. | 372 // entrypoints. |
379 if (libraryRoot == null) { | 373 if (libraryRoot == null) { |
380 throw new ArgumentError("[libraryRoot] is null."); | 374 throw new ArgumentError("[libraryRoot] is null."); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 resolutionOutput: resolutionOutput, | 427 resolutionOutput: resolutionOutput, |
434 resolveOnly: resolveOnly, | 428 resolveOnly: resolveOnly, |
435 sourceMapUri: sourceMapUri, | 429 sourceMapUri: sourceMapUri, |
436 strips: strips, | 430 strips: strips, |
437 testMode: testMode, | 431 testMode: testMode, |
438 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, | 432 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, |
439 trustPrimitives: trustPrimitives, | 433 trustPrimitives: trustPrimitives, |
440 trustTypeAnnotations: trustTypeAnnotations, | 434 trustTypeAnnotations: trustTypeAnnotations, |
441 useContentSecurityPolicy: useContentSecurityPolicy, | 435 useContentSecurityPolicy: useContentSecurityPolicy, |
442 useKernel: useKernel, | 436 useKernel: useKernel, |
443 loadFromDill: loadFromDill, | |
444 useFrequencyNamer: useFrequencyNamer, | 437 useFrequencyNamer: useFrequencyNamer, |
445 useMultiSourceInfo: useMultiSourceInfo, | 438 useMultiSourceInfo: useMultiSourceInfo, |
446 useNewSourceInfo: useNewSourceInfo, | 439 useNewSourceInfo: useNewSourceInfo, |
447 useStartupEmitter: useStartupEmitter, | 440 useStartupEmitter: useStartupEmitter, |
448 verbose: verbose); | 441 verbose: verbose); |
449 } | 442 } |
450 | 443 |
451 CompilerOptions._(this.entryPoint, this.libraryRoot, this.packageRoot, | 444 CompilerOptions._(this.entryPoint, this.libraryRoot, this.packageRoot, |
452 this.packageConfig, this.packagesDiscoveryProvider, this.environment, | 445 this.packageConfig, this.packagesDiscoveryProvider, this.environment, |
453 {this.allowMockCompilation: false, | 446 {this.allowMockCompilation: false, |
(...skipping 30 matching lines...) Expand all Loading... |
484 this.resolveOnly: false, | 477 this.resolveOnly: false, |
485 this.compileOnly: false, | 478 this.compileOnly: false, |
486 this.sourceMapUri: null, | 479 this.sourceMapUri: null, |
487 this.strips: const [], | 480 this.strips: const [], |
488 this.testMode: false, | 481 this.testMode: false, |
489 this.trustJSInteropTypeAnnotations: false, | 482 this.trustJSInteropTypeAnnotations: false, |
490 this.trustPrimitives: false, | 483 this.trustPrimitives: false, |
491 this.trustTypeAnnotations: false, | 484 this.trustTypeAnnotations: false, |
492 this.useContentSecurityPolicy: false, | 485 this.useContentSecurityPolicy: false, |
493 this.useKernel: false, | 486 this.useKernel: false, |
494 this.loadFromDill: false, | |
495 this.useFrequencyNamer: false, | 487 this.useFrequencyNamer: false, |
496 this.useMultiSourceInfo: false, | 488 this.useMultiSourceInfo: false, |
497 this.useNewSourceInfo: false, | 489 this.useNewSourceInfo: false, |
498 this.useStartupEmitter: false, | 490 this.useStartupEmitter: false, |
499 this.verbose: false}) | 491 this.verbose: false}) |
500 : _shownPackageWarnings = shownPackageWarnings; | 492 : _shownPackageWarnings = shownPackageWarnings; |
501 | 493 |
502 /// Creates a copy of the [CompilerOptions] where the provided non-null | 494 /// Creates a copy of the [CompilerOptions] where the provided non-null |
503 /// option values replace existing. | 495 /// option values replace existing. |
504 static CompilerOptions copy(CompilerOptions options, | 496 static CompilerOptions copy(CompilerOptions options, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 resolveOnly, | 534 resolveOnly, |
543 compileOnly, | 535 compileOnly, |
544 sourceMapUri, | 536 sourceMapUri, |
545 strips, | 537 strips, |
546 testMode, | 538 testMode, |
547 trustJSInteropTypeAnnotations, | 539 trustJSInteropTypeAnnotations, |
548 trustPrimitives, | 540 trustPrimitives, |
549 trustTypeAnnotations, | 541 trustTypeAnnotations, |
550 useContentSecurityPolicy, | 542 useContentSecurityPolicy, |
551 useKernel, | 543 useKernel, |
552 loadFromDill, | |
553 useFrequencyNamer, | 544 useFrequencyNamer, |
554 useMultiSourceInfo, | 545 useMultiSourceInfo, |
555 useNewSourceInfo, | 546 useNewSourceInfo, |
556 useStartupEmitter, | 547 useStartupEmitter, |
557 verbose}) { | 548 verbose}) { |
558 return new CompilerOptions._( | 549 return new CompilerOptions._( |
559 entryPoint ?? options.entryPoint, | 550 entryPoint ?? options.entryPoint, |
560 libraryRoot ?? options.libraryRoot, | 551 libraryRoot ?? options.libraryRoot, |
561 packageRoot ?? options.packageRoot, | 552 packageRoot ?? options.packageRoot, |
562 packageConfig ?? options.packageConfig, | 553 packageConfig ?? options.packageConfig, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 strips: strips ?? options.strips, | 601 strips: strips ?? options.strips, |
611 testMode: testMode ?? options.testMode, | 602 testMode: testMode ?? options.testMode, |
612 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations ?? | 603 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations ?? |
613 options.trustJSInteropTypeAnnotations, | 604 options.trustJSInteropTypeAnnotations, |
614 trustPrimitives: trustPrimitives ?? options.trustPrimitives, | 605 trustPrimitives: trustPrimitives ?? options.trustPrimitives, |
615 trustTypeAnnotations: | 606 trustTypeAnnotations: |
616 trustTypeAnnotations ?? options.trustTypeAnnotations, | 607 trustTypeAnnotations ?? options.trustTypeAnnotations, |
617 useContentSecurityPolicy: | 608 useContentSecurityPolicy: |
618 useContentSecurityPolicy ?? options.useContentSecurityPolicy, | 609 useContentSecurityPolicy ?? options.useContentSecurityPolicy, |
619 useKernel: useKernel ?? options.useKernel, | 610 useKernel: useKernel ?? options.useKernel, |
620 loadFromDill: loadFromDill ?? options.loadFromDill, | |
621 useFrequencyNamer: useFrequencyNamer ?? options.useFrequencyNamer, | 611 useFrequencyNamer: useFrequencyNamer ?? options.useFrequencyNamer, |
622 useMultiSourceInfo: useMultiSourceInfo ?? options.useMultiSourceInfo, | 612 useMultiSourceInfo: useMultiSourceInfo ?? options.useMultiSourceInfo, |
623 useNewSourceInfo: useNewSourceInfo ?? options.useNewSourceInfo, | 613 useNewSourceInfo: useNewSourceInfo ?? options.useNewSourceInfo, |
624 useStartupEmitter: useStartupEmitter ?? options.useStartupEmitter, | 614 useStartupEmitter: useStartupEmitter ?? options.useStartupEmitter, |
625 verbose: verbose ?? options.verbose); | 615 verbose: verbose ?? options.verbose); |
626 } | 616 } |
627 | 617 |
628 /// Returns `true` if warnings and hints are shown for all packages. | 618 /// Returns `true` if warnings and hints are shown for all packages. |
629 bool get showAllPackageWarnings { | 619 bool get showAllPackageWarnings { |
630 return _shownPackageWarnings != null && _shownPackageWarnings.isEmpty; | 620 return _shownPackageWarnings != null && _shownPackageWarnings.isEmpty; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 _extractStringOption(options, "--platform-config=", null), | 707 _extractStringOption(options, "--platform-config=", null), |
718 _extractCsvOption(options, '--categories=')); | 708 _extractCsvOption(options, '--categories=')); |
719 } | 709 } |
720 | 710 |
721 /// Locations of the platform descriptor files relative to the library root. | 711 /// Locations of the platform descriptor files relative to the library root. |
722 const String _clientPlatform = "lib/dart_client.platform"; | 712 const String _clientPlatform = "lib/dart_client.platform"; |
723 const String _serverPlatform = "lib/dart_server.platform"; | 713 const String _serverPlatform = "lib/dart_server.platform"; |
724 const String _sharedPlatform = "lib/dart_shared.platform"; | 714 const String _sharedPlatform = "lib/dart_shared.platform"; |
725 | 715 |
726 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; | 716 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; |
OLD | NEW |