| 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 'commandline_options.dart' show Flags; | 7 import 'commandline_options.dart' show Flags; |
| 8 import '../compiler.dart' show PackagesDiscoveryProvider; | 8 import '../compiler.dart' show PackagesDiscoveryProvider; |
| 9 | 9 |
| 10 /// Options used for parsing. | 10 /// Options used for parsing. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 /// URI of the main output if the compiler is generating source maps. | 181 /// URI of the main output if the compiler is generating source maps. |
| 182 final Uri outputUri; | 182 final Uri outputUri; |
| 183 | 183 |
| 184 /// Location of the platform configuration file. | 184 /// Location of the platform configuration file. |
| 185 final Uri platformConfigUri; | 185 final Uri platformConfigUri; |
| 186 | 186 |
| 187 /// Whether to emit URIs in the reflection metadata. | 187 /// Whether to emit URIs in the reflection metadata. |
| 188 final bool preserveUris; | 188 final bool preserveUris; |
| 189 | 189 |
| 190 /// The location of serialized data used for resolution. |
| 191 final Uri resolutionInput; |
| 192 |
| 193 /// The location of the serialized data from resolution. |
| 194 final Uri resolutionOutput; |
| 195 |
| 196 // If `true`, sources are resolved and serialized. |
| 197 final bool resolveOnly; |
| 198 |
| 190 /// URI where the compiler should generate the output source map file. | 199 /// URI where the compiler should generate the output source map file. |
| 191 final Uri sourceMapUri; | 200 final Uri sourceMapUri; |
| 192 | 201 |
| 193 /// The compiler is run from the build bot. | 202 /// The compiler is run from the build bot. |
| 194 final bool testMode; | 203 final bool testMode; |
| 195 | 204 |
| 196 /// Whether to trust JS-interop annotations. (experimental) | 205 /// Whether to trust JS-interop annotations. (experimental) |
| 197 final bool trustJSInteropTypeAnnotations; | 206 final bool trustJSInteropTypeAnnotations; |
| 198 | 207 |
| 199 /// Whether to trust primitive types during inference and optimizations. | 208 /// Whether to trust primitive types during inference and optimizations. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 249 |
| 241 /// Strip option used by dart2dart. | 250 /// Strip option used by dart2dart. |
| 242 final List<String> strips; | 251 final List<String> strips; |
| 243 | 252 |
| 244 /// Create an options object by parsing flags from [options]. | 253 /// Create an options object by parsing flags from [options]. |
| 245 factory CompilerOptions.parse( | 254 factory CompilerOptions.parse( |
| 246 {Uri entryPoint, | 255 {Uri entryPoint, |
| 247 Uri libraryRoot, | 256 Uri libraryRoot, |
| 248 Uri packageRoot, | 257 Uri packageRoot, |
| 249 Uri packageConfig, | 258 Uri packageConfig, |
| 259 Uri resolutionInput, |
| 260 Uri resolutionOutput, |
| 250 PackagesDiscoveryProvider packagesDiscoveryProvider, | 261 PackagesDiscoveryProvider packagesDiscoveryProvider, |
| 251 Map<String, dynamic> environment: const <String, dynamic>{}, | 262 Map<String, dynamic> environment: const <String, dynamic>{}, |
| 252 List<String> options}) { | 263 List<String> options}) { |
| 253 return new CompilerOptions( | 264 return new CompilerOptions( |
| 254 entryPoint: entryPoint, | 265 entryPoint: entryPoint, |
| 255 libraryRoot: libraryRoot, | 266 libraryRoot: libraryRoot, |
| 256 packageRoot: packageRoot, | 267 packageRoot: packageRoot, |
| 257 packageConfig: packageConfig, | 268 packageConfig: packageConfig, |
| 258 packagesDiscoveryProvider: packagesDiscoveryProvider, | 269 packagesDiscoveryProvider: packagesDiscoveryProvider, |
| 259 environment: environment, | 270 environment: environment, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 generateCodeWithCompileTimeErrors: | 302 generateCodeWithCompileTimeErrors: |
| 292 _hasOption(options, Flags.generateCodeWithCompileTimeErrors), | 303 _hasOption(options, Flags.generateCodeWithCompileTimeErrors), |
| 293 generateSourceMap: !_hasOption(options, Flags.noSourceMaps), | 304 generateSourceMap: !_hasOption(options, Flags.noSourceMaps), |
| 294 hasIncrementalSupport: _forceIncrementalSupport || | 305 hasIncrementalSupport: _forceIncrementalSupport || |
| 295 _hasOption(options, Flags.incrementalSupport), | 306 _hasOption(options, Flags.incrementalSupport), |
| 296 outputUri: _extractUriOption(options, '--out='), | 307 outputUri: _extractUriOption(options, '--out='), |
| 297 platformConfigUri: | 308 platformConfigUri: |
| 298 _resolvePlatformConfigFromOptions(libraryRoot, options), | 309 _resolvePlatformConfigFromOptions(libraryRoot, options), |
| 299 preserveComments: _hasOption(options, Flags.preserveComments), | 310 preserveComments: _hasOption(options, Flags.preserveComments), |
| 300 preserveUris: _hasOption(options, Flags.preserveUris), | 311 preserveUris: _hasOption(options, Flags.preserveUris), |
| 312 resolutionInput: resolutionInput, |
| 313 resolutionOutput: resolutionOutput, |
| 314 resolveOnly: _hasOption(options, Flags.resolveOnly), |
| 301 sourceMapUri: _extractUriOption(options, '--source-map='), | 315 sourceMapUri: _extractUriOption(options, '--source-map='), |
| 302 strips: _extractCsvOption(options, '--force-strip='), | 316 strips: _extractCsvOption(options, '--force-strip='), |
| 303 testMode: _hasOption(options, Flags.testMode), | 317 testMode: _hasOption(options, Flags.testMode), |
| 304 trustJSInteropTypeAnnotations: | 318 trustJSInteropTypeAnnotations: |
| 305 _hasOption(options, Flags.trustJSInteropTypeAnnotations), | 319 _hasOption(options, Flags.trustJSInteropTypeAnnotations), |
| 306 trustPrimitives: _hasOption(options, Flags.trustPrimitives), | 320 trustPrimitives: _hasOption(options, Flags.trustPrimitives), |
| 307 trustTypeAnnotations: _hasOption(options, Flags.trustTypeAnnotations), | 321 trustTypeAnnotations: _hasOption(options, Flags.trustTypeAnnotations), |
| 308 useContentSecurityPolicy: | 322 useContentSecurityPolicy: |
| 309 _hasOption(options, Flags.useContentSecurityPolicy), | 323 _hasOption(options, Flags.useContentSecurityPolicy), |
| 310 useCpsIr: _hasOption(options, Flags.useCpsIr), | 324 useCpsIr: _hasOption(options, Flags.useCpsIr), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 bool enableNativeLiveTypeAnalysis: true, | 366 bool enableNativeLiveTypeAnalysis: true, |
| 353 bool enableTypeAssertions: false, | 367 bool enableTypeAssertions: false, |
| 354 bool enableUserAssertions: false, | 368 bool enableUserAssertions: false, |
| 355 bool generateCodeWithCompileTimeErrors: false, | 369 bool generateCodeWithCompileTimeErrors: false, |
| 356 bool generateSourceMap: true, | 370 bool generateSourceMap: true, |
| 357 bool hasIncrementalSupport: false, | 371 bool hasIncrementalSupport: false, |
| 358 Uri outputUri: null, | 372 Uri outputUri: null, |
| 359 Uri platformConfigUri: null, | 373 Uri platformConfigUri: null, |
| 360 bool preserveComments: false, | 374 bool preserveComments: false, |
| 361 bool preserveUris: false, | 375 bool preserveUris: false, |
| 376 Uri resolutionInput: null, |
| 377 Uri resolutionOutput: null, |
| 378 bool resolveOnly: false, |
| 362 Uri sourceMapUri: null, | 379 Uri sourceMapUri: null, |
| 363 List<String> strips: const [], | 380 List<String> strips: const [], |
| 364 bool testMode: false, | 381 bool testMode: false, |
| 365 bool trustJSInteropTypeAnnotations: false, | 382 bool trustJSInteropTypeAnnotations: false, |
| 366 bool trustPrimitives: false, | 383 bool trustPrimitives: false, |
| 367 bool trustTypeAnnotations: false, | 384 bool trustTypeAnnotations: false, |
| 368 bool useContentSecurityPolicy: false, | 385 bool useContentSecurityPolicy: false, |
| 369 bool useCpsIr: false, | 386 bool useCpsIr: false, |
| 370 bool useFrequencyNamer: true, | 387 bool useFrequencyNamer: true, |
| 371 bool useNewSourceInfo: false, | 388 bool useNewSourceInfo: false, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 391 if (allowNativeExtensions) { | 408 if (allowNativeExtensions) { |
| 392 throw new ArgumentError( | 409 throw new ArgumentError( |
| 393 "${Flags.allowNativeExtensions} is only supported in combination " | 410 "${Flags.allowNativeExtensions} is only supported in combination " |
| 394 "with ${Flags.analyzeOnly}"); | 411 "with ${Flags.analyzeOnly}"); |
| 395 } | 412 } |
| 396 } | 413 } |
| 397 return new CompilerOptions._(entryPoint, libraryRoot, packageRoot, | 414 return new CompilerOptions._(entryPoint, libraryRoot, packageRoot, |
| 398 packageConfig, packagesDiscoveryProvider, environment, | 415 packageConfig, packagesDiscoveryProvider, environment, |
| 399 allowMockCompilation: allowMockCompilation, | 416 allowMockCompilation: allowMockCompilation, |
| 400 allowNativeExtensions: allowNativeExtensions, | 417 allowNativeExtensions: allowNativeExtensions, |
| 401 analyzeAll: analyzeAll, | 418 analyzeAll: analyzeAll || resolveOnly, |
| 402 analyzeMain: analyzeMain, | 419 analyzeMain: analyzeMain, |
| 403 analyzeOnly: analyzeOnly || analyzeSignaturesOnly || analyzeAll, | 420 analyzeOnly: |
| 421 analyzeOnly || analyzeSignaturesOnly || analyzeAll || resolveOnly, |
| 404 analyzeSignaturesOnly: analyzeSignaturesOnly, | 422 analyzeSignaturesOnly: analyzeSignaturesOnly, |
| 405 buildId: buildId, | 423 buildId: buildId, |
| 406 dart2dartMultiFile: dart2dartMultiFile, | 424 dart2dartMultiFile: dart2dartMultiFile, |
| 407 deferredMapUri: deferredMapUri, | 425 deferredMapUri: deferredMapUri, |
| 408 fatalWarnings: fatalWarnings, | 426 fatalWarnings: fatalWarnings, |
| 409 terseDiagnostics: terseDiagnostics, | 427 terseDiagnostics: terseDiagnostics, |
| 410 suppressWarnings: suppressWarnings, | 428 suppressWarnings: suppressWarnings, |
| 411 suppressHints: suppressHints, | 429 suppressHints: suppressHints, |
| 412 shownPackageWarnings: shownPackageWarnings, | 430 shownPackageWarnings: shownPackageWarnings, |
| 413 disableInlining: disableInlining || hasIncrementalSupport, | 431 disableInlining: disableInlining || hasIncrementalSupport, |
| 414 disableTypeInference: disableTypeInference || !emitJavaScript, | 432 disableTypeInference: disableTypeInference || !emitJavaScript, |
| 415 dumpInfo: dumpInfo, | 433 dumpInfo: dumpInfo, |
| 416 emitJavaScript: emitJavaScript, | 434 emitJavaScript: emitJavaScript, |
| 417 enableAssertMessage: enableAssertMessage, | 435 enableAssertMessage: enableAssertMessage, |
| 418 enableGenericMethodSyntax: enableGenericMethodSyntax, | 436 enableGenericMethodSyntax: enableGenericMethodSyntax, |
| 419 enableExperimentalMirrors: enableExperimentalMirrors, | 437 enableExperimentalMirrors: enableExperimentalMirrors, |
| 420 enableMinification: enableMinification, | 438 enableMinification: enableMinification, |
| 421 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis, | 439 enableNativeLiveTypeAnalysis: enableNativeLiveTypeAnalysis, |
| 422 enableTypeAssertions: enableTypeAssertions, | 440 enableTypeAssertions: enableTypeAssertions, |
| 423 enableUserAssertions: enableUserAssertions, | 441 enableUserAssertions: enableUserAssertions, |
| 424 generateCodeWithCompileTimeErrors: generateCodeWithCompileTimeErrors, | 442 generateCodeWithCompileTimeErrors: generateCodeWithCompileTimeErrors, |
| 425 generateSourceMap: generateSourceMap, | 443 generateSourceMap: generateSourceMap, |
| 426 hasIncrementalSupport: hasIncrementalSupport, | 444 hasIncrementalSupport: hasIncrementalSupport, |
| 427 outputUri: outputUri, | 445 outputUri: outputUri, |
| 428 platformConfigUri: platformConfigUri ?? | 446 platformConfigUri: platformConfigUri ?? |
| 429 _resolvePlatformConfig( | 447 _resolvePlatformConfig( |
| 430 libraryRoot, null, !emitJavaScript, const []), | 448 libraryRoot, null, !emitJavaScript, const []), |
| 431 preserveComments: preserveComments, | 449 preserveComments: preserveComments, |
| 432 preserveUris: preserveUris, | 450 preserveUris: preserveUris, |
| 451 resolutionInput: resolutionInput, |
| 452 resolutionOutput: resolutionOutput, |
| 453 resolveOnly: resolveOnly, |
| 433 sourceMapUri: sourceMapUri, | 454 sourceMapUri: sourceMapUri, |
| 434 strips: strips, | 455 strips: strips, |
| 435 testMode: testMode, | 456 testMode: testMode, |
| 436 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, | 457 trustJSInteropTypeAnnotations: trustJSInteropTypeAnnotations, |
| 437 trustPrimitives: trustPrimitives, | 458 trustPrimitives: trustPrimitives, |
| 438 trustTypeAnnotations: trustTypeAnnotations, | 459 trustTypeAnnotations: trustTypeAnnotations, |
| 439 useContentSecurityPolicy: useContentSecurityPolicy, | 460 useContentSecurityPolicy: useContentSecurityPolicy, |
| 440 useCpsIr: useCpsIr, | 461 useCpsIr: useCpsIr, |
| 441 useFrequencyNamer: useFrequencyNamer, | 462 useFrequencyNamer: useFrequencyNamer, |
| 442 useNewSourceInfo: useNewSourceInfo, | 463 useNewSourceInfo: useNewSourceInfo, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 471 this.enableNativeLiveTypeAnalysis: false, | 492 this.enableNativeLiveTypeAnalysis: false, |
| 472 this.enableTypeAssertions: false, | 493 this.enableTypeAssertions: false, |
| 473 this.enableUserAssertions: false, | 494 this.enableUserAssertions: false, |
| 474 this.generateCodeWithCompileTimeErrors: false, | 495 this.generateCodeWithCompileTimeErrors: false, |
| 475 this.generateSourceMap: true, | 496 this.generateSourceMap: true, |
| 476 this.hasIncrementalSupport: false, | 497 this.hasIncrementalSupport: false, |
| 477 this.outputUri: null, | 498 this.outputUri: null, |
| 478 this.platformConfigUri: null, | 499 this.platformConfigUri: null, |
| 479 this.preserveComments: false, | 500 this.preserveComments: false, |
| 480 this.preserveUris: false, | 501 this.preserveUris: false, |
| 502 this.resolutionInput: null, |
| 503 this.resolutionOutput: null, |
| 504 this.resolveOnly: false, |
| 481 this.sourceMapUri: null, | 505 this.sourceMapUri: null, |
| 482 this.strips: const [], | 506 this.strips: const [], |
| 483 this.testMode: false, | 507 this.testMode: false, |
| 484 this.trustJSInteropTypeAnnotations: false, | 508 this.trustJSInteropTypeAnnotations: false, |
| 485 this.trustPrimitives: false, | 509 this.trustPrimitives: false, |
| 486 this.trustTypeAnnotations: false, | 510 this.trustTypeAnnotations: false, |
| 487 this.useContentSecurityPolicy: false, | 511 this.useContentSecurityPolicy: false, |
| 488 this.useCpsIr: false, | 512 this.useCpsIr: false, |
| 489 this.useFrequencyNamer: false, | 513 this.useFrequencyNamer: false, |
| 490 this.useNewSourceInfo: false, | 514 this.useNewSourceInfo: false, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 614 |
| 591 /// Locations of the platform descriptor files relative to the library root. | 615 /// Locations of the platform descriptor files relative to the library root. |
| 592 const String _clientPlatform = "lib/dart_client.platform"; | 616 const String _clientPlatform = "lib/dart_client.platform"; |
| 593 const String _serverPlatform = "lib/dart_server.platform"; | 617 const String _serverPlatform = "lib/dart_server.platform"; |
| 594 const String _sharedPlatform = "lib/dart_shared.platform"; | 618 const String _sharedPlatform = "lib/dart_shared.platform"; |
| 595 const String _dart2dartPlatform = "lib/dart2dart.platform"; | 619 const String _dart2dartPlatform = "lib/dart2dart.platform"; |
| 596 | 620 |
| 597 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; | 621 const String _UNDETERMINED_BUILD_ID = "build number could not be determined"; |
| 598 const bool _forceIncrementalSupport = | 622 const bool _forceIncrementalSupport = |
| 599 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); | 623 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); |
| OLD | NEW |